[Bug lto/50601] [4.7 Regression] New LTO failures

rguenth at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Dec 6 11:35:00 GMT 2011


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

--- Comment #6 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-12-06 11:34:41 UTC ---
Because the decl isn't considered decl_address_invariant_p () - of course,
it is neither TREE_STATIC nor DECL_EXTERNAL ...

It _is_ both TREE_PUBLIC and TREE_STATIC when created by the C++ frontend
(and during compile stage).

We get

2
cp_lto_20100302_0.o 4
164 6cc97232062f75e0 PREVAILING_DEF_IRONLY _Z1fPU8__vectorf
177 6cc97232062f75e0 PREVAILING_DEF_IRONLY _Z1fPDv4_f
180 6cc97232062f75e0 PREVAILING_DEF_IRONLY _ZN1AIDv4_fE1tE
182 6cc97232062f75e0 PREVAILING_DEF_IRONLY _ZN1AIU8__vectorfE1tE
cp_lto_20100302_1.o 3
164 5d25700523736b18 PREVAILING_DEF main
168 5d25700523736b18 RESOLVED_IR _Z1fPDv4_f
179 5d25700523736b18 RESOLVED_IR _ZN1AIDv4_fE1tE

which is then mangled via cgraph_make_decl_local during the IPA
function and variable visibility pass.  This removes the TREE_PUBLIC
flag, the TREE_STATIC flag remains at WPA stage.  Note that the
parent, non-alias decl stays TREE_PUBLIC.

The no longer TREE_PUBLIC alias is then mangled at LTRANS stage, and
the TREE_STATIC flag is cleared in:

input_varpool_node (file_data=0x7ffff5b61000, ib=0x19ec4f0)
    at /space/rguenther/src/svn/trunk/gcc/lto-cgraph.c:1083
1083      if (node->finalized)
(gdb) l
1078      if (node->in_other_partition)
1079        {
1080          DECL_EXTERNAL (node->decl) = 1;
1081          TREE_STATIC (node->decl) = 0;
1082        }

but DECL_EXTERNAL is in turn cleared again by

assemble_alias (decl=0x7ffff5a2c140, target=0x7ffff5b5af00)
    at /space/rguenther/src/svn/trunk/gcc/varasm.c:5850
5850      if (TREE_CODE (decl) == FUNCTION_DECL)
(gdb) l
5845         note that the symbol is in fact locally defined.  */
5846      if (! is_weakref)
5847        DECL_EXTERNAL (decl) = 0;

that, of course, looks bogus in the light of LTO partitioning.  Doing

  /* A quirk of the initial implementation of aliases required that the user
     add "extern" to all of them.  Which is silly, but now historical.  Do
     note that the symbol is in fact locally defined.  */
  if (! is_weakref
      && (TREE_CODE (decl) == FUNCTION_DECL
          || !varpool_node (decl)->in_other_partition))
    DECL_EXTERNAL (decl) = 0;

instead "fixes" this bug.



More information about the Gcc-bugs mailing list