diff options
author | David Malcolm <dmalcolm@redhat.com> | 2019-02-07 23:00:18 +0000 |
---|---|---|
committer | David Malcolm <dmalcolm@gcc.gnu.org> | 2019-02-07 23:00:18 +0000 |
commit | 25b67546a1a5fd49ddcb0a923a8d23d77a91e05f (patch) | |
tree | 9669c8a1154a56f24f9d2079c0759f4b6424e0ef /gcc/tree-vectorizer.c | |
parent | 8544ed6eea68a80999504c8a4b21b77d29cd86e2 (diff) | |
download | gcc-25b67546a1a5fd49ddcb0a923a8d23d77a91e05f.zip gcc-25b67546a1a5fd49ddcb0a923a8d23d77a91e05f.tar.gz gcc-25b67546a1a5fd49ddcb0a923a8d23d77a91e05f.tar.bz2 |
Fix more ICEs in -fsave-optimization-record (PR tree-optimization/89235)
PR tree-optimization/89235 reports an ICE inside -fsave-optimization-record
whilst reporting the inlining chain of of the location_t in the
vect_location global.
This is very similar to PR tree-optimization/86637, fixed in r266821.
The issue is that the inlining chains are read from the location_t's
ad-hoc data, referencing GC-managed tree blocks, but the former are
not GC roots; it's simply assumed that old locations referencing dead
blocks never get used again.
The fix is to reset the "vect_location" global in more places. Given
that is a somewhat subtle detail, the patch adds a sentinel class to
reset vect_location at the end of a scope. Doing it as a class
simplifies the task of ensuring that the global is reset on every
exit path from a function, and also gives a good place to signpost
the above subtlety (in the documentation for the class).
The patch also adds test cases for both of the PRs mentioned above.
gcc/testsuite/ChangeLog:
PR tree-optimization/86637
PR tree-optimization/89235
* gcc.c-torture/compile/pr86637-1.c: New test.
* gcc.c-torture/compile/pr86637-2.c: New test.
* gcc.c-torture/compile/pr86637-3.c: New test.
* gcc.c-torture/compile/pr89235.c: New test.
gcc/ChangeLog:
PR tree-optimization/86637
PR tree-optimization/89235
* tree-vect-loop.c (optimize_mask_stores): Add an
auto_purge_vect_location sentinel to ensure that vect_location is
purged on exit.
* tree-vectorizer.c
(auto_purge_vect_location::~auto_purge_vect_location): New dtor.
(try_vectorize_loop_1): Add an auto_purge_vect_location sentinel
to ensure that vect_location is purged on exit.
(pass_slp_vectorize::execute): Likewise, replacing the manual
reset.
* tree-vectorizer.h (class auto_purge_vect_location): New class.
From-SVN: r268659
Diffstat (limited to 'gcc/tree-vectorizer.c')
-rw-r--r-- | gcc/tree-vectorizer.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/gcc/tree-vectorizer.c b/gcc/tree-vectorizer.c index fa5b22e..d271049 100644 --- a/gcc/tree-vectorizer.c +++ b/gcc/tree-vectorizer.c @@ -86,6 +86,15 @@ along with GCC; see the file COPYING3. If not see /* Loop or bb location, with hotness information. */ dump_user_location_t vect_location; +/* auto_purge_vect_location's dtor: reset the vect_location + global, to avoid stale location_t values that could reference + GC-ed blocks. */ + +auto_purge_vect_location::~auto_purge_vect_location () +{ + vect_location = dump_user_location_t (); +} + /* Dump a cost entry according to args to F. */ void @@ -860,6 +869,7 @@ try_vectorize_loop_1 (hash_table<simduid_to_vf> *&simduid_to_vf_htab, { unsigned ret = 0; vec_info_shared shared; + auto_purge_vect_location sentinel; vect_location = find_loop_location (loop); if (LOCATION_LOCUS (vect_location.get_location_t ()) != UNKNOWN_LOCATION && dump_enabled_p ()) @@ -1269,6 +1279,7 @@ public: unsigned int pass_slp_vectorize::execute (function *fun) { + auto_purge_vect_location sentinel; basic_block bb; bool in_loop_pipeline = scev_initialized_p (); @@ -1303,8 +1314,6 @@ pass_slp_vectorize::execute (function *fun) loop_optimizer_finalize (); } - vect_location = dump_user_location_t (); - return 0; } |