backport: re PR middle-end/45852 (volatile structs are broken!)

Backport from mainline
	2010-12-21  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/45852
	* expr.c (store_expr): Ignore alt_rtl if equal to target,
	but has side-effects.

	* gcc.target/i386/pr45852.c: New test.

From-SVN: r168879
This commit is contained in:
Jakub Jelinek 2011-01-16 23:56:10 +01:00 committed by Jakub Jelinek
parent dedf9c9915
commit 87e0ccb464
4 changed files with 31 additions and 1 deletions

View File

@ -1,6 +1,12 @@
2011-01-16 Jakub Jelinek <jakub@redhat.com>
Backport from mainline
2010-12-21 Jakub Jelinek <jakub@redhat.com>
PR middle-end/45852
* expr.c (store_expr): Ignore alt_rtl if equal to target,
but has side-effects.
2010-12-10 Jakub Jelinek <jakub@redhat.com>
PR rtl-optimization/46865

View File

@ -4662,7 +4662,10 @@ store_expr (tree exp, rtx target, int call_param_p, bool nontemporal)
/* If store_expr stores a DECL whose DECL_RTL(exp) == TARGET,
but TARGET is not valid memory reference, TEMP will differ
from TARGET although it is really the same location. */
&& !(alt_rtl && rtx_equal_p (alt_rtl, target))
&& !(alt_rtl
&& rtx_equal_p (alt_rtl, target)
&& !side_effects_p (alt_rtl)
&& !side_effects_p (target))
/* If there's nothing to copy, don't bother. Don't call
expr_size unless necessary, because some front-ends (C++)
expr_size-hook must not be given objects that are not

View File

@ -1,6 +1,11 @@
2011-01-16 Jakub Jelinek <jakub@redhat.com>
Backport from mainline
2010-12-21 Jakub Jelinek <jakub@redhat.com>
PR middle-end/45852
* gcc.target/i386/pr45852.c: New test.
2010-12-10 Jakub Jelinek <jakub@redhat.com>
PR rtl-optimization/46865

View File

@ -0,0 +1,16 @@
/* PR middle-end/45852 */
/* { dg-options "-O2 -mcmodel=small" } */
/* { dg-do compile { target { { i?86-*-linux* x86_64-*-linux* } && lp64 } } } */
/* { dg-require-visibility "" } */
struct S { int s; };
volatile struct S globvar __attribute__((visibility ("hidden"))) = { -6 };
void
foo (void)
{
globvar = globvar;
}
/* { dg-final { scan-assembler-times "globvar.%?rip" 2 } } */