]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[ARM] PR68390 Incorrect code due to indirect tail call of varargs function with hard...
authorChristophe Lyon <christophe.lyon@linaro.org>
Fri, 21 Apr 2017 09:23:59 +0000 (09:23 +0000)
committerChristophe Lyon <clyon@gcc.gnu.org>
Fri, 21 Apr 2017 09:23:59 +0000 (11:23 +0200)
2017-04-21  Christophe Lyon  <christophe.lyon@linaro.org>

Backport from mainline
+2015-11-23  Kugan Vivekanandarajah  <kuganv@linaro.org>

PR target/68390
gcc/
* config/arm/arm.c (arm_function_ok_for_sibcall): Get function type
for indirect function call.

gcc/testsuite/
* gcc.c-torture/execute/pr68390.c: New test.

From-SVN: r247057

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

index d05b488db21e54ed6c8d507b2b96881806e17893..b592996003ce4b331930e879d6f87de1b4736cb5 100644 (file)
@@ -1,3 +1,12 @@
+2017-04-21  Christophe Lyon  <christophe.lyon@linaro.org>
+
+       Backport from mainline
+       +2015-11-23  Kugan Vivekanandarajah  <kuganv@linaro.org>
+
+       PR target/68390
+       * config/arm/arm.c (arm_function_ok_for_sibcall): Get function type
+       for indirect function call.
+
 2017-04-12  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
        Backport from mainline
index c8aab8e09f83efd084a9d21e0d2fd04c04120877..67bab17a9d77a54b69394505e55d67d4ab4416d5 100644 (file)
@@ -6507,8 +6507,13 @@ arm_function_ok_for_sibcall (tree decl, tree exp)
         a VFP register but then need to transfer it to a core
         register.  */
       rtx a, b;
+      tree decl_or_type = decl;
 
-      a = arm_function_value (TREE_TYPE (exp), decl, false);
+      /* If it is an indirect function pointer, get the function type.  */
+      if (!decl)
+       decl_or_type = TREE_TYPE (TREE_TYPE (CALL_EXPR_FN (exp)));
+
+      a = arm_function_value (TREE_TYPE (exp), decl_or_type, false);
       b = arm_function_value (TREE_TYPE (DECL_RESULT (cfun->decl)),
                              cfun->decl, false);
       if (!rtx_equal_p (a, b))
index 1493a615d01b95d2a1de870216adca81caa400c1..df0134eb983ebd5ac11931df0a917e10bed653fe 100644 (file)
@@ -1,3 +1,11 @@
+2017-04-21  Christophe Lyon  <christophe.lyon@linaro.org>
+
+       Backport from mainline
+       2015-11-23  Kugan Vivekanandarajah  <kuganv@linaro.org>
+
+       PR target/68390
+       * gcc.c-torture/execute/pr68390.c: New test.
+
 2017-04-14  Dominique d'Humieres  <dominiq@lps.ens.fr>
 
        Backport from trunk
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr68390.c b/gcc/testsuite/gcc.c-torture/execute/pr68390.c
new file mode 100644 (file)
index 0000000..86f07fe
--- /dev/null
@@ -0,0 +1,27 @@
+/* { dg-do run }  */
+/* { dg-options "-O2" } */
+
+__attribute__ ((noinline))
+double direct(int x, ...)
+{
+  return x*x;
+}
+
+__attribute__ ((noinline))
+double broken(double (*indirect)(int x, ...), int v)
+{
+  return indirect(v);
+}
+
+int main ()
+{
+  double d1, d2;
+  int i = 2;
+  d1 = broken (direct, i);
+  if (d1 != i*i)
+    {
+      __builtin_abort ();
+    }
+  return 0;
+}
+