diff options
author | Richard Biener <rguenther@suse.de> | 2021-08-17 11:23:06 +0200 |
---|---|---|
committer | Richard Biener <rguenther@suse.de> | 2021-08-17 11:24:14 +0200 |
commit | 3ed779689631ff8f398dcde06d5efa2a3c43ef27 (patch) | |
tree | b4b967559a5fdd4a12af45519c964680b8625b5c /gcc | |
parent | 2e0d7f16da0897fb2eb83f5c1ffe67f0ad747e92 (diff) | |
download | gcc-3ed779689631ff8f398dcde06d5efa2a3c43ef27.zip gcc-3ed779689631ff8f398dcde06d5efa2a3c43ef27.tar.gz gcc-3ed779689631ff8f398dcde06d5efa2a3c43ef27.tar.bz2 |
tree-optimization/101868 - avoid PRE of trapping mems across calls
This adds the testcase from the fix for the PR.
2021-08-17 Richard Biener <rguenther@suse.de>
PR tree-optimization/101868
* gcc.dg/lto/pr101868_0.c: New testcase.
* gcc.dg/lto/pr101868_1.c: Likewise.
* gcc.dg/lto/pr101868_2.c: Likewise.
* gcc.dg/lto/pr101868_3.c: Likewise.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/testsuite/gcc.dg/lto/pr101868_0.c | 33 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/lto/pr101868_1.c | 23 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/lto/pr101868_2.c | 11 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/lto/pr101868_3.c | 8 |
4 files changed, 75 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/lto/pr101868_0.c b/gcc/testsuite/gcc.dg/lto/pr101868_0.c new file mode 100644 index 0000000..c84d19b --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/pr101868_0.c @@ -0,0 +1,33 @@ +/* { dg-lto-do run } */ +/* { dg-lto-options { "-O2 -fno-strict-aliasing -flto" } } */ + +typedef unsigned long VALUE; + +__attribute__ ((cold)) +void rb_check_type(VALUE, int); + +static VALUE +repro(VALUE dummy, VALUE hash) +{ + if (hash == 0) { + rb_check_type(hash, 1); + } + else if (*(long *)hash) { + rb_check_type(hash, 1); + } + + + return *(long *)hash; +} + +static VALUE (*that)(VALUE dummy, VALUE hash) = repro; + +int +main(int argc, char **argv) +{ + argc--; + that(0, argc); + + rb_check_type(argc, argc); + +} diff --git a/gcc/testsuite/gcc.dg/lto/pr101868_1.c b/gcc/testsuite/gcc.dg/lto/pr101868_1.c new file mode 100644 index 0000000..146c14a --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/pr101868_1.c @@ -0,0 +1,23 @@ +typedef unsigned long VALUE; + + +__attribute__ ((noreturn)) void rexc_raise(VALUE mesg); + +VALUE rb_donothing(VALUE klass); + +static void +funexpected_type(VALUE x, int xt, int t) +{ + rexc_raise(rb_donothing(0)); +} + +__attribute__ ((cold)) +void +rb_check_type(VALUE x, int t) +{ + int xt; + + if (x == 0) { + funexpected_type(x, xt, t); + } +} diff --git a/gcc/testsuite/gcc.dg/lto/pr101868_2.c b/gcc/testsuite/gcc.dg/lto/pr101868_2.c new file mode 100644 index 0000000..e6f01b2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/pr101868_2.c @@ -0,0 +1,11 @@ +typedef unsigned long VALUE; + +static void thing(void) {} +static void (*ptr)(void) = &thing; + +VALUE +rb_donothing(VALUE klass) +{ + ptr(); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/lto/pr101868_3.c b/gcc/testsuite/gcc.dg/lto/pr101868_3.c new file mode 100644 index 0000000..6121762 --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/pr101868_3.c @@ -0,0 +1,8 @@ +typedef unsigned long VALUE; + +__attribute__((noreturn)) +void +rexc_raise(VALUE mesg) +{ + __builtin_exit(0); +} |