[Bug target/50970] Function pointer dereferenced twice in if statement on Arm cpu
mikpe at it dot uu.se
gcc-bugzilla@gcc.gnu.org
Sat Nov 19 17:45:00 GMT 2011
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50970
--- Comment #7 from Mikael Pettersson <mikpe at it dot uu.se> 2011-11-19 17:42:53 UTC ---
Created attachment 25859
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=25859
reduced test case
Reduced test case. Running this on i686 shows a single call to func3
>/mnt/scratch/install47/bin/g++ -O2 -Wall pr50970.cc ; ./a.out
TestClass::func3 from 0x8048553
but on ARM we see two calls from different locations:
>/mnt/scratch/install47/bin/g++ -march=armv5te -mtune=arm10tdmi -O2 -Wall pr50970.cc ; ./a.out
TestClass::func3 from 0x8554
TestClass::func3 from 0x8590
Looking at the code for testFunction
void TestClass::testFunction()
{
if ((this->*_myFunc3)() == 0)
;
}
we see not one but two indirect method calls (the blx insns):
_ZN9TestClass12testFunctionEv:
.fnstart
.LFB16:
@ args = 0, pretend = 0, frame = 16
@ frame_needed = 0, uses_anonymous_args = 0
stmfd sp!, {r4, lr}
.save {r4, lr}
ldr r1, [r0, #4]
.pad #16
sub sp, sp, #16
tst r1, #1
ldrne r2, [r0, r1, asr #1]
ldrne r3, [r0, #0]
ldreq r3, [r0, #0]
addeq r1, r0, r1, asr #1
addne r1, r0, r1, asr #1
ldrne r3, [r2, r3]
mov r4, r0
mov r0, sp
blx r3
ldr r3, [sp, #0]
cmp r3, #0
beq .L14
.L7:
add sp, sp, #16
ldmfd sp!, {r4, pc}
.L14:
ldr r1, [r4, #4]
add r0, sp, #8
tst r1, #1
ldrne r2, [r4, r1, asr #1]
ldrne r3, [r4, #0]
ldreq r3, [r4, #0]
addeq r1, r4, r1, asr #1
addne r1, r4, r1, asr #1
ldrne r3, [r2, r3]
blx r3
b .L7
More information about the Gcc-bugs
mailing list