This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug lto/42401] wrong-code with -flto



------- Comment #5 from matz at gcc dot gnu dot org  2009-12-19 01:19 -------
To explain: the miscompilation is a result of the cloner (when cloning for the
find() call) creating a new tree for a local static variable (the 'm' in
main).  After inlining we have:

if (  &mD.2293._M_tD.2062._M_implD.2039._M_headerD.2043
   != &mD.2303._M_tD.2062._M_implD.2039._M_headerD.2043)

note the different UIDs for 'm'.  fold will say true to the unequality,
as references to static vars are unequal if the base VAR_DECL is different.

The reason for all this is because the LTO reader/writer of jump_functions
create the new tree already.  The input for the LTO writer contains the same
tree node for the decl in main and the jump_function (val.constant),
but as it uses a different output_block (hence unshared cache) it can't find
the tree and emits a new copy.

For whatever reason richis patch makes this work, but I can't see why it
does ... ;-/


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42401


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]