https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64012
Bug ID: 64012 Summary: GCC-4.9.2 option -fcaller-saves in -O2 Product: gcc Version: 4.9.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: airbak.li at huawei dot com A cross toolchain build by GCC-4.9.2, when I use this toolchain to compile kernel-3.4.35 with option -O2, it always crash when system power up. (CPU : armv-7 cortex-a9) -----------Crash log------------------------------ Unable to handle kernel paging request at virtual address ffffffff pgd = c0004000 [ffffffff] *pgd=85ffe821, *pte=00000000, *ppte=00000000 Internal error: Oops: 17 [#1] SMP ARM Modules linked in: CPU: 1 Not tainted (3.4.35_hi3535 #27) PC is at kmem_cache_alloc+0x54/0x130 LR is at con_insert_unipair+0xc0/0x10c pc : [<c00a5764>] lr : [<c028447c>] psr: a0000013 sp : c5831e60 ip : c05b27d8 fp : c5831e94 r10: 00000263 r9 : 00000003 r8 : 0000005f r7 : 0000005f r6 : 000000d0 r5 : c5802200 r4 : ffffffff r3 : 00000000 r2 : c5830000 r1 : c05a69e0 r0 : 0011e000 Flags: NzCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment kernel Control: 10c53c7d Table: 8000404a DAC: 00000015 -------------Assembler code------------------------- c00a5710 <kmem_cache_alloc>: c00a5710: e1a0c00d mov ip, sp c00a5714: e92ddff0 push {r4, r5, r6, r7, r8, r9, sl, fp, ip, lr, pc} c00a5718: e24cb004 sub fp, ip, #4 c00a571c: e24dd00c sub sp, sp, #12 c00a5720: e1a0300d mov r3, sp c00a5724: e3c32d7f bic r2, r3, #8128 ; 0x1fc0 c00a5728: e302c7d8 movw ip, #10200 ; 0x27d8 c00a572c: e3c2203f bic r2, r2, #63 ; 0x3f c00a5730: e34cc05b movt ip, #49243 ; 0xc05b c00a5734: e1a05000 mov r5, r0 c00a5738: e1a06001 mov r6, r1 c00a573c: e50be030 str lr, [fp, #-48] ; 0x30 c00a5740: e5923014 ldr r3, [r2, #20] c00a5744: e5951000 ldr r1, [r5] c00a5748: e79c0103 ldr r0, [ip, r3, lsl #2] c00a574c: e0813000 add r3, r1, r0 c00a5750: e593a004 ldr sl, [r3, #4] c00a5754: e7914000 ldr r4, [r1, r0] c00a5758: e3540000 cmp r4, #0 c00a575c: 0a000026 beq c00a57fc <kmem_cache_alloc+0xec> c00a5760: e5953014 ldr r3, [r5, #20] c00a5764: e7949003 ldr r9, [r4, r3] --->r4 is ffffffff c00a5768: e10f8000 mrs r8, CPSR ---------------------------------------------- When I compile kernel with "-O1" or "-O2 -fno-caller-saves", it is ok, no crash. (GCC-4.8 not have this problem) Question: 1. Please tell me about option "-fcaller-saves" in GCC-4.9.2. Is it different from GCC-4.8? 2. The error happen in code "con_insert_unipair()->kmem_cache_alloc()->slab_alloc()", file path is "linux-3.4.35\mm\slub.c". What codes will "-fcaller-saves" optimize? Please give me some samples. 3."-fcaller-saves" may be not the root cause. Generally, we use -O2 include "-fcaller-saves", we want to keep "-fcaller-saves", please help me to solve it.