diff options
author | Vedant Kumar <vsk@apple.com> | 2018-11-08 17:57:09 +0000 |
---|---|---|
committer | Vedant Kumar <vsk@apple.com> | 2018-11-08 17:57:09 +0000 |
commit | d6699423f17fa7b0fd8415c3e1733b711f24f5b6 (patch) | |
tree | 37a6a8ac36dcc4e79d46b8f25a92cfe7f75a390b /llvm/lib/Transforms/Utils/CodeExtractor.cpp | |
parent | 7383b4fba43c77e803927d5aaac4ec5f2ae7f6b9 (diff) | |
download | bcm5719-llvm-d6699423f17fa7b0fd8415c3e1733b711f24f5b6.tar.gz bcm5719-llvm-d6699423f17fa7b0fd8415c3e1733b711f24f5b6.zip |
[CodeExtractor] Mark functions noreturn when applicable
This eliminates the outlining penalty for llvm.trap/unreachable, because
callers no longer have to emit cleanup/ret instructions after calling an
outlined `noreturn` function.
rdar://45523626
llvm-svn: 346421
Diffstat (limited to 'llvm/lib/Transforms/Utils/CodeExtractor.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/CodeExtractor.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/CodeExtractor.cpp b/llvm/lib/Transforms/Utils/CodeExtractor.cpp index 419e1db08bf..41c3632c82a 100644 --- a/llvm/lib/Transforms/Utils/CodeExtractor.cpp +++ b/llvm/lib/Transforms/Utils/CodeExtractor.cpp @@ -1330,6 +1330,13 @@ Function *CodeExtractor::extractCodeRegion() { DVI->eraseFromParent(); } + // Mark the new function `noreturn` if applicable. + bool doesNotReturn = none_of(*newFunction, [](const BasicBlock &BB) { + return isa<ReturnInst>(BB.getTerminator()); + }); + if (doesNotReturn) + newFunction->setDoesNotReturn(); + LLVM_DEBUG(if (verifyFunction(*newFunction)) report_fatal_error("verifyFunction failed!")); return newFunction; |