]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
rs6000.c (rs6000_function_ok_for_sibcall): Return false if the call takes a static...
authorEric Botcazou <ebotcazou@adacore.com>
Fri, 21 Sep 2018 10:06:25 +0000 (10:06 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Fri, 21 Sep 2018 10:06:25 +0000 (10:06 +0000)
* config/rs6000/rs6000.c (rs6000_function_ok_for_sibcall): Return false
if the call takes a static chain.

From-SVN: r264465

gcc/ChangeLog
gcc/config/rs6000/rs6000.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/nested-func-11.c [new file with mode: 0644]

index a076b8816189695b5be8bdcfc67d90935866e055..471a203d29585bdae58776785ed6c8c46a71f802 100644 (file)
@@ -1,3 +1,8 @@
+2018-09-21  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * config/rs6000/rs6000.c (rs6000_function_ok_for_sibcall): Return false
+       if the call takes a static chain.
+
 2018-09-19  John David Anglin  <danglin@gcc.gnu.org>
 
        * config/pa/pa.md (atomic_storeqi): Restore deleted expander.
index 365f006af6266239f27d1b0db188efcb877a98ce..d377e24291350b54490e8f5d20e92eb5f149bba3 100644 (file)
@@ -27793,6 +27793,12 @@ rs6000_function_ok_for_sibcall (tree decl, tree exp)
 {
   tree fntype;
 
+  /* The sibcall epilogue may clobber the static chain register.
+     ??? We could work harder and avoid that, but it's probably
+     not worth the hassle in practice.  */
+  if (CALL_EXPR_STATIC_CHAIN (exp))
+    return false;
+
   if (decl)
     fntype = TREE_TYPE (decl);
   else
index 60ce73f3a3dce2ec643eaa3279eebdd0c2f5c73a..55bf1c25c9c8b9d8cb46295996f0e1908980c81f 100644 (file)
@@ -1,3 +1,7 @@
+2018-09-21  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gcc.dg/nested-func-11.c: New test.
+
 2018-09-13  Paul Thomas  <pault@gcc.gnu.org>
 
        Backported from trunk
diff --git a/gcc/testsuite/gcc.dg/nested-func-11.c b/gcc/testsuite/gcc.dg/nested-func-11.c
new file mode 100644 (file)
index 0000000..01096b4
--- /dev/null
@@ -0,0 +1,34 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -fno-omit-frame-pointer" } */
+
+int __attribute__((noipa)) foo (int i)
+{
+  int a;
+
+  void __attribute__((noipa)) nested2 (int i)
+  {
+    a = i;
+  }
+
+  void  __attribute__((noipa)) nested1 (int i)
+  {
+    int b[32];
+
+    for (int j = 0; j < 32; j++)
+      b[j] = i + j;
+
+    nested2 (b[i]);
+  }
+
+  nested1 (i);
+
+  return a;
+}
+
+int main (void)
+{
+  if (foo (4) != 8)
+    __builtin_abort ();
+
+  return 0;
+}