aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Malcomson <matthew.malcomson@arm.com>2019-12-09 12:03:53 +0000
committerMatthew Malcomson <matmal01@gcc.gnu.org>2019-12-09 12:03:53 +0000
commitfdc5359fb65458577a9d2a529d64cb0a54618cff (patch)
tree45f4b9b573dea8a33641596b57b98c5010b76000
parentad8b778345e01ff8ce252bf572965684a0826082 (diff)
downloadgcc-fdc5359fb65458577a9d2a529d64cb0a54618cff.zip
gcc-fdc5359fb65458577a9d2a529d64cb0a54618cff.tar.gz
gcc-fdc5359fb65458577a9d2a529d64cb0a54618cff.tar.bz2
[mid-end] Add notes to dataflow insn info when re-emitting (PR92410)
In scheduling passes, notes are removed with `remove_notes` before the scheduling is done, and added back in with `reemit_notes` once the scheduling has been decided. This process leaves the notes in the RTL chain with different insn uid's than were there before. Having different UID's (larger than the previous ones) means that DF_INSN_INFO_GET(insn) will access outside of the allocated array. This has been seen in the `regstat_bb_compute_calls_crossed` function. This patch adds an assert to the `regstat_bb_compute_calls_crossed` function so that bad accesses here are caught instead of going unnoticed, and then avoids the problem. We avoid the problem by ensuring that new notes added by `reemit_notes` have an insn record given to them. This is done by adding a call to `df_insn_create_insn_record` on each note added in `reemit_notes`. `df_insn_create_insn_record` leaves this new record zeroed out, which appears to be fine for notes (e.g. `df_bb_refs_record` already does not set anything except the luid for notes, and notes have no dataflow information to record). We add the testcase that Martin found here https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92410#c2 . This testcase fails with the "regstat.c" change, and then succeeds with the "haifa-sched.c" change. There is a similar problem with labels, that the `gcc_assert` catches when running regression tests in gcc.dg/fold-eqandshift-1.c and gcc.c-torture/compile/pr32482.c. This is due to the `cfg_layout_finalize` call in `bb-reorder.c` emitting new labels, and these labels not having a dataflow df_insn_info member. We solve this by manually calling `df_recompute_luids` on each basic block once this pass has finished. Testing done: Ran regression tests on aarch64-none-linux-gnu cross compiler. Bootstrapped and ran tests on aarch64-none-linux-gnu native. gcc/ChangeLog: 2019-12-09 Matthew Malcomson <matthew.malcomson@arm.com> PR middle-end/92410 * bb-reorder.c (pass_reorder_blocks::execute): Recompute dataflow luids once basic blocks have been reordered. * haifa-sched.c (reemit_notes): Create df insn record for each new note. * regstat.c (regstat_bb_compute_calls_crossed): Assert every insn has an insn record before trying to use it. gcc/testsuite/ChangeLog: 2019-12-09 Matthew Malcomson <matthew.malcomson@arm.com> PR middle-end/92410 * gcc.dg/torture/pr92410.c: New test. From-SVN: r279124
-rw-r--r--gcc/ChangeLog10
-rw-r--r--gcc/bb-reorder.c2
-rw-r--r--gcc/haifa-sched.c1
-rw-r--r--gcc/regstat.c1
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr92410.c8
6 files changed, 27 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 58ffe76..43e838c 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,13 @@
+2019-12-09 Matthew Malcomson <matthew.malcomson@arm.com>
+
+ PR middle-end/92410
+ * bb-reorder.c (pass_reorder_blocks::execute): Recompute
+ dataflow luids once basic blocks have been reordered.
+ * haifa-sched.c (reemit_notes): Create df insn record for each
+ new note.
+ * regstat.c (regstat_bb_compute_calls_crossed): Assert every
+ insn has an insn record before trying to use it.
+
2019-12-09 Hongtao Liu <hongtao.liu@intel.com>
* gcc/common/config/i386/i386-common.c
diff --git a/gcc/bb-reorder.c b/gcc/bb-reorder.c
index d1a2f1e..1cdeac1 100644
--- a/gcc/bb-reorder.c
+++ b/gcc/bb-reorder.c
@@ -2662,6 +2662,8 @@ pass_reorder_blocks::execute (function *fun)
bb->aux = bb->next_bb;
cfg_layout_finalize ();
+ FOR_EACH_BB_FN (bb, fun)
+ df_recompute_luids (bb);
return 0;
}
diff --git a/gcc/haifa-sched.c b/gcc/haifa-sched.c
index 54fb034..d56c405 100644
--- a/gcc/haifa-sched.c
+++ b/gcc/haifa-sched.c
@@ -5432,6 +5432,7 @@ reemit_notes (rtx_insn *insn)
last = emit_note_before (note_type, last);
remove_note (insn, note);
+ df_insn_create_insn_record (last);
}
}
}
diff --git a/gcc/regstat.c b/gcc/regstat.c
index 4da9b7c..c6cefb11 100644
--- a/gcc/regstat.c
+++ b/gcc/regstat.c
@@ -324,6 +324,7 @@ regstat_bb_compute_calls_crossed (unsigned int bb_index, bitmap live)
FOR_BB_INSNS_REVERSE (bb, insn)
{
+ gcc_assert (INSN_UID (insn) < DF_INSN_SIZE ());
struct df_insn_info *insn_info = DF_INSN_INFO_GET (insn);
unsigned int regno;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 272a83e..8361b78 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2019-12-09 Matthew Malcomson <matthew.malcomson@arm.com>
+
+ PR middle-end/92410
+ * gcc.dg/torture/pr92410.c: New test.
+
2019-12-09 Sudakshina Das <sudi.das@arm.com>
* gcc.dg/vect/vect-shift-5.c: New test.
diff --git a/gcc/testsuite/gcc.dg/torture/pr92410.c b/gcc/testsuite/gcc.dg/torture/pr92410.c
new file mode 100644
index 0000000..628e329
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr92410.c
@@ -0,0 +1,8 @@
+/* PR middle-end/92410 */
+/* { dg-do compile } */
+int v;
+
+int a() {
+ ;
+ return v;
+}