From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 97205 invoked by alias); 21 Feb 2020 09:11:04 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 97196 invoked by uid 89); 21 Feb 2020 09:11:03 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-19.3 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mail-lj1-f196.google.com Received: from mail-lj1-f196.google.com (HELO mail-lj1-f196.google.com) (209.85.208.196) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 21 Feb 2020 09:11:01 +0000 Received: by mail-lj1-f196.google.com with SMTP id r19so1432157ljg.3 for ; Fri, 21 Feb 2020 01:11:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:autocrypt:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=DFCAdyvbdjnyuB/xx3ghY17BLTZGtqG9g6xdjOe+lTw=; b=Hq++ovYUGYz2kK5JN5JLFjDKi/5dRqkp5yRH7f/1L16C2L5CLUq1pAcbJ582y2Bl+H fCQx9TAqgxcbRygpZB6m2KUDpQFfNdHpulfz3aAti0YKXev3mLEVYvikeGitQm25cszK RW7tpC0en2Xb/puK98C0Rugl1jlaPCPB0n2XHqUgf4z71w5QvKHl/70Tc3Q7z1lf/yL1 ev1jyCl1Lfsut4PJm47UgQcfHWLkN3JdlKKMNfsCpp312IG7z7BjCqQcrFlqpvwHWonI /m79v7JJmg9NNfVfm4EOpf2hH7efEMbE1XGs2QEgwoQvRn5UQt0o9GDCcKE86Sr66196 K4Rg== Return-Path: Received: from [192.168.11.148] ([185.68.146.210]) by smtp.gmail.com with ESMTPSA id a8sm1230246ljn.74.2020.02.21.01.10.58 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 21 Feb 2020 01:10:58 -0800 (PST) Subject: Re: [PATCH] Fix stack pointer handling in ms_hook_prologue functions for i386 target. To: gcc-patches@gcc.gnu.org References: <20200210162241.988175-1-gofmanp@gmail.com> From: Paul Gofman Message-ID: <78f3ce96-8225-c40c-c1ea-8080011308c2@gmail.com> Date: Fri, 21 Feb 2020 09:11:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: <20200210162241.988175-1-gofmanp@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-IsSubscribed: yes X-SW-Source: 2020-02/txt/msg01189.txt.bz2 Hello,     ping for patch https://gcc.gnu.org/ml/gcc-patches/2020-02/msg00554.html. Thanks,     Paul. On 2/10/20 19:22, Paul Gofman wrote: > ChangeLog: > PR target/91489 > * config/i386/i386.md (simple_return): Also check > for ms_hook_prologue function attribute. > * config/i386/i386.c (ix86_can_use_return_insn_p): > Also check for ms_hook_prologue function attribute. > > testsuite/ChangeLog: > PR target/91489 > * gcc.target/i386/ms_hook_prologue.c: Expand testcase > to reproduce PR target/91489 issue. > > Signed-off-by: Paul Gofman > --- > gcc/config/i386/i386-protos.h | 1 + > gcc/config/i386/i386.c | 3 +++ > gcc/config/i386/i386.md | 5 ++++- > gcc/testsuite/gcc.target/i386/ms_hook_prologue.c | 13 ++++++++++++- > 4 files changed, 20 insertions(+), 2 deletions(-) > > diff --git a/gcc/config/i386/i386-protos.h b/gcc/config/i386/i386-protos.h > index 266381ca5a6..966ce426a18 100644 > --- a/gcc/config/i386/i386-protos.h > +++ b/gcc/config/i386/i386-protos.h > @@ -26,6 +26,7 @@ extern bool ix86_handle_option (struct gcc_options *opts, > /* Functions in i386.c */ > extern bool ix86_target_stack_probe (void); > extern bool ix86_can_use_return_insn_p (void); > +extern bool ix86_function_ms_hook_prologue (const_tree fn); > extern void ix86_setup_frame_addresses (void); > extern bool ix86_rip_relative_addr_p (struct ix86_address *parts); > > diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c > index 44bc0e0176a..68e2a7519f4 100644 > --- a/gcc/config/i386/i386.c > +++ b/gcc/config/i386/i386.c > @@ -4954,6 +4954,9 @@ symbolic_reference_mentioned_p (rtx op) > bool > ix86_can_use_return_insn_p (void) > { > + if (ix86_function_ms_hook_prologue (current_function_decl)) > + return false; > + > if (ix86_function_naked (current_function_decl)) > return false; > > diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md > index f14683cd14f..a7302b886c6 100644 > --- a/gcc/config/i386/i386.md > +++ b/gcc/config/i386/i386.md > @@ -13445,10 +13445,13 @@ > ;; static chain pointer - the first instruction has to be pushl %esi > ;; and it can't be moved around, as we use alternate entry points > ;; in that case. > +;; Also disallow for ms_hook_prologue functions which have frame > +;; pointer set up in function label which is correctly handled in > +;; ix86_expand_{prologue|epligoue}() only. > > (define_expand "simple_return" > [(simple_return)] > - "!TARGET_SEH && !ix86_static_chain_on_stack" > + "!TARGET_SEH && !ix86_static_chain_on_stack && !ix86_function_ms_hook_prologue (cfun->decl)" > { > if (crtl->args.pops_args) > { > diff --git a/gcc/testsuite/gcc.target/i386/ms_hook_prologue.c b/gcc/testsuite/gcc.target/i386/ms_hook_prologue.c > index e11bcc049cb..12e54c0e4ad 100644 > --- a/gcc/testsuite/gcc.target/i386/ms_hook_prologue.c > +++ b/gcc/testsuite/gcc.target/i386/ms_hook_prologue.c > @@ -4,6 +4,8 @@ > /* { dg-require-effective-target ms_hook_prologue } */ > /* { dg-options "-O2 -fomit-frame-pointer" } */ > > +#include > + > int __attribute__ ((__ms_hook_prologue__)) foo () > { > unsigned char *ptr = (unsigned char *) foo; > @@ -32,7 +34,16 @@ int __attribute__ ((__ms_hook_prologue__)) foo () > return 0; > } > > +unsigned int __attribute__ ((noinline, __ms_hook_prologue__)) test_func() > +{ > + static int value; > + > + if (value++) puts(""); > + > + return 0; > +} > + > int main () > { > - return foo(); > + return foo() || test_func(); > }