aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYvan Roux <yvan.roux@linaro.org>2015-12-28 09:40:20 +0100
committerLinaro Code Review <review@review.linaro.org>2015-12-30 12:09:14 +0000
commit0a0679afd918911c9021b126e67c5d5e939a5db2 (patch)
tree61c6b7ceadc5dde68334fd5b1b0df112e440e590
parent55e7ff54a1ed7d22e1fd815f3ac5c8aca687564a (diff)
gcc/
Backport from trunk r230730. 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. gcc/testsuite/ Backport from trunk r230730. 2015-11-23 Kugan Vivekanandarajah <kuganv@linaro.org> PR target/68390 * gcc/testsuite/gcc.c-torture/execute/pr68390.c: New test. Change-Id: I83be78dbafa3dbd8b693ce9768d62bbeb9ff452c
-rw-r--r--gcc/config/arm/arm.c7
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/pr68390.c27
2 files changed, 33 insertions, 1 deletions
diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index 04bd1f5179d..9b848bd5ed6 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -6695,8 +6695,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))
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr68390.c b/gcc/testsuite/gcc.c-torture/execute/pr68390.c
new file mode 100644
index 00000000000..86f07fefd4f
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/pr68390.c
@@ -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;
+}
+