Patchwork [committed] Fix x86_64 ICE with very large stack frame (PR debug/46095)

login
register
mail settings
Submitter Jakub Jelinek
Date Nov. 15, 2010, 8:13 p.m.
Message ID <20101115201318.GC29412@tyan-ft48-01.lab.bos.redhat.com>
Download mbox | patch
Permalink /patch/71274/
State New
Headers show

Comments

Jakub Jelinek - Nov. 15, 2010, 8:13 p.m.
Hi!

I've committed following fix after bootstrap/regtest on x86_64-linux and
i686-linux after approval in bugzilla from rth.

The issue is that scheduler swaps movq %rsp, %rbx and movabsq $..., %r11
insns in the prologue and thus dwarf2out fragile logic fails to remember
that %r11 holds an interesting value (and which one) for unwinding purposes.

Fixed by describing the insn using REG_FRAME_RELATED_EXPR instead.

2010-11-15  Jakub Jelinek  <jakub@redhat.com>

	PR debug/46095
	* config/i386/i386.c (pro_epilogue_adjust_stack): Instead of
	marking r11 set RTX_FRAME_RELATED_P if offset is too large for
	style < 0, add REG_FRAME_RELATED_EXPR.

	* gcc.target/i386/pr46095.c: New test.


	Jakub

Patch

--- gcc/config/i386/i386.c.jj	2010-11-15 09:28:19.000000000 +0100
+++ gcc/config/i386/i386.c	2010-11-15 18:16:14.000000000 +0100
@@ -9418,6 +9418,7 @@  pro_epilogue_adjust_stack (rtx dest, rtx
 {
   struct machine_function *m = cfun->machine;
   rtx insn;
+  bool add_frame_related_expr = false;
 
   if (! TARGET_64BIT)
     insn = gen_pro_epilogue_adjust_stack_si_add (dest, src, offset);
@@ -9438,7 +9439,7 @@  pro_epilogue_adjust_stack (rtx dest, rtx
 	}
       insn = emit_insn (gen_rtx_SET (DImode, tmp, offset));
       if (style < 0)
-	RTX_FRAME_RELATED_P (insn) = 1;
+	add_frame_related_expr = true;
 
       insn = gen_pro_epilogue_adjust_stack_di_add (dest, src, tmp);
     }
@@ -9461,7 +9462,15 @@  pro_epilogue_adjust_stack (rtx dest, rtx
       RTX_FRAME_RELATED_P (insn) = 1;
     }
   else if (style < 0)
-    RTX_FRAME_RELATED_P (insn) = 1;
+    {
+      RTX_FRAME_RELATED_P (insn) = 1;
+      if (add_frame_related_expr)
+	{
+	  rtx r = gen_rtx_PLUS (Pmode, src, offset);
+	  r = gen_rtx_SET (VOIDmode, dest, r);
+	  add_reg_note (insn, REG_FRAME_RELATED_EXPR, r);
+	}
+    }
 
   if (dest == stack_pointer_rtx)
     {
--- gcc/testsuite/gcc.target/i386/pr46095.c.jj	2010-11-15 18:20:37.000000000 +0100
+++ gcc/testsuite/gcc.target/i386/pr46095.c	2010-11-15 18:18:58.000000000 +0100
@@ -0,0 +1,12 @@ 
+/* PR debug/46095 */
+/* { dg-do compile { target lp64 } } */
+/* { dg-options "-O -fschedule-insns2 -fno-omit-frame-pointer -fstack-protector" } */
+
+extern void bar (char *);
+
+void
+foo (void)
+{
+  char c[0x80000000UL];
+  bar (c);
+}