https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100491
Bug ID: 100491 Summary: Code generation get worse when including function prototype on ARM Product: gcc Version: 11.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: fredrik.hederstie...@securitas-direct.com Target Milestone: --- Created attachment 50779 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50779&action=edit sym.c New in arm-none-eabi-gcc-11.1.0 I found that code generated when including a function prototype was getting worse. I've in the past tested gcc 4-10, and these didn't show this behavior. Attach example from CSiBE Flex. (Code was getting +17% size both with -O2 and -Os.) Target: arm-none-eabi, cortex-m3, softfloat GCC-10.2.0 00000000 <addsym.constprop.0.isra.0>: 0: e92d 43f8 stmdb sp!, {r3, r4, r5, r6, r7, r8, r9, lr} 4: 4689 mov r9, r1 6: 2165 movs r1, #101 ; 0x65 8: 461c mov r4, r3 a: 4607 mov r7, r0 c: 4690 mov r8, r2 e: f7ff fffe bl 0 <hashfunct> 12: 4605 mov r5, r0 14: f854 6020 ldr.w r6, [r4, r0, lsl #2] 18: b98e cbnz r6, 3e <addsym.constprop.0.isra.0+0x3e> 1a: 2014 movs r0, #20 1c: f7ff fffe bl 0 <flex_alloc> 20: f854 3025 ldr.w r3, [r4, r5, lsl #2] 24: b19b cbz r3, 4e <addsym.constprop.0.isra.0+0x4e> 26: 6043 str r3, [r0, #4] 28: 6018 str r0, [r3, #0] 2a: 2300 movs r3, #0 2c: e9c0 7902 strd r7, r9, [r0, #8] 30: 6003 str r3, [r0, #0] 32: f8c0 8010 str.w r8, [r0, #16] 36: f844 0025 str.w r0, [r4, r5, lsl #2] 3a: e8bd 83f8 ldmia.w sp!, {r3, r4, r5, r6, r7, r8, r9, pc} 3e: 4638 mov r0, r7 40: 68b1 ldr r1, [r6, #8] 42: f7ff fffe bl 0 <strcmp> 46: 2800 cmp r0, #0 48: d0f7 beq.n 3a <addsym.constprop.0.isra.0+0x3a> 4a: 6876 ldr r6, [r6, #4] 4c: e7e4 b.n 18 <addsym.constprop.0.isra.0+0x18> 4e: 6046 str r6, [r0, #4] 50: e7eb b.n 2a <addsym.constprop.0.isra.0+0x2a> 00000052 <cclinstal>: 52: b510 push {r4, lr} 54: 460c mov r4, r1 56: f7ff fffe bl 0 <copy_unsigned_string> 5a: 4622 mov r2, r4 5c: e8bd 4010 ldmia.w sp!, {r4, lr} 60: 2100 movs r1, #0 62: 4b01 ldr r3, [pc, #4] ; (68 <cclinstal+0x16>) 64: e7cc b.n 0 <addsym.constprop.0.isra.0> 66: bf00 nop 68: 00000000 .word 0x00000000 0000006c <ndinstal>: 6c: b570 push {r4, r5, r6, lr} 6e: 460d mov r5, r1 70: f7ff fffe bl 0 <copy_string> 74: 4604 mov r4, r0 76: 4628 mov r0, r5 78: f7ff fffe bl 0 <copy_unsigned_string> 7c: 2200 movs r2, #0 7e: 4601 mov r1, r0 80: 4b02 ldr r3, [pc, #8] ; (8c <ndinstal+0x20>) 82: 4620 mov r0, r4 84: e8bd 4070 ldmia.w sp!, {r4, r5, r6, lr} 88: e7ba b.n 0 <addsym.constprop.0.isra.0> 8a: bf00 nop 8c: 00000194 .word 0x00000194 GCC-11.1.0 00000000 <addsym.constprop.0>: 0: e92d 47f0 stmdb sp!, {r4, r5, r6, r7, r8, r9, sl, lr} 4: 4689 mov r9, r1 6: 2165 movs r1, #101 ; 0x65 8: 461d mov r5, r3 a: 4607 mov r7, r0 c: 4690 mov r8, r2 e: f7ff fffe bl 0 <hashfunct> 12: 4606 mov r6, r0 14: f855 a020 ldr.w sl, [r5, r0, lsl #2] 18: f1ba 0f00 cmp.w sl, #0 1c: d112 bne.n 44 <addsym.constprop.0+0x44> 1e: 2014 movs r0, #20 20: f7ff fffe bl 0 <flex_alloc> 24: f855 3026 ldr.w r3, [r5, r6, lsl #2] 28: 4604 mov r4, r0 2a: b1a3 cbz r3, 56 <addsym.constprop.0+0x56> 2c: 6043 str r3, [r0, #4] 2e: 6018 str r0, [r3, #0] 30: 2000 movs r0, #0 32: e9c4 7902 strd r7, r9, [r4, #8] 36: 6020 str r0, [r4, #0] 38: f8c4 8010 str.w r8, [r4, #16] 3c: f845 4026 str.w r4, [r5, r6, lsl #2] 40: e8bd 87f0 ldmia.w sp!, {r4, r5, r6, r7, r8, r9, sl, pc} 44: 4638 mov r0, r7 46: f8da 1008 ldr.w r1, [sl, #8] 4a: f7ff fffe bl 0 <strcmp> 4e: b128 cbz r0, 5c <addsym.constprop.0+0x5c> 50: f8da a004 ldr.w sl, [sl, #4] 54: e7e0 b.n 18 <addsym.constprop.0+0x18> 56: f8c0 a004 str.w sl, [r0, #4] 5a: e7e9 b.n 30 <addsym.constprop.0+0x30> 5c: f04f 30ff mov.w r0, #4294967295 ; 0xffffffff 60: e7ee b.n 40 <addsym.constprop.0+0x40> 00000062 <cclinstal>: 62: b513 push {r0, r1, r4, lr} 64: 460c mov r4, r1 66: f7ff fffe bl 0 <copy_unsigned_string> 6a: 2365 movs r3, #101 ; 0x65 6c: 4622 mov r2, r4 6e: 9300 str r3, [sp, #0] 70: 2100 movs r1, #0 72: 4b02 ldr r3, [pc, #8] ; (7c <cclinstal+0x1a>) 74: f7ff ffc4 bl 0 <addsym.constprop.0> 78: b002 add sp, #8 7a: bd10 pop {r4, pc} 7c: 00000000 .word 0x00000000 00000080 <ndinstal>: 80: b537 push {r0, r1, r2, r4, r5, lr} 82: 460d mov r5, r1 84: f7ff fffe bl 0 <copy_string> 88: 4604 mov r4, r0 8a: 4628 mov r0, r5 8c: f7ff fffe bl 0 <copy_unsigned_string> 90: 2365 movs r3, #101 ; 0x65 92: 4601 mov r1, r0 94: 9300 str r3, [sp, #0] 96: 2200 movs r2, #0 98: 4620 mov r0, r4 9a: 4b02 ldr r3, [pc, #8] ; (a4 <ndinstal+0x24>) 9c: f7ff ffb0 bl 0 <addsym.constprop.0> a0: b003 add sp, #12 a2: bd30 pop {r4, r5, pc} a4: 00000194 .word 0x00000194