Content originally posted in LPCWare by Daniel Widyanto on Tue Nov 13 21:03:20 MST 2012
Well, the only way to check it is to disassemble your main() for both cases. My guess is that optimization level-0 never reuse register value to call the functions. Hence, it would generate longer assembly instructions.
Eg. For optimization lv 0<code>
ldr r0, #function1_addr
ldr r0, [r0]
bx r0
ldr r0, #function2_addr
ldr r0, [r0]
bx r0
function1_addr:
.word function1_addr_content
function2_addr:
.word function2_addr_content
</code>
Eg. For optimization higher than lv-0<code>
ldr r4, #function1_addr
ldr r0, [r4, #0]
bx r0
ldr r0, [r4, #4]
bx r0
function1_addr:
.word function1_addr_content
function2_addr:
.word function2_addr_content
</code>