Hi Richard,
I have a patch set for bug 43513 - The stack pointer is adjusted twice.
01_pr43513.3.patch
02_pr43513.3.test.patch
03_pr43513.3.mudflap.patch
The patch set has been bootstrapped and reg-tested on x86_64.
I will sent out the patches individually.
The patch replaces a vla __builtin_alloca that has a constant argument with an
array declaration.
The effect of the patch on the example from the bug report for
-march=armv7-a -mthumb -Os -fpic is a text size reduction from 72 to 64 bytes.
This is demonstrated in the following diff, where left is without and right is
with patch.
push {r4, r5, r6, r7, r8, lr} | push {r4, r5, r6, lr}
add r7, sp, #0 | sub sp, sp, #40
sub sp, sp, #48 <
ldr r4, .L4 ldr r4, .L4
mov r0, sp mov r0, sp
ldr r6, .L4+4 <
bl bar(PLT) bl bar(PLT)
ldr r3, .L4+8 | ldr r3, .L4+4
.LPIC8: .LPIC8:
add r4, pc add r4, pc
mov r8, sp | ldr r6, .L4+8
movs r5, #0 movs r5, #0
> ldr r4, [r4, r3]
.LPIC9: .LPIC9:
add r6, pc add r6, pc
ldr r4, [r4, r3] <
.L2: .L2:
ldr r2, [r8, r5] | ldr r2, [sp, r5]
mov r1, r6 mov r1, r6
ldr r0, [r4, #0] ldr r0, [r4, #0]
adds r5, r5, #4 adds r5, r5, #4
bl fprintf(PLT) bl fprintf(PLT)
cmp r5, #40 cmp r5, #40
bne .L2 bne .L2
mov sp, r7 | add sp, sp, #40
pop {r4, r5, r6, r7, r8, pc} | pop {r4, r5, r6, pc}
.L5: .L5:
.align 2 .align 2
.L4: .L4:
.word _GLOBAL_OFFSET_TABLE_-(.LPIC8 .word _GLOBAL_OFFSET_TABLE_-(.LPIC8
.word .LC0-(.LPIC9+4) <
.word stdout(GOT) .word stdout(GOT)
> .word .LC0-(.LPIC9+4)
.size foo3, .-foo3 .size foo3, .-foo3
.section .rodata.str1.1,"aMS", .section .rodata.str1.1,"aMS",
.LC0: .LC0:
.ascii "%d \000" .ascii "%d \000"
Thanks,
- Tom