aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/InlineFunction.cpp
diff options
context:
space:
mode:
authorNoah Goldstein <goldstein.w.n@gmail.com>2023-08-16 21:51:09 -0500
committerNoah Goldstein <goldstein.w.n@gmail.com>2023-08-16 22:43:04 -0500
commit4d51c6258e8391738e5c002b36de3b5538d31b8c (patch)
tree731f9f3a6a9e489a2285aa10500567f37561a68b /llvm/lib/Transforms/Utils/InlineFunction.cpp
parent612a7f0b15a2b40d725bcfe618fbc69f1cb15607 (diff)
downloadllvm-4d51c6258e8391738e5c002b36de3b5538d31b8c.zip
llvm-4d51c6258e8391738e5c002b36de3b5538d31b8c.tar.gz
llvm-4d51c6258e8391738e5c002b36de3b5538d31b8c.tar.bz2
[Inliner] Add return attributes to callsites not marked `willreturn`/`nounwind`
The actual callsite we are adding to doesn't need to be `willreturn`/`nounwind`, only ever instructions between the callsite and the return. Reviewed By: nikic Differential Revision: https://reviews.llvm.org/D156844
Diffstat (limited to 'llvm/lib/Transforms/Utils/InlineFunction.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/InlineFunction.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp
index 9b4c62a..b70236c 100644
--- a/llvm/lib/Transforms/Utils/InlineFunction.cpp
+++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp
@@ -1331,13 +1331,15 @@ static void AddAliasScopeMetadata(CallBase &CB, ValueToValueMapTy &VMap,
}
}
-static bool MayContainThrowingOrExitingCall(Instruction *Begin,
- Instruction *End) {
+static bool MayContainThrowingOrExitingCallAfterCB(CallBase *Begin,
+ ReturnInst *End) {
assert(Begin->getParent() == End->getParent() &&
"Expected to be in same basic block!");
+ auto BeginIt = Begin->getIterator();
+ assert(BeginIt != End->getIterator() && "Non-empty BB has empty iterator");
return !llvm::isGuaranteedToTransferExecutionToSuccessor(
- Begin->getIterator(), End->getIterator(), InlinerAttributeWindow + 1);
+ ++BeginIt, End->getIterator(), InlinerAttributeWindow + 1);
}
static AttrBuilder IdentifyValidAttributes(CallBase &CB) {
@@ -1393,7 +1395,7 @@ static void AddReturnAttributes(CallBase &CB, ValueToValueMapTy &VMap) {
// limit the check to both RetVal and RI are in the same basic block and
// there are no throwing/exiting instructions between these instructions.
if (RI->getParent() != RetVal->getParent() ||
- MayContainThrowingOrExitingCall(RetVal, RI))
+ MayContainThrowingOrExitingCallAfterCB(RetVal, RI))
continue;
// Add to the existing attributes of NewRetVal, i.e. the cloned call
// instruction.