diff options
author | Richard Biener <rguenther@suse.de> | 2021-08-23 09:57:05 +0200 |
---|---|---|
committer | Richard Biener <rguenther@suse.de> | 2021-08-23 11:53:15 +0200 |
commit | ad665deeafd31238b537139385e1e80b40c10e0c (patch) | |
tree | 5b0c5616fb3711b3393e31a5287aa248f657762e /gcc/testsuite/gcc.dg | |
parent | 70c7ab5c487f392e04907ce8f22eb454b8d3c4ff (diff) | |
download | gcc-ad665deeafd31238b537139385e1e80b40c10e0c.zip gcc-ad665deeafd31238b537139385e1e80b40c10e0c.tar.gz gcc-ad665deeafd31238b537139385e1e80b40c10e0c.tar.bz2 |
tree-optimization/79334 - avoid PRE of possibly trapping array-ref
This replicates tree-eh.c in_array_bound_p into VNs
vn_reference_may_trap to fix hoisting of a possibly trapping
ARRAY_REF across a call that might not return.
2021-08-23 Richard Biener <rguenther@suse.de>
PR tree-optimization/79334
* tree-ssa-sccvn.c (copy_reference_ops_from_ref): Record
a type also for COMPONENT_REFs.
(vn_reference_may_trap): Check ARRAY_REF with constant index
against the array domain.
* gcc.dg/torture/pr79334-0.c: New testcase.
* gcc.dg/torture/pr79334-1.c: Likewise.
Diffstat (limited to 'gcc/testsuite/gcc.dg')
-rw-r--r-- | gcc/testsuite/gcc.dg/torture/pr79334-0.c | 23 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/torture/pr79334-1.c | 1 |
2 files changed, 24 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/torture/pr79334-0.c b/gcc/testsuite/gcc.dg/torture/pr79334-0.c new file mode 100644 index 0000000..fa45a6d --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr79334-0.c @@ -0,0 +1,23 @@ +/* { dg-do run } */ +/* { dg-additional-sources "pr79334-1.c" } */ + +extern int d[][8]; + +static void __attribute__((noinline)) +func_that_exits (int flag) +{ + if (!flag) + __builtin_exit (0); +} + +int main () +{ + int e = 0; + while (1) + { + func_that_exits (e); + /* We do not know whether d[1024][0] will trap. */ + e = d[1024][0]; + } + return 0; +} diff --git a/gcc/testsuite/gcc.dg/torture/pr79334-1.c b/gcc/testsuite/gcc.dg/torture/pr79334-1.c new file mode 100644 index 0000000..b1c8a27 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr79334-1.c @@ -0,0 +1 @@ +int d[1][8]; |