diff options
author | Martin Sebor <msebor@redhat.com> | 2019-07-12 17:36:45 +0000 |
---|---|---|
committer | Martin Sebor <msebor@gcc.gnu.org> | 2019-07-12 11:36:45 -0600 |
commit | 5dd47cb75dac4583dc38e9c1df2fde89fd459a08 (patch) | |
tree | 0d8febea6e49248e6ea92f630e251dcc93b88c9a | |
parent | d132c59b10ac8ee35d2e48c0b598160d5bdabf46 (diff) | |
download | gcc-5dd47cb75dac4583dc38e9c1df2fde89fd459a08.zip gcc-5dd47cb75dac4583dc38e9c1df2fde89fd459a08.tar.gz gcc-5dd47cb75dac4583dc38e9c1df2fde89fd459a08.tar.bz2 |
invoke.texi (ssa-name-def-chain-limit): Document new --param.
gcc/ChangeLog:
* doc/invoke.texi (ssa-name-def-chain-limit): Document new --param.
* params.def (PARAM_SSA_NAME_DEF_CHAIN_LIMIT): Add new --param.
* tree-vrp.c (vrp_prop::check_mem_ref): Use
PARAM_SSA_NAME_DEF_CHAIN_LIMIT.
gcc/testsuite/ChangeLog:
* gcc.dg/Warray-bounds-43.c: New test.
From-SVN: r273454
-rw-r--r-- | gcc/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/doc/invoke.texi | 7 | ||||
-rw-r--r-- | gcc/params.def | 6 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/Warray-bounds-43.c | 133 | ||||
-rw-r--r-- | gcc/tree-vrp.c | 3 |
6 files changed, 159 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 37b5eaf..685c779 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2019-07-12 Martin Sebor <msebor@redhat.com> + + * doc/invoke.texi (ssa-name-def-chain-limit): Document new --param. + * params.def (PARAM_SSA_NAME_DEF_CHAIN_LIMIT): Add new --param. + * tree-vrp.c (vrp_prop::check_mem_ref): Use + PARAM_SSA_NAME_DEF_CHAIN_LIMIT. + 2019-07-12 Jan Hubicka <jh@suse.cz> * tree-ssa-alias.c (same_tmr_indexing_p): Break out from ... @@ -28,7 +35,6 @@ rather than this_state as the lowering context for the ELSE seq in a GIMPLE_EH_ELSE. ->>>>>>> .r273450 2019-07-12 Richard Sandiford <richard.sandiford@arm.com> * vector-builder.h (vector_builder::elt): Allow already-supplied diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 0c20cb6..b4e71f2c 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -12225,6 +12225,13 @@ before the loop versioning pass considers it too big to copy, discounting any instructions in inner loops that directly benefit from versioning. +@item ssa-name-def-chain-limit +The maximum number of SSA_NAME assignments to follow in determining +a property of a variable such as its value. This limits the number +of iterations or recursive calls GCC performs when optimizing certain +statements or when determining their validity prior to issuing +diagnostics. + @end table @end table diff --git a/gcc/params.def b/gcc/params.def index 4567c17..c56055d 100644 --- a/gcc/params.def +++ b/gcc/params.def @@ -1437,6 +1437,12 @@ DEFPARAM(PARAM_HASH_TABLE_VERIFICATION_LIMIT, "each searched element.", 10, 0, 0) +DEFPARAM(PARAM_SSA_NAME_DEF_CHAIN_LIMIT, + "ssa-name-def-chain-limit", + "The maximum number of SSA_NAME assignments to follow in determining " + "a value.", + 512, 0, 0) + /* Local variables: diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4d6eb0f..73fe739 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2019-07-12 Martin Sebor <msebor@redhat.com> + + * gcc.dg/Warray-bounds-43.c: New test. + 2019-07-12 Jan Hubicka <jh@suse.cz> * gcc.dg/tree-ssa/alias-access-path-9.c: New testcase. diff --git a/gcc/testsuite/gcc.dg/Warray-bounds-43.c b/gcc/testsuite/gcc.dg/Warray-bounds-43.c new file mode 100644 index 0000000..8892921 --- /dev/null +++ b/gcc/testsuite/gcc.dg/Warray-bounds-43.c @@ -0,0 +1,133 @@ +/* Test to verify that --param ssa_name_def_chain_limit can be used to + limit the maximum number of SSA_NAME assignments the warning follows. + { dg-do compile } + { dg-options "-O2 -Wall --param ssa-name-def-chain-limit=4" } */ + +#define NOIPA __attribute__ ((noipa)) + +const char a0[] = ""; +const char a1[] = "1"; +const char a2[] = "12"; +const char a3[] = "123"; +const char a4[] = "1234"; +const char a5[] = "12345"; +const char a6[] = "123456"; +const char a7[] = "1234567"; +const char a8[] = "12345678"; +const char a9[] = "123456789"; + +void f (const char*, ...); + +int i0, i1, i2, i3, i4, i5, i6, i7, i8; + +NOIPA int g2 (int i) +{ + if (i < 1) i = 1; + + const char *p0 = a9; + const char *p1 = p0 + i; + const char *p2 = p1 + i; + + f (p0, p1, p2); + + return p2[8]; // { dg-warning "\\\[-Warray-bounds]" } +} + +NOIPA int g3 (int i) +{ + if (i < 1) i = 1; + + const char *p0 = a9; + const char *p1 = p0 + i; + const char *p2 = p1 + i; + const char *p3 = p2 + i; + + f (p0, p1, p2, p3); + + return p3[7]; // { dg-warning "\\\[-Warray-bounds]" } +} + +NOIPA int g4 (int i) +{ + if (i < 1) i = 1; + + const char *p0 = a9; + const char *p1 = p0 + i; + const char *p2 = p1 + i; + const char *p3 = p2 + i; + const char *p4 = p3 + i; + + f (p0, p1, p2, p3, p4); + + return p4[6]; // { dg-warning "\\\[-Warray-bounds]" } +} + +NOIPA int g5 (int i) +{ + if (i < 1) i = 1; + + const char *p0 = a9; + const char *p1 = p0 + i; + const char *p2 = p1 + i; + const char *p3 = p2 + i; + const char *p4 = p3 + i; + const char *p5 = p4 + i; + + f (p0, p1, p2, p3, p4, p5); + + return p5[5]; +} + +NOIPA int g6 (int i) +{ + if (i < 1) i = 1; + + const char *p0 = a9; + const char *p1 = p0 + i; + const char *p2 = p1 + i; + const char *p3 = p2 + i; + const char *p4 = p3 + i; + const char *p5 = p4 + i; + const char *p6 = p5 + i; + + f (p0, p1, p2, p3, p4, p5, p6); + + return p6[4]; +} + +NOIPA int g7 (int i) +{ + if (i < 1) i = 1; + + const char *p0 = a9; + const char *p1 = p0 + i; + const char *p2 = p1 + i; + const char *p3 = p2 + i; + const char *p4 = p3 + i; + const char *p5 = p4 + i; + const char *p6 = p5 + i; + const char *p7 = p6 + i; + + f (p0, p1, p2, p3, p4, p5, p6, p7); + + return p7[3]; +} + +NOIPA int g8 (int i) +{ + if (i < 1) i = 1; + + const char *p0 = a9; + const char *p1 = p0 + i; + const char *p2 = p1 + i; + const char *p3 = p2 + i; + const char *p4 = p3 + i; + const char *p5 = p4 + i; + const char *p6 = p5 + i; + const char *p7 = p6 + i; + const char *p8 = p7 + i; + + f (p0, p1, p2, p3, p4, p5, p6, p7, p8); + + return p8[2]; +} diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index 594ee9a..b79dfb2 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -4492,7 +4492,8 @@ vrp_prop::check_mem_ref (location_t location, tree ref, The loop computes the range of the final offset for expressions such as (A + i0 + ... + iN)[CSTOFF] where i0 through iN are SSA_NAMEs in some range. */ - while (TREE_CODE (arg) == SSA_NAME) + const unsigned limit = PARAM_VALUE (PARAM_SSA_NAME_DEF_CHAIN_LIMIT); + for (unsigned n = 0; TREE_CODE (arg) == SSA_NAME && n < limit; ++n) { gimple *def = SSA_NAME_DEF_STMT (arg); if (!is_gimple_assign (def)) |