This is the mail archive of the gcc-patches@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]

Re: [PATCH] Handle weak symbols


On Monday 07 May 2001 21:29, Mark Mitchell wrote:
> The assembly I get for that test case looks OK to me using a
> powerpc-linux-gnu cross compiler based on today's sources:
>
>   main:
> 	  mflr 0
> 	  stwu 1,-16(1)
> 	  lis 9,foo@ha
> 	  stw 0,20(1)
> 	  la 0,foo@l(9)
> 	  lis 3,.LC0@ha
> 	  cmpwi 0,0,0
> 	  la 3,.LC0@l(3)
> 	  li 4,0
> 	  beq- 0,.L4
> 	  lwz 4,foo@l(9)
>   .L4:
> 	  crxor 6,6,6
> 	  bl printf
> 	  lwz 0,20(1)
> 	  addi 1,1,16
> 	  mtlr 0
> 	  blr
>
> Does that look right to you?  If so, we need another test-case.

This looks OK, yes.

> It may be that the reason that this is working now is that some other
> optimization (delete_null_pointer_checks?) has gotten broken somehow.

Yes, I just tried it myself and I couldn't trigger it anymore, even though I 
bumped BRANCH_COST to 100! I came to the same conclusion as you, somewhere 
along the way to 3.0 some optimizations were disabled :-(. I even fear 
someone did it on purpose to fix the failure I'm fixing now the right way.

Anyway, gcc-2.95 produces code like this:

atexit:
        stwu 1,-16(1)
        mflr 0
        stw 0,20(1)
        lis 9,__dso_handle@ha
        la 0,__dso_handle@l(9)
        lwz 11,__dso_handle@l(9)
        srawi 9,0,31
        xor 5,9,0
        subf 5,5,9
        srawi 5,5,31
        and 5,11,5
        li 4,0
        bl __cxa_atexit
        lwz 0,20(1)
        mtlr 0
        la 1,16(1)
        blr

See how the branch got converted into a linear sequence of instructions?

So, the problem is that we no longer can find a testcase on PPC, but unless 
we can _prove_ that this bug cannot happen with gcc-3.0 on any glibc platform 
(ppc,x86,sparc,alpha,pa,mips) anymore, I still think we should apply a 
variant of my patch.

Franz.


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