[Bug target/84521] [8 Regression] aarch64: Frame-pointer corruption with __builtin_setjmp/__builtin_longjmp and -fomit-frame-pointer

wilco at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Feb 22 22:51:00 GMT 2018


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84521

--- Comment #9 from Wilco <wilco at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #7)
> cfun->has_nonlocal_label instead of cfun->calls_setjmp would cover
> __builtin_setjmp.

Do non-local labels do the same odd thing? It seems to me if the mid-end
automatically inserts explicit writes to the frame pointer, it should also set
frame_pointer_needed. This may be a bug on other targets too.

Also a much better implementation would use a small landing pad in the function
that does the __builtin_setjmp (rather than inline it a different function), so
you avoid the frame pointer corruption. Eg.

baz:
        ...
        ldr     x1, [x0, 8]
        br      x1

L7_nonlocal: (landing pad in foo)
        ldr     x29, [x0, 16]
        ldr     sp,  [x0]
        b       .L7

Or maybe we should get rid of these horrible hacks altogether?


More information about the Gcc-bugs mailing list