diff options
author | Richard Biener <rguenther@suse.de> | 2022-02-04 09:46:43 +0100 |
---|---|---|
committer | Richard Biener <rguenther@suse.de> | 2022-02-10 10:56:14 +0100 |
commit | 0f58ba4dd6b25b16d25494ae18d15dfa681f9b65 (patch) | |
tree | 72fb407291d3a50d206b43c977c237a49a41e642 /gcc/tree-ssa-sccvn.cc | |
parent | 4a8083285c3edf50088a095870b217ab0881dff0 (diff) | |
download | gcc-0f58ba4dd6b25b16d25494ae18d15dfa681f9b65.zip gcc-0f58ba4dd6b25b16d25494ae18d15dfa681f9b65.tar.gz gcc-0f58ba4dd6b25b16d25494ae18d15dfa681f9b65.tar.bz2 |
tree-optimization/104373 - early diagnostic on unreachable code
The following improves early uninit diagnostics by computing edge
reachability using VN and ignoring unreachable blocks when looking
for uninitialized uses. To not ICE with -fdump-tree-all the
early uninit pass needs a dumpfile since VN tries to dump statistics.
2022-02-04 Richard Biener <rguenther@suse.de>
PR tree-optimization/104373
* tree-ssa-sccvn.h (do_rpo_vn): New export exposing the
walk kind.
* tree-ssa-sccvn.cc (do_rpo_vn): Export, get the default
walk kind as argument.
(run_rpo_vn): Adjust.
(pass_fre::execute): Likewise.
* tree-ssa-uninit.cc (warn_uninitialized_vars): Skip
blocks not reachable.
(execute_late_warn_uninitialized): Mark all edges as
executable.
(execute_early_warn_uninitialized): Use VN to compute
executable edges.
(pass_data_early_warn_uninitialized): Enable a dump file,
change dump name to warn_uninit.
* g++.dg/warn/Wuninitialized-32.C: New testcase.
* gcc.dg/uninit-pr20644-O0.c: Remove XFAIL.
Diffstat (limited to 'gcc/tree-ssa-sccvn.cc')
-rw-r--r-- | gcc/tree-ssa-sccvn.cc | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/gcc/tree-ssa-sccvn.cc b/gcc/tree-ssa-sccvn.cc index a03f0aa..eb17549 100644 --- a/gcc/tree-ssa-sccvn.cc +++ b/gcc/tree-ssa-sccvn.cc @@ -7034,15 +7034,14 @@ eliminate_with_rpo_vn (bitmap inserted_exprs) return walker.eliminate_cleanup (); } -static unsigned +unsigned do_rpo_vn (function *fn, edge entry, bitmap exit_bbs, - bool iterate, bool eliminate); + bool iterate, bool eliminate, vn_lookup_kind kind); void run_rpo_vn (vn_lookup_kind kind) { - default_vn_walk_kind = kind; - do_rpo_vn (cfun, NULL, NULL, true, false); + do_rpo_vn (cfun, NULL, NULL, true, false, kind); /* ??? Prune requirement of these. */ constant_to_value_id = new hash_table<vn_constant_hasher> (23); @@ -7740,11 +7739,12 @@ do_unwind (unwind_state *to, rpo_elim &avail) executed and iterate. If ELIMINATE is true then perform elimination, otherwise leave that to the caller. */ -static unsigned +unsigned do_rpo_vn (function *fn, edge entry, bitmap exit_bbs, - bool iterate, bool eliminate) + bool iterate, bool eliminate, vn_lookup_kind kind) { unsigned todo = 0; + default_vn_walk_kind = kind; /* We currently do not support region-based iteration when elimination is requested. */ @@ -8164,8 +8164,7 @@ do_rpo_vn (function *fn, edge entry, bitmap exit_bbs, unsigned do_rpo_vn (function *fn, edge entry, bitmap exit_bbs) { - default_vn_walk_kind = VN_WALKREWRITE; - unsigned todo = do_rpo_vn (fn, entry, exit_bbs, false, true); + unsigned todo = do_rpo_vn (fn, entry, exit_bbs, false, true, VN_WALKREWRITE); free_rpo_vn (); return todo; } @@ -8221,8 +8220,7 @@ pass_fre::execute (function *fun) if (iterate_p) loop_optimizer_init (AVOID_CFG_MODIFICATIONS); - default_vn_walk_kind = VN_WALKREWRITE; - todo = do_rpo_vn (fun, NULL, NULL, iterate_p, true); + todo = do_rpo_vn (fun, NULL, NULL, iterate_p, true, VN_WALKREWRITE); free_rpo_vn (); if (iterate_p) |