OSDN Git Service

PR target/51643
authorrearnsha <rearnsha@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 22 Dec 2011 14:13:09 +0000 (14:13 +0000)
committerrearnsha <rearnsha@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 22 Dec 2011 14:13:09 +0000 (14:13 +0000)
* 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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@182621 138bc75d-0d04-0410-961f-82ee72b054a4

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

index a26d8b4..d1c9a2f 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  Jonathan Wakely  <jwakely.gcc@gmail.com>
            Jim Avera  <james_avera@yahoo.com>
 
index b682a9f..fec43fb 100644 (file)
@@ -5250,6 +5250,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 18db669..9e58adc 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-22  Uros Bizjak  <ubizjak@gmail.com>
 
        PR testsuite/51645
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" } } */