Fix g++.dg/torture/stackalign/eh-alloca-1.C with LTO plugin

Jan Hubicka hubicka@ucw.cz
Thu Dec 2 16:06:00 GMT 2010


> 
> How so?  Maybe via TREE_CONSTANT_POOL_ADDRESS_P stuff?  And why

The code does not set TREE_CONSTANT_POOL_ADDRESS_P. It does sort of its own constant pool.

/* Put X, a SYMBOL_REF, in memory.  Return a SYMBOL_REF to the allocated
   memory.  Differs from force_const_mem in that a single pool is used for
   the entire unit of translation, and the memory is not guaranteed to be
   "near" the function in any interesting sense.  IS_PUBLIC controls whether
   the symbol can be shared across the entire application (or DSO).  *

As I've explained earlier, the problem is that the code is organized in a way
first producing label:

          ASM_GENERATE_INTERNAL_LABEL (label, "LDFCM", dw2_const_labelno);
          ++dw2_const_labelno;
          gcc_assert (!maybe_get_identifier (label));
          decl_id = get_identifier (label);

(in dw2_force_const_mem)
Then we happily use decl_id to reffer to the value.

At the end of compilation dw2_output_indirect_constants build the decl that
must match the decl_id computed above.  the decl is created as:

decl = build_decl (UNKNOWN_LOCATION, VAR_DECL, id, ptr_type_node);
where ID is the DECL_ID produced and used earlier.

build_decl then store ID in DECL_NAME.  Later DECL_ASSEMBLER_NAME calls

tree
decl_assembler_name (tree decl)
{
  if (!DECL_ASSEMBLER_NAME_SET_P (decl))
    lang_hooks.set_decl_assembler_name (decl);
  return DECL_WITH_VIS_CHECK (decl)->decl_with_vis.assembler_name; 
}

and finally we get into

static void
lto_set_decl_assembler_name (tree decl)
{
  /* This is almost the same as lhd_set_decl_assembler_name, except that
     we need to uniquify file-scope names, even if they are not
     TREE_PUBLIC, to avoid conflicts between individual files.  */
  tree id;

  if (TREE_PUBLIC (decl))
    id = targetm.mangle_decl_assembler_name (decl, DECL_NAME (decl));
  else
    { 
      const char *name = IDENTIFIER_POINTER (DECL_NAME (decl));
      char *label;

      ASM_FORMAT_PRIVATE_NAME (label, name, DECL_UID (decl));
      id = get_identifier (label);
    }

  SET_DECL_ASSEMBLER_NAME (decl, id);
}

I guess LTO frontend might be first one that mangles even names starting with
'*', but the code above really wants to build a variable with assembler name
matching internal label produced earlier, so setting assembler name instead of
going through frontend hooks seems sane to me.

It would be perhaps bit saner to if we produced decls early, but I am not sure
I want to reorganize that code now...

Honza

> do we care?  We're rebuilding this decl anyway (and thus would have
> a decl merging issue).
> 
> Your fix looks like a hack to work around a fundamental issue
> elsewhere ...
> 
> Richard.



More information about the Gcc-patches mailing list