From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20290 invoked by alias); 18 Nov 2015 23:18:50 -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 20279 invoked by uid 89); 18 Nov 2015 23:18:49 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 18 Nov 2015 23:18:48 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 7D31F4AD68; Wed, 18 Nov 2015 23:18:47 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-116-34.ams2.redhat.com [10.36.116.34]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tAINIkbj013670 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 18 Nov 2015 18:18:47 -0500 Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id tAINIhZP004953; Thu, 19 Nov 2015 00:18:44 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id tAINIgNh004952; Thu, 19 Nov 2015 00:18:42 +0100 Date: Wed, 18 Nov 2015 23:18:00 -0000 From: Jakub Jelinek To: Uros Bizjak Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Disable shrink-wrapping for ix86_static_chain_on_stack functions (PR target/67770) Message-ID: <20151118231842.GP5675@tucnak.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes X-SW-Source: 2015-11/txt/msg02286.txt.bz2 Hi! As the testcase shows, shrink-wrapping is incompatible with ix86_static_chain_on_stack, where we rely on the very first instruction in the (nested) function to be pushl %esi and use alternate entry point right after that pushl instruction (one byte after the start of the nested function). If shrink-wrapping moves the prologue somewhere else, then this is no longer true. Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk/5.3? 2015-11-18 Jakub Jelinek PR target/67770 * config/i386/i386.md (simple_return): Disable if ix86_static_chain_on_stack is true. * gcc.target/i386/pr67770.c: New test. --- gcc/config/i386/i386.md.jj 2015-11-14 19:36:03.000000000 +0100 +++ gcc/config/i386/i386.md 2015-11-18 17:49:51.648115096 +0100 @@ -12187,10 +12187,14 @@ (define_expand "return" ;; We need to disable this for TARGET_SEH, as otherwise ;; shrink-wrapped prologue gets enabled too. This might exceed ;; the maximum size of prologue in unwind information. +;; Also disallow shrink-wrapping if using stack slot to pass the +;; 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. (define_expand "simple_return" [(simple_return)] - "!TARGET_SEH" + "!TARGET_SEH && !ix86_static_chain_on_stack" { if (crtl->args.pops_args) { --- gcc/testsuite/gcc.target/i386/pr67770.c.jj 2015-11-18 17:38:13.940956205 +0100 +++ gcc/testsuite/gcc.target/i386/pr67770.c 2015-11-18 17:53:22.354143509 +0100 @@ -0,0 +1,40 @@ +/* PR target/67770 */ +/* { dg-do run { target ia32 } } */ +/* { dg-require-effective-target trampolines } */ +/* { dg-options "-O2" } */ + +#ifndef NO_TRAMPOLINES +__attribute__ ((noinline)) void +foo (int i, void (* __attribute__ ((regparm (3))) bar) (int)) +{ + bar (i); +} +#endif + +int +main () +{ +#ifndef NO_TRAMPOLINES + int p = 0; + + __attribute__ ((regparm (3), noinline)) void + bar (int i) + { + if (__builtin_expect (i, 0)) + ++p; + } + + foo (0, bar); + bar (0); + + if (p != 0) + __builtin_abort (); + + foo (1, bar); + bar (1); + + if (p != 2) + __builtin_abort (); +#endif + return 0; +} Jakub