This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/82158] _Noreturn functions that do return clobber caller's registers on ARM32 (but not other arches)
- From: "peter at cordes dot ca" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 14 Sep 2017 23:17:14 +0000
- Subject: [Bug target/82158] _Noreturn functions that do return clobber caller's registers on ARM32 (but not other arches)
- Auto-submitted: auto-generated
- References: <bug-82158-4@http.gcc.gnu.org/bugzilla/>
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.