Jonathan Roelofs
2014-Nov-25 14:29 UTC
[LLVMdev] bx instruction getting generated in arm assembly for O1
On 11/25/14 12:42 AM, MAYUR PANDEY wrote:> Hi Jonathan, > > The assembly generated in case of clang-3.5 is > > indirect_call: > .fnstart > .Leh_func_begin0: > ldr r0, .LCPI0_0 > ldr r1, .LCPI0_1 > .LPC0_0: > add r0, pc, r0 > ldr r0, [r1, r0] > ldr r0, [r0] > bx r0 > .align 2 > .LCPI0_0: > .long _GLOBAL_OFFSET_TABLE_-(.LPC0_0+8) > .LCPI0_1: > .long indirect_func(GOT) > .Ltmp0: > .size indirect_call, .Ltmp0-indirect_call > .Leh_func_end0: > .fnendHmm, never mind. This looks correct. This is tail call optimization, which is possible because indirect_call() doesn't have anything in its frame. Cheers, Jon> > with clang-3.4.2 the assembly generated is: > > ndirect_call: > push {r11, lr} > ldr r0, .LCPI0_0 > mov r11, sp > ldr r1, .LCPI0_1 > .LPC0_0: > add r0, pc, r0 > ldr r0, [r1, r0] > ldr r0, [r0] > blx r0 > pop {r11, pc} > .align 2 > .LCPI0_0: > .long _GLOBAL_OFFSET_TABLE_-(.LPC0_0+8) > .LCPI0_1: > .long indirect_func(GOT) > .Ltmp0: > .size indirect_call, .Ltmp0-indirect_call > > Both assemblies are generated with O1 optimization. The assembly generated with > trunk version of clang is similar to 3.5 > > Thanks, > > Mayur >-- Jon Roelofs jonathan at codesourcery.com CodeSourcery / Mentor Embedded