[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:
Vedant Kumar
2018-12-05 19:35:37 +00:00
parent c10590f6f9
commit 09415a850e
2 changed files with 42 additions and 2 deletions

View File

@@ -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();