Message ID | 20101215175901.GJ27214@tyan-ft48-01.lab.bos.redhat.com |
---|---|
State | New |
Headers | show |
On 12/15/2010 9:59 AM, Jakub Jelinek wrote: > CCing Mark who has added alt_rtl stuff. Unfortunately, I remember nothing about this. I went and looked at the code, and I just don't fully recall what was going on there. > I think either we just shouldn't set alt_rtl at all when it has side effects > (as done in this patch), or the above if should do similar testing on > side_effects_p for alt_rtl/target. I suspect the latter. I think that it's more logical for the low-level function (expand_expr_real_1) to say "this is what's being modified" and for the high-level one to say "OK, but I don't care" than it is for the low-level function to try to guess why the high-level one wants the information. I suppose that's just style, though, not substance. Thank you,
--- gcc/expr.c.jj 2010-11-29 13:27:43.000000000 +0100 +++ gcc/expr.c 2010-12-14 14:12:07.000000000 +0100 @@ -8445,7 +8445,7 @@ expand_expr_real_1 (tree exp, rtx target else if (MEM_P (decl_rtl) && modifier != EXPAND_INITIALIZER) { - if (alt_rtl) + if (alt_rtl && !side_effects_p (decl_rtl)) *alt_rtl = decl_rtl; decl_rtl = use_anchored_address (decl_rtl); if (modifier != EXPAND_CONST_ADDRESS --- gcc/testsuite/gcc.target/i386/pr45852.c.jj 2010-12-14 14:30:23.000000000 +0100 +++ gcc/testsuite/gcc.target/i386/pr45852.c 2010-12-14 14:37:59.000000000 +0100 @@ -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 } } */