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
This commit is contained in:
Jakub Jelinek 2017-01-11 09:40:59 +01:00 committed by Jakub Jelinek
parent a476f04689
commit 4c4b47031d
4 changed files with 34 additions and 0 deletions

View File

@ -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

View File

@ -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;
}

View File

@ -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

View File

@ -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;
}