[CodeExtractor] Do not marked outlined calls which may resume EH as noreturn
Treat terminators which resume exception propagation as returning instructions (at least, for the purposes of marking outlined functions `noreturn`). This is to avoid inserting traps after calls to outlined functions which unwind. rdar://46129950 llvm-svn: 348404
This commit is contained in:
@@ -1369,9 +1369,12 @@ Function *CodeExtractor::extractCodeRegion() {
|
||||
DVI->eraseFromParent();
|
||||
}
|
||||
|
||||
// Mark the new function `noreturn` if applicable.
|
||||
// Mark the new function `noreturn` if applicable. Terminators which resume
|
||||
// exception propagation are treated as returning instructions. This is to
|
||||
// avoid inserting traps after calls to outlined functions which unwind.
|
||||
bool doesNotReturn = none_of(*newFunction, [](const BasicBlock &BB) {
|
||||
return isa<ReturnInst>(BB.getTerminator());
|
||||
const Instruction *Term = BB.getTerminator();
|
||||
return isa<ReturnInst>(Term) || isa<ResumeInst>(Term);
|
||||
});
|
||||
if (doesNotReturn)
|
||||
newFunction->setDoesNotReturn();
|
||||
|
||||
Reference in New Issue
Block a user