aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Monakov <amonakov@ispras.ru>2015-05-14 20:43:28 +0300
committerAlexander Monakov <amonakov@gcc.gnu.org>2015-05-14 20:43:28 +0300
commitf226d22967576772030669a06d5bea73a5802d2f (patch)
treeb0c12b8e68653fc976b3e4811c08b59a36b232d9
parentaea417d748969d87d4973a34e055f40ce4a1d739 (diff)
downloadgcc-f226d22967576772030669a06d5bea73a5802d2f.zip
gcc-f226d22967576772030669a06d5bea73a5802d2f.tar.gz
gcc-f226d22967576772030669a06d5bea73a5802d2f.tar.bz2
i386.md (sibcall_memory): Check that register with callee address is not also used as one of the arguments...
* config/i386/i386.md (sibcall_memory): Check that register with callee address is not also used as one of the arguments, instead of checking that it is not live after the sibcall. (sibcall_pop_memory): Ditto. (sibcall_value_memory): Ditto. (sibcall_value_pop_memory): Ditto. testsuite: * gcc.target/i386/sibcall-7.c: New test. * gcc.target/i386/sibcall-8.c: New test. From-SVN: r223201
-rw-r--r--gcc/ChangeLog9
-rw-r--r--gcc/config/i386/i386.md24
-rw-r--r--gcc/testsuite/ChangeLog7
-rw-r--r--gcc/testsuite/gcc.target/i386/sibcall-7.c10
-rw-r--r--gcc/testsuite/gcc.target/i386/sibcall-8.c24
5 files changed, 65 insertions, 9 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index f41771e..97aa0eb 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@
+2015-05-14 Alexander Monakov <amonakov@ispras.ru>
+
+ * config/i386/i386.md (sibcall_memory): Check that register with
+ callee address is not also used as one of the arguments, instead
+ of checking that it is not live after the sibcall.
+ (sibcall_pop_memory): Ditto.
+ (sibcall_value_memory): Ditto.
+ (sibcall_value_pop_memory): Ditto.
+
2015-05-14 Marc Glisse <marc.glisse@inria.fr>
* generic-match-head.c (types_match): Handle non-types.
diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
index 7bec509..aefca43 100644
--- a/gcc/config/i386/i386.md
+++ b/gcc/config/i386/i386.md
@@ -11680,7 +11680,8 @@
(call (mem:QI (match_dup 0))
(match_operand 3))]
"!TARGET_X32 && SIBLING_CALL_P (peep2_next_insn (1))
- && peep2_reg_dead_p (2, operands[0])"
+ && !reg_mentioned_p (operands[0],
+ CALL_INSN_FUNCTION_USAGE (peep2_next_insn (1)))"
[(parallel [(call (mem:QI (match_dup 1))
(match_dup 3))
(unspec [(const_int 0)] UNSPEC_PEEPSIB)])])
@@ -11692,7 +11693,8 @@
(call (mem:QI (match_dup 0))
(match_operand 3))]
"!TARGET_X32 && SIBLING_CALL_P (peep2_next_insn (2))
- && peep2_reg_dead_p (3, operands[0])"
+ && !reg_mentioned_p (operands[0],
+ CALL_INSN_FUNCTION_USAGE (peep2_next_insn (2)))"
[(unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE)
(parallel [(call (mem:QI (match_dup 1))
(match_dup 3))
@@ -11751,7 +11753,8 @@
(plus:SI (reg:SI SP_REG)
(match_operand:SI 4 "immediate_operand")))])]
"!TARGET_64BIT && SIBLING_CALL_P (peep2_next_insn (1))
- && peep2_reg_dead_p (2, operands[0])"
+ && !reg_mentioned_p (operands[0],
+ CALL_INSN_FUNCTION_USAGE (peep2_next_insn (1)))"
[(parallel [(call (mem:QI (match_dup 1))
(match_dup 3))
(set (reg:SI SP_REG)
@@ -11769,7 +11772,8 @@
(plus:SI (reg:SI SP_REG)
(match_operand:SI 4 "immediate_operand")))])]
"!TARGET_64BIT && SIBLING_CALL_P (peep2_next_insn (2))
- && peep2_reg_dead_p (3, operands[0])"
+ && !reg_mentioned_p (operands[0],
+ CALL_INSN_FUNCTION_USAGE (peep2_next_insn (2)))"
[(unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE)
(parallel [(call (mem:QI (match_dup 1))
(match_dup 3))
@@ -11845,7 +11849,8 @@
(call (mem:QI (match_dup 0))
(match_operand 3)))]
"!TARGET_X32 && SIBLING_CALL_P (peep2_next_insn (1))
- && peep2_reg_dead_p (2, operands[0])"
+ && !reg_mentioned_p (operands[0],
+ CALL_INSN_FUNCTION_USAGE (peep2_next_insn (1)))"
[(parallel [(set (match_dup 2)
(call (mem:QI (match_dup 1))
(match_dup 3)))
@@ -11859,7 +11864,8 @@
(call (mem:QI (match_dup 0))
(match_operand 3)))]
"!TARGET_X32 && SIBLING_CALL_P (peep2_next_insn (2))
- && peep2_reg_dead_p (3, operands[0])"
+ && !reg_mentioned_p (operands[0],
+ CALL_INSN_FUNCTION_USAGE (peep2_next_insn (2)))"
[(unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE)
(parallel [(set (match_dup 2)
(call (mem:QI (match_dup 1))
@@ -11924,7 +11930,8 @@
(plus:SI (reg:SI SP_REG)
(match_operand:SI 4 "immediate_operand")))])]
"!TARGET_64BIT && SIBLING_CALL_P (peep2_next_insn (1))
- && peep2_reg_dead_p (2, operands[0])"
+ && !reg_mentioned_p (operands[0],
+ CALL_INSN_FUNCTION_USAGE (peep2_next_insn (1)))"
[(parallel [(set (match_dup 2)
(call (mem:QI (match_dup 1))
(match_dup 3)))
@@ -11944,7 +11951,8 @@
(plus:SI (reg:SI SP_REG)
(match_operand:SI 4 "immediate_operand")))])]
"!TARGET_64BIT && SIBLING_CALL_P (peep2_next_insn (2))
- && peep2_reg_dead_p (3, operands[0])"
+ && !reg_mentioned_p (operands[0],
+ CALL_INSN_FUNCTION_USAGE (peep2_next_insn (2)))"
[(unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE)
(parallel [(set (match_dup 2)
(call (mem:QI (match_dup 1))
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 504dc07..2d48683 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2015-05-14 Alexander Monakov <amonakov@ispras.ru>
+
+ * gcc.target/i386/sibcall-7.c: New test.
+ * gcc.target/i386/sibcall-8.c: New test.
+
2015-05-14 Wilco Dijkstra <wdijkstr@arm.com>
* gcc.target/aarch64/abs_1.c (abs64): Update test for new abs expansion.
@@ -97,7 +102,7 @@
PR tree-optimization/37021
* gcc.target/i386/vect-addsub.c: New testcase.
-2015-05-11 Alexander Monakov <amonakov@ispras.ru>
+2015-05-12 Alexander Monakov <amonakov@ispras.ru>
* gcc.target/i386/pr65753.c: Use -O2 instead of -O.
diff --git a/gcc/testsuite/gcc.target/i386/sibcall-7.c b/gcc/testsuite/gcc.target/i386/sibcall-7.c
new file mode 100644
index 0000000..6effb8f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/sibcall-7.c
@@ -0,0 +1,10 @@
+/* { dg-do compile { target { ! x32 } } } */
+/* { dg-options "-O2" } */
+/* { dg-final { scan-assembler-not "mov" } } */
+
+int foo()
+{
+ int (**bar)(void);
+ asm("":"=a"(bar));
+ return (*bar)();
+}
diff --git a/gcc/testsuite/gcc.target/i386/sibcall-8.c b/gcc/testsuite/gcc.target/i386/sibcall-8.c
new file mode 100644
index 0000000..3ab3809
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/sibcall-8.c
@@ -0,0 +1,24 @@
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+extern void abort (void);
+
+static int __attribute__((regparm(1)))
+bar(void *arg)
+{
+ return arg != bar;
+}
+
+static int __attribute__((noinline,noclone,regparm(1)))
+foo(int (__attribute__((regparm(1))) **bar)(void*))
+{
+ return (*bar)(*bar);
+}
+
+int main()
+{
+ int (__attribute__((regparm(1))) *p)(void*) = bar;
+ if (foo(&p))
+ abort();
+ return 0;
+}