Message ID | 20230713164756.3558785-2-mikpelinux@gmail.com |
---|---|
State | Accepted |
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp1954745vqm; Thu, 13 Jul 2023 09:52:15 -0700 (PDT) X-Google-Smtp-Source: APBJJlFUMVgNHOkeuWeBI1HRxsyT+bFZ9lARrpIe5IXz79M0zM9U+g4zusaOjmmbSwEDUd+t9Sdw X-Received: by 2002:a05:6512:5c9:b0:4f9:5a87:1028 with SMTP id o9-20020a05651205c900b004f95a871028mr1684107lfo.30.1689267135068; Thu, 13 Jul 2023 09:52:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689267135; cv=none; d=google.com; s=arc-20160816; b=qZ3n9RzrBHpCIccKRkYsYfWL5rU1Wr0mVoEFMvSy/3hsEooEtvnr/h4QahOeEDkyS1 wiTremWyk2lUbaZcUtuh3mVqjXDT+poBz62yqmSlg5rHfQK+gKjNFIQCC/qcEEeLVZqC FSxFnZppi04Kk5/f74L8o5E3ISQe+CggBA2WuYo5NdfhjaTeuNkp+2lTNN2Rvr0z+i8Z 5urytatT5V19J9+UEO13JNczfECFXEm+34Usr7/qIzhRvmX3B/b8HYA+Gc302nPKDShv AayorIeFBGXxU+xAxH90zYYOmKGflaHJ1h16Yf2eVX/a8z8X7fhaKgSNQ1UF49ZlM+JP tHIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=bUQzWbCFpYrj9g5b8H4RAs/hT8H9wssHbpiADKP8BmE=; fh=LHnENvTTaXNsE7421wiK7HdkNeNGqyt9A07NFUB6POA=; b=dJyGo2Xfrwtr+0mkx3LDhkMxHlRRvOqdX7AYOvBf2DOP9HFDUaL0YCd6ZTOXWIdjET mox4lulLLczjH6YaTUDF60uLCJ3y377fUHJpIKKw2VMlyEwAKE+Fh7y/ksiw6xG0pOuI BtBNVqep5KmzZ/NUo+Fsycs59G5D4wsf+xDqMg7irQCOdZhSQK6EFAIwYa8o3VSNknjr pC/8H4l98oFsvtGeHYPox3KueKQxD9234SHDyHcugMqo26bEAfU2Ag7sPUfvZgBdUOZu IX2kE6Jk9+QFOmmqiCCPy3wmeBayyAej5owGwWuM8djrAScEugV8VF8bARVasdAxaGI0 zfwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=bD5bwXTn; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id o12-20020aa7c50c000000b0051e57e864adsi7458859edq.189.2023.07.13.09.52.14 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jul 2023 09:52:15 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=bD5bwXTn; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 957CF3858422 for <ouuuleilei@gmail.com>; Thu, 13 Jul 2023 16:52:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 957CF3858422 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1689267133; bh=bUQzWbCFpYrj9g5b8H4RAs/hT8H9wssHbpiADKP8BmE=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=bD5bwXTnxEUL3T2xlRqATvgx6lGAw+jHCSWGUMgPrV7pT7jiyKP6mfGcij5Mjmkv/ 7ueoWEGhOnmfW6pZ5BJhDi1riby/H6IaKKT0SCBX0fzyL34Oilgw45yffShE8YzB3g S+AP7vTJhVwusMwWRkfLuCuZqXp8+uPMaTZBkeLA= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lf1-x133.google.com (mail-lf1-x133.google.com [IPv6:2a00:1450:4864:20::133]) by sourceware.org (Postfix) with ESMTPS id E3A583858D1E for <gcc-patches@gcc.gnu.org>; Thu, 13 Jul 2023 16:51:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E3A583858D1E Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-4f9fdb0ef35so1738594e87.0 for <gcc-patches@gcc.gnu.org>; Thu, 13 Jul 2023 09:51:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689267086; x=1691859086; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=bUQzWbCFpYrj9g5b8H4RAs/hT8H9wssHbpiADKP8BmE=; b=K69DdNVV9zgbK78EXVotqj8zPyu6heca9zkxdFzqbtiOiUJIlj/w9ocDcPtAiBLMVI FiGjRYn4XkU2p9AqEK7y413sUpUcmoLkzTnJD9mQRsP6czt3j889sXjI2bUPPrgO2n52 A4pd9jmGwNB4E5aNeElwRZ9NwET8HLvM9qOtjpVLL7Pmi+pT1R7q6csf76iwluM12gjU dtliZGh1Xc4+BBKxd8JBCSq7gsSxp5djSf5qFaCXTsaTeYVz/m7Nb9xFDA7r0FmyLkC0 VXb1KL2yNxSZgV+rAhaM7DIu7IKmesXM3D8O4UKyj+YdwJ3Awyr1NA/OIkwtFDMLc4Uk haNQ== X-Gm-Message-State: ABy/qLaMaLsvKzVCv+XSQgrLdbU5nbzAuyxLF337sKhlTAg3lV/0Q7KP BvB2i0eWbK3i9jEZld+Wz5GMAIonMXeMew== X-Received: by 2002:ac2:57ca:0:b0:4fb:97e8:bc25 with SMTP id k10-20020ac257ca000000b004fb97e8bc25mr1615792lfo.34.1689267085866; Thu, 13 Jul 2023 09:51:25 -0700 (PDT) Received: from hallertau.. (ip006.net-192-176-117.koping.net. [192.176.117.6]) by smtp.gmail.com with ESMTPSA id h12-20020ac2596c000000b004fbb011c9c7sm1174829lfp.162.2023.07.13.09.51.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jul 2023 09:51:25 -0700 (PDT) To: gcc-patches@gcc.gnu.org Cc: Paul Koning <ni1d@arrl.net>, Mikael Pettersson <mikpelinux@gmail.com> Subject: [PATCH] fix pdp11_expand_epilogue (PR target/107841) Date: Thu, 13 Jul 2023 18:47:57 +0200 Message-ID: <20230713164756.3558785-2-mikpelinux@gmail.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> From: Mikael Pettersson via Gcc-patches <gcc-patches@gcc.gnu.org> Reply-To: Mikael Pettersson <mikpelinux@gmail.com> Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771324975577939972 X-GMAIL-MSGID: 1771324975577939972 |
Series |
fix pdp11_expand_epilogue (PR target/107841)
|
|
Checks
Context | Check | Description |
---|---|---|
snail/gcc-patch-check | success | Github commit url |
Commit Message
Mikael Pettersson
July 13, 2023, 4:47 p.m. UTC
If the stack frame only contains an alloca area, then pdp11_expand_epilogue fails to deallocate it, resulting in callee-saved registers and the return address being restored from the wrong stack slots. Fixed by adding || cfun->calls_alloca to the condition for deallocating the frame. Tested with a cross to pdp11-unknown-aout. Ok for master? (Note: I don't have commit rights.) gcc/ PR target/107841 * config/pdp11/pdp11.c (pdp11_expand_epilogue): Also deallocate alloca-only frame. gcc/testsuite/ PR target/107841 * gcc.target/pdp11/pr107841.c: New test. --- gcc/config/pdp11/pdp11.cc | 2 +- gcc/testsuite/gcc.target/pdp11/pr107841.c | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.target/pdp11/pr107841.c
Comments
> On Jul 13, 2023, at 12:47 PM, Mikael Pettersson <mikpelinux@gmail.com> wrote: > > If the stack frame only contains an alloca area, then > pdp11_expand_epilogue fails to deallocate it, resulting > in callee-saved registers and the return address being > restored from the wrong stack slots. Fixed by adding > || cfun->calls_alloca to the condition for deallocating > the frame. > > Tested with a cross to pdp11-unknown-aout. > > Ok for master? (Note: I don't have commit rights.) Yes, thank you! Question for the experts: how is this handled? Do I need to apply this change to my workspace and commit it, with Mikael as the change author? paul > > gcc/ > > PR target/107841 > * config/pdp11/pdp11.c (pdp11_expand_epilogue): Also > deallocate alloca-only frame. > > gcc/testsuite/ > > PR target/107841 > * gcc.target/pdp11/pr107841.c: New test. > --- > gcc/config/pdp11/pdp11.cc | 2 +- > gcc/testsuite/gcc.target/pdp11/pr107841.c | 12 ++++++++++++ > 2 files changed, 13 insertions(+), 1 deletion(-) > create mode 100644 gcc/testsuite/gcc.target/pdp11/pr107841.c > > diff --git a/gcc/config/pdp11/pdp11.cc b/gcc/config/pdp11/pdp11.cc > index f6dd841f184..311a1d225e0 100644 > --- a/gcc/config/pdp11/pdp11.cc > +++ b/gcc/config/pdp11/pdp11.cc > @@ -393,7 +393,7 @@ pdp11_expand_epilogue (void) > rtx x, reg, via_ac = NULL; > > /* Deallocate the local variables. */ > - if (fsize) > + if (fsize || cfun->calls_alloca) > { > if (frame_pointer_needed) > { > diff --git a/gcc/testsuite/gcc.target/pdp11/pr107841.c b/gcc/testsuite/gcc.target/pdp11/pr107841.c > new file mode 100644 > index 00000000000..a363c468b0b > --- /dev/null > +++ b/gcc/testsuite/gcc.target/pdp11/pr107841.c > @@ -0,0 +1,12 @@ > +/* { dg-do compile } */ > +/* { dg-options "-O2" } */ > + > +/* Verify that the stack frame is deallocated using the frame pointer. */ > + > +void qq (int a) > +{ > + char *s = __builtin_alloca (128); > + __builtin_sprintf (s, "qq %d", 3); > +} > + > +/* { dg-final { scan-assembler "mov\tr5,sp" } } */ > -- > 2.41.0 >
On 7/13/23 11:46, Paul Koning via Gcc-patches wrote: > > >> On Jul 13, 2023, at 12:47 PM, Mikael Pettersson <mikpelinux@gmail.com> wrote: >> >> If the stack frame only contains an alloca area, then >> pdp11_expand_epilogue fails to deallocate it, resulting >> in callee-saved registers and the return address being >> restored from the wrong stack slots. Fixed by adding >> || cfun->calls_alloca to the condition for deallocating >> the frame. >> >> Tested with a cross to pdp11-unknown-aout. >> >> Ok for master? (Note: I don't have commit rights.) > > Yes, thank you! > > Question for the experts: how is this handled? Do I need to apply this change to my workspace and commit it, with Mikael as the change author? That's what I usually do for someone without write access. commit it locally using the --author flag, then push. jeff
> On Jul 13, 2023, at 12:47 PM, Mikael Pettersson <mikpelinux@gmail.com> wrote: > > If the stack frame only contains an alloca area, then > pdp11_expand_epilogue fails to deallocate it, resulting > in callee-saved registers and the return address being > restored from the wrong stack slots. Fixed by adding > || cfun->calls_alloca to the condition for deallocating > the frame. > > Tested with a cross to pdp11-unknown-aout. > > Ok for master? (Note: I don't have commit rights.) > > gcc/ > > PR target/107841 > * config/pdp11/pdp11.c (pdp11_expand_epilogue): Also > deallocate alloca-only frame. > > gcc/testsuite/ > > PR target/107841 > * gcc.target/pdp11/pr107841.c: New test. > --- > gcc/config/pdp11/pdp11.cc | 2 +- > gcc/testsuite/gcc.target/pdp11/pr107841.c | 12 ++++++++++++ > 2 files changed, 13 insertions(+), 1 deletion(-) > create mode 100644 gcc/testsuite/gcc.target/pdp11/pr107841.c > > diff --git a/gcc/config/pdp11/pdp11.cc b/gcc/config/pdp11/pdp11.cc > index f6dd841f184..311a1d225e0 100644 > --- a/gcc/config/pdp11/pdp11.cc > +++ b/gcc/config/pdp11/pdp11.cc > @@ -393,7 +393,7 @@ pdp11_expand_epilogue (void) > rtx x, reg, via_ac = NULL; > > /* Deallocate the local variables. */ > - if (fsize) > + if (fsize || cfun->calls_alloca) > { > if (frame_pointer_needed) > { > diff --git a/gcc/testsuite/gcc.target/pdp11/pr107841.c b/gcc/testsuite/gcc.target/pdp11/pr107841.c > new file mode 100644 > index 00000000000..a363c468b0b > --- /dev/null > +++ b/gcc/testsuite/gcc.target/pdp11/pr107841.c > @@ -0,0 +1,12 @@ > +/* { dg-do compile } */ > +/* { dg-options "-O2" } */ > + > +/* Verify that the stack frame is deallocated using the frame pointer. */ > + > +void qq (int a) > +{ > + char *s = __builtin_alloca (128); > + __builtin_sprintf (s, "qq %d", 3); > +} > + > +/* { dg-final { scan-assembler "mov\tr5,sp" } } */ > -- > 2.41.0 > Thanks Mikael. I committed this fix. paul
On Thu, 13 Jul 2023, Jeff Law via Gcc-patches wrote: > > Question for the experts: how is this handled? Do I need to apply this > > change to my workspace and commit it, with Mikael as the change author? > That's what I usually do for someone without write access. commit it locally > using the --author flag, then push. FWIW `git am' taking the e-mail containing a change on stdin is I believe the most straightforward way, as long as the submission has been properly formatted. The command automatically sets the author correctly, picking the `From:' entry from the e-mail headers or the first line of the e-mail body as appropriate, sets the author date from the `Date:' header, picks up the contents of the `Subject:' header as the change heading and the body of the e-mail sans any `From:' entry as the change description, and strips any discussion between the non-commit delimiter (`--') and the patch itself. The command was designed for maintainers to import changes submitted by e-mail so it does what expected. Any issues with an imported change can then be addressed with `git commit --amend', etc. HTH, Maciej
diff --git a/gcc/config/pdp11/pdp11.cc b/gcc/config/pdp11/pdp11.cc index f6dd841f184..311a1d225e0 100644 --- a/gcc/config/pdp11/pdp11.cc +++ b/gcc/config/pdp11/pdp11.cc @@ -393,7 +393,7 @@ pdp11_expand_epilogue (void) rtx x, reg, via_ac = NULL; /* Deallocate the local variables. */ - if (fsize) + if (fsize || cfun->calls_alloca) { if (frame_pointer_needed) { diff --git a/gcc/testsuite/gcc.target/pdp11/pr107841.c b/gcc/testsuite/gcc.target/pdp11/pr107841.c new file mode 100644 index 00000000000..a363c468b0b --- /dev/null +++ b/gcc/testsuite/gcc.target/pdp11/pr107841.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +/* Verify that the stack frame is deallocated using the frame pointer. */ + +void qq (int a) +{ + char *s = __builtin_alloca (128); + __builtin_sprintf (s, "qq %d", 3); +} + +/* { dg-final { scan-assembler "mov\tr5,sp" } } */