From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20744 invoked by alias); 2 Sep 2011 09:05:12 -0000 Received: (qmail 20734 invoked by uid 22791); 2 Sep 2011 09:05:10 -0000 X-SWARE-Spam-Status: No, hits=-2.9 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 02 Sep 2011 09:04:56 +0000 From: "vries at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/50251] [4.7 Regression] Revision 178353 caused many test failures Date: Fri, 02 Sep 2011 09:05:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: vries at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: vries at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.7.0 X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2011-09/txt/msg00105.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50251 --- Comment #9 from vries at gcc dot gnu.org 2011-09-02 09:03:54 UTC --- The following testcase reproduces the same failure without alloca, vla, or the 178353 patch. stack-stave-restore.c: ... extern void bar (int*); char *p; int main () { int q; p = __builtin_stack_save (); bar (&q); __builtin_stack_restore (p); bar (&q); return 0; } ... Using &q makes sure we use virtual-stack-vars, which expands into something using FRAME_POINTER_REG. Main has an incoming stack boundary of 32, and a preferred one of 128, so a realign is needed. Nothing sets crtl->need_drap, so we have stack_realign_fp rather than stack_realign_drap. This forbids elimination from FRAME_POINTER_REG to HARD_FRAME_POINTER_REG. The __builtin_stack_restore stays until ira (if we wouldn't by declaring p global), and this forbids elimination from FRAME_POINTER_REG to STACK_POINTER_REGNUM. FRAME_POINTER_REG cannot be eliminated, and we assert. This patch sets need_drap when a stack_restore is present at expand, which allows both the 20010209-1.c and the stack-stave-restore.c testcase to succeed: ... Index: src/gcc-mainline/gcc/explow.c =================================================================== --- src/gcc-mainline/gcc/explow.c (revision 178379) +++ src/gcc-mainline/gcc/explow.c (working copy) @@ -1062,6 +1062,9 @@ emit_stack_restore (enum save_level save /* The default is that we use a move insn. */ rtx (*fcn) (rtx, rtx) = gen_move_insn; + if (SUPPORTS_STACK_ALIGNMENT) + crtl->need_drap = true; + /* See if this machine has anything special to do for this kind of save. */ switch (save_level) { ...