This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Fix PR28516 (Arm nested function ICE)


The attached patch fixes PR target/28516. This is an ICE when compiling nested 
functions with -fexceptions.

Despite what the PR says I'm not convinced this is a regression. However it 
does cause glibc build failures, so I'm choosing to apply it anyway.

The nested function case requires a very new gas. I think this is ok as the 
new gas feature is only required in the cases that would previously ICE.

Tested with cross to arm-none-eabi.
Applied to trunk and branches/csl/sourcerygxx-4_1.

Paul

2006-09-19  Paul Brook  <paul@codesourcery.com>

	PR target/28516
	gcc/
	* config/arm/arm.c (arm_unwind_emit_set): Handle reg = sp + const.

	gcc/testsuite/
	* gcc.dg/nested-func-5.c: New test.
Index: gcc/testsuite/gcc.dg/nested-func-5.c
===================================================================
--- gcc/testsuite/gcc.dg/nested-func-5.c	(revision 0)
+++ gcc/testsuite/gcc.dg/nested-func-5.c	(revision 0)
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-fexceptions" } */
+/* PR28516: ICE generating ARM unwind directives for nested functions.  */
+
+void ex(int (*)(void));
+void foo(int i)
+{
+  int bar(void)
+  {
+    return i;
+  }
+  ex(bar);
+}
Index: gcc/config/arm/arm.c
===================================================================
--- gcc/config/arm/arm.c	(revision 117054)
+++ gcc/config/arm/arm.c	(working copy)
@@ -15415,6 +15415,15 @@ arm_unwind_emit_set (FILE * asm_out_file
 	  /* Move from sp to reg.  */
 	  asm_fprintf (asm_out_file, "\t.movsp %r\n", REGNO (e0));
 	}
+     else if (GET_CODE (e1) == PLUS
+	      && GET_CODE (XEXP (e1, 0)) == REG
+	      && REGNO (XEXP (e1, 0)) == SP_REGNUM
+	      && GET_CODE (XEXP (e1, 1)) == CONST_INT)
+	{
+	  /* Set reg to offset from sp.  */
+	  asm_fprintf (asm_out_file, "\t.movsp %r, #%d\n",
+		       REGNO (e0), (int)INTVAL(XEXP (e1, 1)));
+	}
       else
 	abort ();
       break;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]