[PR 48333] avoid -fcompare-debug errors from builtins in MEM attrs

Alexandre Oliva aoliva@redhat.com
Sat Apr 2 08:06:00 GMT 2011


I caught this with bootstrap-debug-lean, then realized a bug report was
open about the same problem.  When Jakub introduced MEM attrs for the
MEMs that refer to the function to be called, it exposed a rare
problem.

Say we're compiling a translation unit that, in one function A, calls
foo (available as __builtin_foo), and in another function B, calls bar,
that GCC internally folded to __builtin_foo, a separate but equivalent
FUNCTION_DECL as far as MEM attrs are concerned.

While compiling A, we introduce in the MEM attrs hash table an attribute
for foo.  Then, while compiling B, we find and reuse the same MEM attr.
So far, so good.

Now, while recompiling for -fcompare-debug, the garbage collector
decides to run between the compilations of A and B, and it finds that
the MEM attr created for A's RTL is no longer necessary, throwing it
away.  Then, when it compiles B, it does not find a pre-existing MEM,
and introduces one for __builtin_foo.

It should be obvious now that the final RTL dumps that -fcompare-debug
compares for B will differ in this case, because in one case it will say
foo, and in the other, __builtin_foo.

This patch avoids this particular instance of the problem by recording
the __builtin FUNCTION_DECL in the MEM attrs for calls.  This ought to
be enough to fix this particular instance of the problem, but I'm a bit
concerned that other, more convoluted versions of it might still be
lingering around.  Changing the tree expressions when creating
attributes might be doable, but I find that highly undesirable; another
option would be to always dump functions as their builtins; there are
probably other options too.

This regstrapped on x86_64-linux-gnu.  Ok to install?

-------------- next part --------------
A non-text attachment was scrubbed...
Name: compdebug-call-built-in-mem-attr-pr48333.patch
Type: text/x-diff
Size: 1309 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20110402/19b7dc91/attachment.bin>
-------------- next part --------------


-- 
Alexandre Oliva, freedom fighter    http://FSFLA.org/~lxoliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/   FSF Latin America board member
Free Software Evangelist      Red Hat Brazil Compiler Engineer


More information about the Gcc-patches mailing list