]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR target/51643 (Incorrect code produced for tail-call of weak function with ...
authorRichard Earnshaw <rearnsha@arm.com>
Thu, 22 Dec 2011 14:28:39 +0000 (14:28 +0000)
committerRichard Earnshaw <rearnsha@gcc.gnu.org>
Thu, 22 Dec 2011 14:28:39 +0000 (14:28 +0000)
PR target/51643
* arm.c (arm_function_ok_for_sibcall): Don't try to tailcall a
weak function on bare-metal EABI targets.

* gcc.target/arm/sibcall-2.c: New test.

From-SVN: r182622

gcc/ChangeLog
gcc/config/arm/arm.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/arm/sibcall-2.c [new file with mode: 0644]

index a11ac8a77794568418a09b2c9b68cf8f9e07744b..cd22ed466177aae011adc86c97121ada382d8b2a 100644 (file)
@@ -1,3 +1,9 @@
+2011-12-21  Richard Earnshaw  <rearnsha@arm.com>
+
+       PR target/51643
+       * arm.c (arm_function_ok_for_sibcall): Don't try to tailcall a
+       weak function on bare-metal EABI targets.
+
 2011-12-21  Uros Bizjak  <ubizjak@gmail.com>
 
        Backport from mainline
index b79de0892f071128858f3aa9820fd8375299ec93..f271320c80e3a359807017d27a3f01df364c465b 100644 (file)
@@ -5077,6 +5077,14 @@ arm_function_ok_for_sibcall (tree decl, tree exp)
   if (IS_STACKALIGN (func_type))
     return false;
 
+  /* The AAPCS says that, on bare-metal, calls to unresolved weak
+     references should become a NOP.  Don't convert such calls into
+     sibling calls.  */
+  if (TARGET_AAPCS_BASED
+      && arm_abi == ARM_ABI_AAPCS
+      && lookup_attribute ("weak", DECL_ATTRIBUTES (decl)))
+    return false;
+
   /* Everything else is ok.  */
   return true;
 }
index 6071d1f609b496721538383fd29f56f1488f4c72..86ca26fccf479eddc7b87c5a5a97300f0b74ca13 100644 (file)
@@ -1,3 +1,8 @@
+2011-12-21  Richard Earnshaw  <rearnsha@arm.com>
+
+       PR target/51643
+       * gcc.target/arm/sibcall-2.c: New test.
+
 2011-12-19  Martin Jambor  <mjambor@suse.cz>
 
        PR tree-optimization/51583
diff --git a/gcc/testsuite/gcc.target/arm/sibcall-2.c b/gcc/testsuite/gcc.target/arm/sibcall-2.c
new file mode 100644 (file)
index 0000000..921c0f3
--- /dev/null
@@ -0,0 +1,12 @@
+/* { dg-require-effective-target arm_eabi } */
+/* { dg-do compile } */
+/* { dg-options "-O2 -mabi=aapcs" } */
+
+
+extern void __attribute__((weak)) wfunc(void);
+void main(void)
+{
+  wfunc();  /* Must not tail-call.  */
+}
+
+/* { dg-final { scan-assembler-not "b\[\\t \]+wfunc" } } */