diff mbox

ipa-visibility TLC 2/n

Message ID 20140530210219.GE17544@kam.mff.cuni.cz
State New
Headers show

Commit Message

Jan Hubicka May 30, 2014, 9:02 p.m. UTC
> Honza,
> 
> For example g++.dg/abi/vcall1.C fails at a call in a "localalias"
> function, which jumps to a bad location:
> 
> 
> (gdb) up
> #1  0x100004c0 in B::B() [clone .localalias.2] ()
> (gdb) x/16i $pc-32
>    0x100004a0 <_ZN1BC2Ev+156>:  add     r10,r10,r8
>    0x100004a4 <_ZN1BC2Ev+160>:  mr      r3,r10
>    0x100004a8 <_ZN1BC2Ev+164>:  stw     r2,20(r1)
>    0x100004ac <_ZN1BC2Ev+168>:  lwz     r10,0(r9)
>    0x100004b0 <_ZN1BC2Ev+172>:  lwz     r11,8(r9)
>    0x100004b4 <_ZN1BC2Ev+176>:  mtctr   r10
>    0x100004b8 <_ZN1BC2Ev.localalias.2+180>:     lwz     r2,4(r9)
>    0x100004bc <_ZN1BC2Ev.localalias.2+184>:     bctrl
> => 0x100004c0 <_ZN1BC2Ev.localalias.2+188>:     lwz     r2,20(r1)
>    0x100004c4 <_ZN1BC2Ev.localalias.2+192>:     addi    r1,r31,64
>    0x100004c8 <_ZN1BC2Ev.localalias.2+196>:     lwz     r0,8(r1)
>    0x100004cc <_ZN1BC2Ev.localalias.2+200>:     mtlr    r0
>    0x100004d0 <_ZN1BC2Ev.localalias.2+204>:     lwz     r31,-4(r1)
>    0x100004d4 <_ZN1BC2Ev.localalias.2+208>:     blr

I suppose this is the problem Richard mentioned - the offsets are not computed
by DECL_RTL callback but by place_block. 

> >>> is SYMBOL_REF_BLOCK_OFFSET (target) guaranteed to be valid at this point?
> >>> It looked at face value like you'd need a recursive call to place_block_symbol
> >>> on the target before the copy.
> >>
> >> My reading was that SYMBOL_REF_BLOCK_OFFSET is computed at DECL_RTL
> >> calculation time. But you are right - it is done by validize_mem that
> >> is not done by DECL_RTL.  Shall I just call it on target first?
> >
> > Yeah, sounds like calling place_block_symbol would be safer.

I will test:


Honza
> >
> > IIRC, the reason I didn't do it at SET_DECL_RTL time is that some frontends
> > tended to create placeholder decls that for whatever reason ended up with
> > an initial DECL_RTL, then changed the properties of the decl later once
> > more information was known.  (This was all many years ago.)
> >
> > Thanks,
> > Richard

Comments

David Edelsohn May 31, 2014, 12:57 a.m. UTC | #1
Honza,

With the patch, I cannot bootstrap.

I am concerned about the much greater frequency of AIX linker warnings
about branch not followed by no-op after your patch.

GCC may bootstrap only because it links libstdc++ statically. If your
patch is too aggressive in its effort to remove PLT calls, it may be
breaking shared library support on AIX. Previously there were a few
recursive libstdc++ calls that binds_local_p() asserted were bound
locally to functions declared global.  I hope that cross-module calls
have not been incorrectly analyzed as local.

Thanks, David


