Hi,
this little routine is miscompiled with -O2 with gcc-3.3 on ppc-linux:
nsresult imgContainerGIF::DecodingComplete(void)
{
mDoneDecoding = 1;
PRUint32 numFrames = inlinedGetNumFrames();
if (numFrames == 1) {
nsCOMPtr<gfxIImageFrame> currentFrame;
inlinedGetFrameAt(0, getter_AddRefs(currentFrame));
currentFrame->SetMutable(0);
}
return 0;
}
This is the assembly:
_ZN15imgContainerGIF16DecodingCompleteEv:
stwu %r1,-48(%r1)
mflr %r0
stw %r0,52(%r1)
li %r0,1
stw %r0,104(%r3) # <variable>.mDoneDecoding
stw %r31,44(%r1)
addi %r31,%r3,16 # this, this
lwz %r0,16(%r31) # <variable>.mCount
stw %r30,40(%r1)
addi %r30,%r1,16 # this
cmpwi %cr0,%r0,1
stw %r29,36(%r1)
mr %r3,%r30 # this
beq- %cr0,.L202
.L188:
lwz %r0,52(%r1)
li %r3,0
lwz %r29,36(%r1)
lwz %r30,40(%r1)
mtlr %r0
lwz %r31,44(%r1)
addi %r1,%r1,48
blr
.L202:
li %r0,0 # rawPtr
stw %r0,16(%r1) # <variable>.mRawPtr, rawPtr
bl _ZN13nsCOMPtr_base16begin_assignmentEv@plt
mr %r29,%r3 # <anonymous>
li %r4,0
mr %r3,%r31 # this
bl _ZN15nsSupportsArray9ElementAtEj@plt
lwz %r9,16(%r1) # <variable>.mRawPtr, <anonymous> XXXXX
cmpwi %cr0,%r3,0 # _elem
mr %r0,%r3 # _elem
li %r4,0
mr %r3,%r9 # <anonymous>
beq- %cr0,.L196
stw %r0,0(%r29) # * <anonymous>, _elem XXXXX
.L196:
lwz %r9,0(%r9) # <variable>._vptr.nsISupports
lwz %r9,20(%r9)
mtctr %r9
bctrl
mr %r3,%r30 # this
bl _ZN13nsCOMPtr_baseD2Ev@plt
b .L188
The problem are the marked lines, they are swapped ( 0(%r29) and
16(%r1) point
to the same stack slot, r29 is the return value of
_ZN13nsCOMPtr_base16begin_assignmentEv). Compiling with -O1 or
-fno-strict-aliasing lets the code work.
I've attached the preprocessed source of the miscompiled file.
Franz.
<imgContainerGIF.ii.bz2>