This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug target/82158] _Noreturn functions that do return clobber caller's registers on ARM32 (but not other arches)


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

--- Comment #3 from Peter Cordes <peter at cordes dot ca> ---
(In reply to joseph@codesourcery.com from comment #2)
> Falling off a noreturn function sounds like it could be another case to 
> insert __builtin_trap (), as we do in various cases of undefined behavior.

gcc has had a `-mabort-on-noreturn` option for ARM32 for a long time, but it's
not enabled by default.

I'm still not sure if clobbering r5 when the function really doesn't return is
a feature (which gcc should be doing for other targets) or a bug.

It clearly breaks stack unwinding of call-preserved register values with x86-64
style .eh_frame metadata; does this matter for exceptions from callees of the
noreturn function, or only for debugging?

Anyway, gcc should either produce a compile-time error, call __builtin_trap()
or abort(), or properly restore all call-preserved registers when it returns. 
There should be no set of options that lets it make bad code like this, even
with a warning.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]