On Fri, May 30, 2014 at 5:02 PM, Jan Hubicka <hubicka@ucw.cz> wrote:
>> Honza,
>>
>> For example g++.dg/abi/vcall1.C fails at a call in a "localalias"
>> function, which jumps to a bad location:
>>
>>
>> (gdb) up
>> #1  0x100004c0 in B::B() [clone .localalias.2] ()
>> (gdb) x/16i $pc-32
>>    0x100004a0 <_ZN1BC2Ev+156>:  add     r10,r10,r8
>>    0x100004a4 <_ZN1BC2Ev+160>:  mr      r3,r10
>>    0x100004a8 <_ZN1BC2Ev+164>:  stw     r2,20(r1)
>>    0x100004ac <_ZN1BC2Ev+168>:  lwz     r10,0(r9)
>>    0x100004b0 <_ZN1BC2Ev+172>:  lwz     r11,8(r9)
>>    0x100004b4 <_ZN1BC2Ev+176>:  mtctr   r10
>>    0x100004b8 <_ZN1BC2Ev.localalias.2+180>:     lwz     r2,4(r9)
>>    0x100004bc <_ZN1BC2Ev.localalias.2+184>:     bctrl
>> => 0x100004c0 <_ZN1BC2Ev.localalias.2+188>:     lwz     r2,20(r1)
>>    0x100004c4 <_ZN1BC2Ev.localalias.2+192>:     addi    r1,r31,64
>>    0x100004c8 <_ZN1BC2Ev.localalias.2+196>:     lwz     r0,8(r1)
>>    0x100004cc <_ZN1BC2Ev.localalias.2+200>:     mtlr    r0
>>    0x100004d0 <_ZN1BC2Ev.localalias.2+204>:     lwz     r31,-4(r1)
>>    0x100004d4 <_ZN1BC2Ev.localalias.2+208>:     blr
>
> I suppose this is the problem Richard mentioned - the offsets are not computed
> by DECL_RTL callback but by place_block.
>
>> >>> is SYMBOL_REF_BLOCK_OFFSET (target) guaranteed to be valid at this point?
>> >>> It looked at face value like you'd need a recursive call to place_block_symbol
>> >>> on the target before the copy.
>> >>
>> >> My reading was that SYMBOL_REF_BLOCK_OFFSET is computed at DECL_RTL
>> >> calculation time. But you are right - it is done by validize_mem that
>> >> is not done by DECL_RTL.  Shall I just call it on target first?
>> >
>> > Yeah, sounds like calling place_block_symbol would be safer.
>
> I will test:
> Index: varasm.c
> ===================================================================
> --- varasm.c    (revision 211096)
> +++ varasm.c    (working copy)
> @@ -7094,6 +7094,7 @@
>        if (snode->alias)
>         {
>           rtx target = DECL_RTL (symtab_alias_ultimate_target (snode)->decl);
> +         place_block_symbol (symbol);
>           SYMBOL_REF_BLOCK_OFFSET (symbol) = SYMBOL_REF_BLOCK_OFFSET (target);
>           return;
>         }
>
>
> Honza
>> >
>> > IIRC, the reason I didn't do it at SET_DECL_RTL time is that some frontends
>> > tended to create placeholder decls that for whatever reason ended up with
>> > an initial DECL_RTL, then changed the properties of the decl later once
>> > more information was known.  (This was all many years ago.)
>> >
>> > Thanks,
>> > Richard
Richard Sandiford May 31, 2014, 7:42 a.m. UTC | #2
David Edelsohn <dje.gcc@gmail.com> writes:
> Honza,
>
> With the patch, I cannot bootstrap.

I think it was meant to be:

	  place_block_symbol (target);

rather than:

	  place_block_symbol (symbol);

I.e. we need to place "target" before copying its offset.

Thanks,
Richard
David Edelsohn May 31, 2014, 2:43 p.m. UTC | #3
This leads to bootstrap errors like:

In file included from
/tmp/20140531/powerpc-ibm-aix7.1.0.0/libstdc++-v3/include/backward/strstream:54:0,
                 from
/nasfarm/edelsohn/src/src/libstdc++-v3/src/c++98/strstream.cc:44:
/tmp/20140531/powerpc-ibm-aix7.1.0.0/libstdc++-v3/include/istream: In
constructor 'std::istrstream::istrstream(char*)':
/tmp/20140531/powerpc-ibm-aix7.1.0.0/libstdc++-v3/include/istream:94:32:
internal compiler error: in place_block_symbol, at varasm.c:7067
       : _M_gcount(streamsize(0))
                                ^

On Sat, May 31, 2014 at 3:42 AM, Richard Sandiford
<rdsandiford@googlemail.com> wrote:
> David Edelsohn <dje.gcc@gmail.com> writes:
>> Honza,
>>
>> With the patch, I cannot bootstrap.
>
> I think it was meant to be:
>
>           place_block_symbol (target);
>
> rather than:
>
>           place_block_symbol (symbol);
>
> I.e. we need to place "target" before copying its offset.
>
> Thanks,
> Richard
diff mbox

Patch

Index: varasm.c
===================================================================
--- varasm.c    (revision 211096)
+++ varasm.c    (working copy)
@@ -7094,6 +7094,7 @@ 
       if (snode->alias)
        {
          rtx target = DECL_RTL (symtab_alias_ultimate_target (snode)->decl);
+         place_block_symbol (symbol);
          SYMBOL_REF_BLOCK_OFFSET (symbol) = SYMBOL_REF_BLOCK_OFFSET (target);
          return;
        }