Add an UNSPEC_PROLOGUE_USE to prevent the link register from being considered dead.
authorNick Clifton <nickc@redhat.com>
Mon, 20 Jan 2003 18:59:43 +0000 (18:59 +0000)
committerNick Clifton <nickc@gcc.gnu.org>
Mon, 20 Jan 2003 18:59:43 +0000 (18:59 +0000)
Add a testcase for the bug fixed by this patch.

From-SVN: r61509

gcc/ChangeLog
gcc/config/arm/arm.md
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/20030117-1.c [new file with mode: 0644]

index ff97b3121bf50a151e79a5323189b70a7b8eb101..c75ddc725125b6b433c2fee08939f33acc7965f9 100644 (file)
@@ -1,3 +1,9 @@
+2003-01-20  Nick Clifton  <nickc@redhat.com>
+
+       * config/arm/arm.md (sibcall_epilogue): Add an
+       UNSPEC_PROLOGUE_USE to prevent the link register from being
+       considered dead.
+
 Mon Jan 20 14:36:23 CET 2003  Jan Hubicka  <jh@suse.cz>
 
        * i386.md (SSE cmov splitter):  Handle memory operand in operand 5.
index b7a09ce4cf2ada8e2efa6940081e6ed6f1dc8cfb..40f956ee260b044bd07122091f3104b7f63f404e 100644 (file)
   "
 )
 
+;; Note - although unspec_volatile's USE all hard registers,
+;; USEs are ignored after relaod has completed.  Thus we need
+;; to add an unspec of the link register to ensure that flow
+;; does not think that it is unused by the sibcall branch that
+;; will replace the standard function epilogue.
 (define_insn "sibcall_epilogue"
-  [(unspec_volatile [(const_int 0)] VUNSPEC_EPILOGUE)]
+  [(parallel [(unspec:SI [(reg:SI LR_REGNUM)] UNSPEC_PROLOGUE_USE)
+              (unspec_volatile [(return)] VUNSPEC_EPILOGUE)])]
   "TARGET_ARM"
   "*
   if (USE_RETURN_INSN (FALSE))
index 79e76c02697b43b6cb9d79326702a2f6cda1ae80..3f53ca43469551e801efb909dfd4233ca1ed58c0 100644 (file)
@@ -1,3 +1,8 @@
+2003-01-20  Nick Clifton  <nickc@redhat.com>
+
+       * gcc.c-torture/execute/20030117-1.c: New test case.  Exposes
+       problem with ARM sibcall code generation.
+
 2003-01-20  Kazu Hirata  <kazu@cs.umass.edu>
 
        * gcc.c-torture/execute/20030120-1.c: New.
diff --git a/gcc/testsuite/gcc.c-torture/execute/20030117-1.c b/gcc/testsuite/gcc.c-torture/execute/20030117-1.c
new file mode 100644 (file)
index 0000000..656bd61
--- /dev/null
@@ -0,0 +1,23 @@
+int foo (int, int, int);
+int bar (int, int, int);
+
+int main (void)
+{
+  if (foo (5, 10, 21) != 12)
+    abort ();
+
+  if (bar (9, 12, 15) != 150)
+    abort ();
+
+  exit (0);
+}
+
+int foo (int x, int y, int z)
+{
+  return (x + y + z) / 3;
+}
+
+int bar (int x, int y, int z)
+{
+  return foo (x * x, y * y, z * z);
+}