From: Jakub Jelinek Date: Wed, 11 Jan 2017 08:40:59 +0000 (+0100) Subject: re PR middle-end/50199 (wrong code with -flto -fno-merge-constants) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4c4b47031d4bcbf116cbc3c479933adf14b2b4fe;p=gcc.git 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 --- diff --git a/gcc/lto/ChangeLog b/gcc/lto/ChangeLog index f94add55852..9bf6df01544 100644 --- a/gcc/lto/ChangeLog +++ b/gcc/lto/ChangeLog @@ -1,3 +1,9 @@ +2017-01-11 Jakub Jelinek + + PR middle-end/50199 + * lto-lang.c (lto_post_options): Force flag_merge_constants = 1 + if it was 0. + 2017-01-09 Jakub Jelinek PR translation/79019 diff --git a/gcc/lto/lto-lang.c b/gcc/lto/lto-lang.c index c2b49dc44b6..fccb8c61f8f 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 c332d9062e0..2b5f3b9dca0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-01-11 Jakub Jelinek + + PR middle-end/50199 + * gcc.dg/lto/pr50199_0.c: New test. + 2017-01-10 Martin Sebor 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 00000000000..61d0012be92 --- /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; +}