[PATCH] D40698: [ubsan] Diagnose noreturn functions which return
Vedant Kumar via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 30 19:12:47 PST 2017
vsk added inline comments.
================
Comment at: lib/CodeGen/CGCall.cpp:2756
SourceLocation EndLoc) {
+ if (FI.isNoReturn()) {
+ // Noreturn functions don't return.
----------------
efriedma wrote:
> Unfortunately, this won't catch cases where the caller has a noreturn marking, but the callee doesn't. Maybe strip the noreturn attribute from the caller, then put the sanitizer check into both the caller and callee?
If the caller sees a noreturn marking on the call target, inserting a 'reached-unreachable' check after the call is UB, and the optimizer throws it away. Perhaps you had a different case in mind?
================
Comment at: lib/CodeGen/CGCall.cpp:2764
// Naked functions don't have epilogues.
- Builder.CreateUnreachable();
+ EmitUnreachable(EndLoc);
return;
----------------
efriedma wrote:
> This is likely a problem. Not because the code is supposed to be reachable, but because putting additional code into a naked function can have weird effects. Probably not worth messing with this case.
Sorry for the noisy change. I recognized it as a mistake a second after I uploaded the new diff :(.
https://reviews.llvm.org/D40698
More information about the cfe-commits
mailing list