[PATCH] PR optimization/13472
Eric Botcazou
ebotcazou@libertysurf.fr
Tue Dec 23 20:38:00 GMT 2003
Hi,
This is again a problem that shows up only on the 3.3 branch, but is probably
latent on mainline. When the testcase is compiled with -O2 -march=i686
-pedantic, a store to .rodata is emitted, which leads to a segfault at
runtime. And, most surprisingly, removing -pedantic makes the problem
disappear!!
Here's what I wrote in the audit trail:
"The final culprit is the reload pass: it generates the store (although the
MEM is marked as unchanging) because it thinks the memory location is a
regular spill slot. It appears that the reload pass doesn't care about the
/u flag when recording equivalent memory locations based on the presence of
REG_EQUIV notes.
But I don't know if this is really a reload problem: maybe reload implicitly
expects full equivalence between objects in pairs that carry REG_EQUIV notes.
In any cases, the dependence upon -pedantic is certainly a bug and is
actually recognized as such in the code (c-typeck.c:790):
/* Return either DECL or its known constant value (if it has one), but
return DECL if pedantic or DECL has mode BLKmode. This is for
bug-compatibility with the old behavior of decl_constant_value
(before GCC 3.0); every use of this function is a bug and it should
be removed before GCC 3.1. It is not appropriate to use pedantic
in a way that affects optimization, and BLKmode is probably not the
right test for avoiding misoptimizations either. */
static tree
decl_constant_value_for_broken_optimization (decl)
tree decl;
{
if (pedantic || DECL_MODE (decl) == BLKmode)
return decl;
else
return decl_constant_value (decl);
}
So I think the fix is to remove decl_constant_value_for_broken_optimization
altogether from the C front-end. But this is probably not doable on a
release branch."
I've attached the patch that does this on mainline. Bootstrapped/regtested
on i586-redhat-linux-gnu (mainline except Ada and libgcj).
2003-12-23 Eric Botcazou <ebotcazou@libertysurf.fr>
* c-typeck.c (decl_constant_value_for_broken_optimization): Delete.
(default_conversion): Call decl_constant_value instead of it.
(convert_for_assignment): Likewise.
(digest_init): Likewise.
--
Eric Botcazou
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr13472.c
Type: text/x-csrc
Size: 473 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20031223/0e5f45ca/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr13472.diff
Type: text/x-diff
Size: 2727 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20031223/0e5f45ca/attachment-0001.bin>
More information about the Gcc-patches
mailing list