diff options
author | Jakub Jelinek <jakub@redhat.com> | 2017-01-11 09:40:59 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2017-01-11 09:40:59 +0100 |
commit | 4c4b47031d4bcbf116cbc3c479933adf14b2b4fe (patch) | |
tree | eb8e4fca20eece89c2e2363b589bcc9a85df7417 /gcc | |
parent | a476f04689b31d139f976d3ef8c80631ca52c591 (diff) | |
download | gcc-4c4b47031d4bcbf116cbc3c479933adf14b2b4fe.zip gcc-4c4b47031d4bcbf116cbc3c479933adf14b2b4fe.tar.gz gcc-4c4b47031d4bcbf116cbc3c479933adf14b2b4fe.tar.bz2 |
re PR middle-end/50199 (wrong code with -flto -fno-merge-constants)
PR middle-end/50199
* lto-lang.c (lto_post_options): Force flag_merge_constants = 1
if it was 0.
* gcc.dg/lto/pr50199_0.c: New test.
From-SVN: r244304
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/lto/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/lto/lto-lang.c | 6 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/lto/pr50199_0.c | 17 |
4 files changed, 34 insertions, 0 deletions
diff --git a/gcc/lto/ChangeLog b/gcc/lto/ChangeLog index f94add5..9bf6df0 100644 --- a/gcc/lto/ChangeLog +++ b/gcc/lto/ChangeLog @@ -1,3 +1,9 @@ +2017-01-11 Jakub Jelinek <jakub@redhat.com> + + PR middle-end/50199 + * lto-lang.c (lto_post_options): Force flag_merge_constants = 1 + if it was 0. + 2017-01-09 Jakub Jelinek <jakub@redhat.com> PR translation/79019 diff --git a/gcc/lto/lto-lang.c b/gcc/lto/lto-lang.c index c2b49dc..fccb8c6 100644 --- a/gcc/lto/lto-lang.c +++ b/gcc/lto/lto-lang.c @@ -857,6 +857,12 @@ lto_post_options (const char **pfilename ATTRIBUTE_UNUSED) support. */ flag_excess_precision_cmdline = EXCESS_PRECISION_FAST; + /* When partitioning, we can tear appart STRING_CSTs uses from the same + TU into multiple partitions. Without constant merging the constants + might not be equal at runtime. See PR50199. */ + if (!flag_merge_constants) + flag_merge_constants = 1; + /* Initialize the compiler back end. */ return false; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c332d90..2b5f3b9 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-01-11 Jakub Jelinek <jakub@redhat.com> + + PR middle-end/50199 + * gcc.dg/lto/pr50199_0.c: New test. + 2017-01-10 Martin Sebor <msebor@redhat.com> PR testsuite/78960 diff --git a/gcc/testsuite/gcc.dg/lto/pr50199_0.c b/gcc/testsuite/gcc.dg/lto/pr50199_0.c new file mode 100644 index 0000000..61d0012 --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/pr50199_0.c @@ -0,0 +1,17 @@ +/* PR middle-end/50199 */ +/* { dg-lto-options {{-O2 -flto -fno-merge-constants --param=lto-min-partition=1}} } */ + +__attribute__ ((noinline)) const char * +foo (const char *x) +{ + return x; +} + +int +main () +{ + const char *a = "ab"; + if (a != foo (a)) + __builtin_abort (); + return 0; +} |