[Bug rtl-optimization/55672] [4.8 Regression] -fstack-check=generic ICEs in print_reg, at config/i386/i386.c:13868
hjl.tools at gmail dot com
gcc-bugzilla@gcc.gnu.org
Tue Dec 18 20:35:00 GMT 2012
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55672
H.J. Lu <hjl.tools at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|target |rtl-optimization
--- Comment #8 from H.J. Lu <hjl.tools at gmail dot com> 2012-12-18 20:35:17 UTC ---
(In reply to comment #4)
> If stack_realign_p is true, frame_pointer_needed is also true. So we can use
> fp to eliminate frame but i386.c::x86_can_eliminate prohibits it. The code
> looks strange:
>
>
> if (stack_realign_fp)
> return ((from == ARG_POINTER_REGNUM
> && to == HARD_FRAME_POINTER_REGNUM)
> || (from == FRAME_POINTER_REGNUM
> && to == STACK_POINTER_REGNUM));
>
> So we permit to change argument pointer but not frame pointer to FP which again
> is strange IMHO. Changing the code to
>
> if (stack_realign_fp)
> return ((from == ARG_POINTER_REGNUM
> && to == HARD_FRAME_POINTER_REGNUM)
> || (from == FRAME_POINTER_REGNUM
> && to == STACK_POINTER_REGNUM)
> || (from == FRAME_POINTER_REGNUM
> && to == HARD_FRAME_POINTER_REGNUM));
>
> solves the problem.
It fixes ICE, but generates questionable code:
main:
.LFB0:
.cfi_startproc
pushl %ebp
.cfi_def_cfa_offset 8
.cfi_offset 5, -8
movl %esp, %ebp
.cfi_def_cfa_register 5
andl $-16, %esp
subl $8236, %esp
orl $0, (%esp)
addl $8204, %esp
cmpl $4, -40(%ebp)
je .L2
call abort
.L2:
movl $0, %eax
leave
.cfi_restore 5
.cfi_def_cfa 4, 4
ret
Without LRA, we got
main:
.LFB0:
.cfi_startproc
pushl %ebp
.cfi_def_cfa_offset 8
.cfi_offset 5, -8
movl %esp, %ebp
.cfi_def_cfa_register 5
andl $-16, %esp
subl $8236, %esp
orl $0, (%esp)
addl $8204, %esp
cmpl $4, (%esp)
je .L2
call abort
.L2:
movl $0, %eax
leave
.cfi_restore 5
.cfi_def_cfa 4, 4
ret
The difference is
--- x.s 2012-12-18 12:24:17.072888139 -0800
+++ no-lra.s 2012-12-18 12:30:11.419157548 -0800
@@ -14,7 +14,7 @@ main:
subl $8236, %esp
orl $0, (%esp)
addl $8204, %esp
- cmpl $4, -40(%ebp)
+ cmpl $4, (%esp)
je .L2
call abort
.L2:
I think LRA generated code is wrong. The reason we don't allow
converting software frame pointer to hardware frame pointer is
when stack alignment is needed, hardware frame pointer is used
to save stack pointer. We can no longer use it for software
frame pointer.
More information about the Gcc-bugs
mailing list