]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR target/38056 (Missed tail calls on ia64)
authorSteve Ellcey <sje@cup.hp.com>
Fri, 20 Feb 2009 17:18:20 +0000 (17:18 +0000)
committerSteve Ellcey <sje@gcc.gnu.org>
Fri, 20 Feb 2009 17:18:20 +0000 (17:18 +0000)
PR target/38056
* config/ia64/ia64.c (ia64_function_ok_for_sibcall): Check
TARGET_CONST_GP.
* gcc.target/ia64/sibcall-opt-1.c: New test.
* gcc.target/ia64/sibcall-opt-2.c: New test.

From-SVN: r144329

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

index eac440672e9ac49b81873a547eca23dd66cbff91..2f995930002b9ed99c1b2cceef4408de22472f89 100644 (file)
@@ -1,3 +1,9 @@
+2009-02-20  Steve Ellcey  <sje@cup.hp.com>
+
+       PR target/38056
+       * config/ia64/ia64.c (ia64_function_ok_for_sibcall): Check
+       TARGET_CONST_GP.
+
 2009-02-19  Uros Bizjak  <ubizjak@gmail.com>
 
        PR target/39228
index 0e3307a046c677f0b3664a360c1bece689d15669..4fad4bcaf398d760cc25db9909cc8b29f6dfdd70 100644 (file)
@@ -4328,8 +4328,9 @@ ia64_function_ok_for_sibcall (tree decl, tree exp ATTRIBUTE_UNUSED)
     return false;
 
   /* We must always return with our current GP.  This means we can
-     only sibcall to functions defined in the current module.  */
-  return decl && (*targetm.binds_local_p) (decl);
+     only sibcall to functions defined in the current module unless
+     TARGET_CONST_GP is set to true.  */
+  return (decl && (*targetm.binds_local_p) (decl)) || TARGET_CONST_GP;
 }
 \f
 
index d3d01859086da8e15248eb4f77c558b4c88802b7..d96f953bc0f0bee0a0967f1215ac10b606f1cb50 100644 (file)
@@ -1,3 +1,9 @@
+2009-02-20  Steve Ellcey  <sje@cup.hp.com>
+
+       PR target/38056
+       * gcc.target/ia64/sibcall-opt-1.c: New test.
+       * gcc.target/ia64/sibcall-opt-2.c: New test.
+
 2009-02-20  Jason Merrill  <jason@redhat.com>
 
        PR c++/39225
diff --git a/gcc/testsuite/gcc.target/ia64/sibcall-opt-1.c b/gcc/testsuite/gcc.target/ia64/sibcall-opt-1.c
new file mode 100644 (file)
index 0000000..6e8d1a2
--- /dev/null
@@ -0,0 +1,12 @@
+/* PR target/38056.  Do not do sibcall optimization across object file
+   boundery when -mconstant-gp is not used.  */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+/* { dg-final { scan-assembler "br.call.*bar" } } */
+
+int bar(int x);
+
+int foo(int x)
+{
+  return (bar(x + 1));
+}
diff --git a/gcc/testsuite/gcc.target/ia64/sibcall-opt-2.c b/gcc/testsuite/gcc.target/ia64/sibcall-opt-2.c
new file mode 100644 (file)
index 0000000..d802b79
--- /dev/null
@@ -0,0 +1,12 @@
+/* PR target/38056.  Do sibcall optimization across object file
+   boundery when -mconstant-gp is used.  */
+/* { dg-do compile } */
+/* { dg-options "-O2 -mconstant-gp" } */
+/* { dg-final { scan-assembler-not "br.call.*bar" } } */
+
+int bar(int x);
+
+int foo(int x)
+{
+  return (bar(x + 1));
+}