Patchwork [ARM] Fix PR56732

login
register
mail settings
Submitter Greta Yorsh
Date May 2, 2013, 12:52 p.m.
Message ID <000001ce4733$f58ebe40$e0ac3ac0$@yorsh@arm.com>
Download mbox | patch
Permalink /patch/240953/
State New
Headers show

Comments

Greta Yorsh - May 2, 2013, 12:52 p.m.
Epilogue in RTL (r188743) generated for naked functions adds simple return
jump insn and causes an ICE, as described here:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56732

There is a missing check of really_return argument in arm_expand_epilogue.
This patch adds the missing check and a new test.

No regression on qemu for arm-none-eabi with cortex-a15 arm/thumb.
Bootstrap successful on Cortex-A15 and no regression.

Ok for trunk?

Thanks,
Greta

gcc/ChangeLog

2013-05-02  Greta Yorsh  <Greta.Yorsh@arm.com>

	PR target/56732
	* config/arm/arm.c (arm_expand_epilogue): Check really_return before
	generating simple_return for naked functions.

gcc/testsuite/ChangeLog

2013-05-02  Greta Yorsh  <Greta.Yorsh@arm.com>

	PR target/56732
	* gcc.target/arm/pr56732-1.c: New test.
Richard Earnshaw - May 2, 2013, 2:45 p.m.
On 02/05/13 13:52, Greta Yorsh wrote:
> Epilogue in RTL (r188743) generated for naked functions adds simple return
> jump insn and causes an ICE, as described here:
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56732
>
> There is a missing check of really_return argument in arm_expand_epilogue.
> This patch adds the missing check and a new test.
>
> No regression on qemu for arm-none-eabi with cortex-a15 arm/thumb.
> Bootstrap successful on Cortex-A15 and no regression.
>
> Ok for trunk?
>
> Thanks,
> Greta
>
> gcc/ChangeLog
>
> 2013-05-02  Greta Yorsh  <Greta.Yorsh@arm.com>
>
> 	PR target/56732
> 	* config/arm/arm.c (arm_expand_epilogue): Check really_return before
> 	generating simple_return for naked functions.
>
> gcc/testsuite/ChangeLog
>
> 2013-05-02  Greta Yorsh  <Greta.Yorsh@arm.com>
>
> 	PR target/56732
> 	* gcc.target/arm/pr56732-1.c: New test.
>
>
OK.

R.

Patch

diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index 464d91c..9d4a453 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -24067,7 +24067,8 @@  arm_expand_epilogue (bool really_return)
   if (IS_NAKED (func_type)
       || (IS_VOLATILE (func_type) && TARGET_ABORT_NORETURN))
     {
-      emit_jump_insn (simple_return_rtx);
+      if (really_return)
+        emit_jump_insn (simple_return_rtx);
       return;
     }
 
diff --git a/gcc/testsuite/gcc.target/arm/pr56732-1.c b/gcc/testsuite/gcc.target/arm/pr56732-1.c
new file mode 100644
index 0000000..ac8b8cf
--- /dev/null
+++ b/gcc/testsuite/gcc.target/arm/pr56732-1.c
@@ -0,0 +1,20 @@ 
+/* { dg-do compile } */
+/* { dg-require-effective-target naked_functions } */
+/* { dg-options "-O2 -Wall" } */
+extern void bar();
+
+void __attribute__((__naked__))
+foo(void)
+{
+  bar ();
+}
+
+int __attribute__((naked))
+zoo (int a, int b, int c, int d, int e, int f)
+{
+  bar ();
+  return e;
+}
+/* Verify that __attribute__((naked)) produces a naked function that
+   does not use bx to return. */
+/* { dg-final { scan-assembler-not "\tbx\tlr" } } */