aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-strlen.c
diff options
context:
space:
mode:
authorJeff Law <law@redhat.com>2019-08-27 17:03:45 -0600
committerJeff Law <law@gcc.gnu.org>2019-08-27 17:03:45 -0600
commit2d8ba44101028f4be534a20a0d2146695e1dc4fd (patch)
tree9ba699bb3eb8b0c9f8d88562019025d8452aea4c /gcc/tree-ssa-strlen.c
parent2bd86b95f76315f102c52a81453ef375c97e8f1b (diff)
downloadgcc-2d8ba44101028f4be534a20a0d2146695e1dc4fd.zip
gcc-2d8ba44101028f4be534a20a0d2146695e1dc4fd.tar.gz
gcc-2d8ba44101028f4be534a20a0d2146695e1dc4fd.tar.bz2
tree-ssa-strlen.c (printf_strlen_execute): Initialize the loop optimizer and SCEV before sizing ssa_ver_to_stridx.
* tree-ssa-strlen.c (printf_strlen_execute): Initialize the loop optimizer and SCEV before sizing ssa_ver_to_stridx. * gcc.c-torture/compile/20190827-1.c: New test. From-SVN: r274975
Diffstat (limited to 'gcc/tree-ssa-strlen.c')
-rw-r--r--gcc/tree-ssa-strlen.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/gcc/tree-ssa-strlen.c b/gcc/tree-ssa-strlen.c
index 5c5b838..d38352a 100644
--- a/gcc/tree-ssa-strlen.c
+++ b/gcc/tree-ssa-strlen.c
@@ -4850,13 +4850,6 @@ printf_strlen_execute (function *fun, bool warn_only)
{
strlen_optimize = !warn_only;
- gcc_assert (!strlen_to_stridx);
- if (warn_stringop_overflow || warn_stringop_truncation)
- strlen_to_stridx = new hash_map<tree, stridx_strlenloc> ();
-
- ssa_ver_to_stridx.safe_grow_cleared (num_ssa_names);
- max_stridx = 1;
-
calculate_dominance_info (CDI_DOMINATORS);
bool use_scev = optimize > 0 && flag_printf_return_value;
@@ -4866,6 +4859,15 @@ printf_strlen_execute (function *fun, bool warn_only)
scev_initialize ();
}
+ gcc_assert (!strlen_to_stridx);
+ if (warn_stringop_overflow || warn_stringop_truncation)
+ strlen_to_stridx = new hash_map<tree, stridx_strlenloc> ();
+
+ /* This has to happen after initializing the loop optimizer
+ and initializing SCEV as they create new SSA_NAMEs. */
+ ssa_ver_to_stridx.safe_grow_cleared (num_ssa_names);
+ max_stridx = 1;
+
/* String length optimization is implemented as a walk of the dominator
tree and a forward walk of statements within each block. */
strlen_dom_walker walker (CDI_DOMINATORS);