On Wed, May 28, 2014 at 6:31 PM, Jan Hubicka <hubi...@ucw.cz> wrote:
>> Honza,
>>
>> I'm glad that you're making progress.
>>
>> > David, this looks like a bug in the AIX target output macros. I get:
>> >         .set 
>> > _ZTCSt14basic_ifstreamIcSt11char_traitsIcEE0_Si.localalias.69,_ZTCSt14basic_ifstreamIcSt11char_traitsIcEE0_Si
>>
>> > (this is correct since localalias is really an alias)
>>
>> > _ZTCSt14basic_ifstreamIcSt11char_traitsIcEE0_Si.localalias.69:
>> >         .space 40
>> > _ZTCSt14basic_ifstreamIcSt11char_traitsIcEE0_Si:
>> ...
>>
>> > This is wrong, since we should not try to out the variable at least if I 
>> > read AIX assembly correctly.
>>
>> > varpool has explicit test to not output any aliases, so perhaps this is a 
>> > bug in wrapup_globals
>> > and AIX output macros.  I will try to track more after my teaching tonight.
>>
>> The AIX support handles AIX XCOFF assembler syntax and chooses
>> appropriate sections, but it would not choose to emit an extra
>> definition. If there are multiple definitions, then the varasm macros
>> are being invoked multiple times for the same symbol.
>
> I now understand what goes wrong: AIX uses section anchors and the code to
> produce them completely ignore the existence of aliases.  It means that we
> get a variable and alias on a different offsets within the anchor.
>
> I think we need to somehow propagate anchros of objects into anchors of 
> aliases.
> The code goes by:
>
> validize_mem
>   that gets SYMBOL_REF for the alias
>   to
> use_anchored_address
>   to
> place_block_symbol
>
> and place_block adds the alias and allocates space for it.
> I suppose we want to walk to alias target there:
>
> Index: varasm.c
> ===================================================================
> --- varasm.c    (revision 211028)
> +++ varasm.c    (working copy)
> @@ -1083,6 +1083,9 @@
>  {
>    addr_space_t as = ADDR_SPACE_GENERIC;
>    int reloc;
> +  symtab_node *snode = symtab_get_node (decl);
> +  if (snode)
> +    decl = symtab_alias_ultimate_target (snode)->decl;
>
>    if (TREE_TYPE (decl) != error_mark_node)
>      as = TYPE_ADDR_SPACE (TREE_TYPE (decl));
> @@ -7084,7 +7087,16 @@
>      }
>    else
>      {
> +      struct symtab_node *snode;
>        decl = SYMBOL_REF_DECL (symbol);
> +
> +      snode = symtab_node (decl);
> +      if (snode->alias)
> +       {
> +         rtx target = DECL_RTL (symtab_alias_ultimate_target (snode)->decl);
> +         SYMBOL_REF_BLOCK_OFFSET (symbol) = SYMBOL_REF_BLOCK_OFFSET (target);
> +         return;
> +       }
>        alignment = get_variable_align (decl);
>        size = tree_to_uhwi (DECL_SIZE_UNIT (decl));
>        if ((flag_sanitize & SANITIZE_ADDRESS)
>
> I am testing if that lets me to finish a bootstrap at gcc111

Richard Sandiford wrote the original section anchors implementation,
so he would be a good person to comment about the interaction between
aliases and section anchors.

Thanks, David

Reply via email to