aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2018-02-06 21:32:45 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2018-02-06 21:32:45 +0100
commit486a2b66f0341c646b6df30e2bce6d7298305933 (patch)
tree7c46a2da971cf452cbf57be6d41d898d1bc21f57
parent86f697aaa6ac674da3d402c57a58bd2e99fb8cb1 (diff)
downloadgcc-486a2b66f0341c646b6df30e2bce6d7298305933.zip
gcc-486a2b66f0341c646b6df30e2bce6d7298305933.tar.gz
gcc-486a2b66f0341c646b6df30e2bce6d7298305933.tar.bz2
re PR target/84146 (ICE with -mcet in dwarf2out_var_location, involving sigsetjmp)
PR target/84146 * config/i386/i386.c (rest_of_insert_endbranch): Only skip NOTE_INSN_CALL_ARG_LOCATION after a call, not anything else, and skip it regardless of bb boundaries. Use CALL_P macro, don't test INSN_P (insn) together with CALL_P or JUMP_P check unnecessarily, formatting fix. * gcc.target/i386/pr84146.c: New test. From-SVN: r257431
-rw-r--r--gcc/ChangeLog9
-rw-r--r--gcc/config/i386/i386.c22
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.target/i386/pr84146.c14
4 files changed, 37 insertions, 13 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index c40d7e6..8edc8cc 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@
+2018-02-06 Jakub Jelinek <jakub@redhat.com>
+
+ PR target/84146
+ * config/i386/i386.c (rest_of_insert_endbranch): Only skip
+ NOTE_INSN_CALL_ARG_LOCATION after a call, not anything else,
+ and skip it regardless of bb boundaries. Use CALL_P macro,
+ don't test INSN_P (insn) together with CALL_P or JUMP_P check
+ unnecessarily, formatting fix.
+
2018-02-06 Michael Collison <michael.collison@arm.com>
* config/arm/thumb2.md:
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 6c612c7..faa9d94 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -2612,31 +2612,27 @@ rest_of_insert_endbranch (void)
for (insn = BB_HEAD (bb); insn != NEXT_INSN (BB_END (bb));
insn = NEXT_INSN (insn))
{
- if (INSN_P (insn) && GET_CODE (insn) == CALL_INSN)
+ if (CALL_P (insn))
{
if (find_reg_note (insn, REG_SETJMP, NULL) == NULL)
continue;
/* Generate ENDBRANCH after CALL, which can return more than
twice, setjmp-like functions. */
- /* Skip notes and debug insns that must be next to the
- call insn. ??? This might skip a lot more than
- that... ??? Skipping barriers and emitting code
- after them surely looks like a mistake; we probably
- won't ever hit it, for we'll hit BB_END first. */
+ /* Skip notes that must immediately follow the call insn. */
rtx_insn *next_insn = insn;
- while ((next_insn != BB_END (bb))
- && (DEBUG_INSN_P (NEXT_INSN (next_insn))
- || NOTE_P (NEXT_INSN (next_insn))
- || BARRIER_P (NEXT_INSN (next_insn))))
- next_insn = NEXT_INSN (next_insn);
+ if (NEXT_INSN (insn)
+ && NOTE_P (NEXT_INSN (insn))
+ && (NOTE_KIND (NEXT_INSN (insn))
+ == NOTE_INSN_CALL_ARG_LOCATION))
+ next_insn = NEXT_INSN (insn);
cet_eb = gen_nop_endbr ();
emit_insn_after_setloc (cet_eb, next_insn, INSN_LOCATION (insn));
continue;
}
- if (INSN_P (insn) && JUMP_P (insn) && flag_cet_switch)
+ if (JUMP_P (insn) && flag_cet_switch)
{
rtx target = JUMP_LABEL (insn);
if (target == NULL_RTX || ANY_RETURN_P (target))
@@ -2671,7 +2667,7 @@ rest_of_insert_endbranch (void)
if ((LABEL_P (insn) && LABEL_PRESERVE_P (insn))
|| (NOTE_P (insn)
&& NOTE_KIND (insn) == NOTE_INSN_DELETED_LABEL))
-/* TODO. Check /s bit also. */
+ /* TODO. Check /s bit also. */
{
cet_eb = gen_nop_endbr ();
emit_insn_after (cet_eb, insn);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 14bcd62..4134471 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2018-02-06 Jakub Jelinek <jakub@redhat.com>
+
+ PR target/84146
+ * gcc.target/i386/pr84146.c: New test.
+
2018-02-06 Michael Collison <michael.collison@arm.com>
* gcc.target/arm/pr7676.c: New testcase for incorrect splitting.
diff --git a/gcc/testsuite/gcc.target/i386/pr84146.c b/gcc/testsuite/gcc.target/i386/pr84146.c
new file mode 100644
index 0000000..ba9b633
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr84146.c
@@ -0,0 +1,14 @@
+/* PR target/84146 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -g -mcet -fcf-protection=full" } */
+
+int __setjmp (void **);
+void *buf[64];
+
+void
+foo (void)
+{
+ __setjmp (buf);
+ for (;;)
+ ;
+}