[PATCH] D156844: [Inliner] Add return attributes to callsites not marked `willreturn`/`nounwind`
Noah Goldstein via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 16 20:42:09 PDT 2023
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4d51c6258e83: [Inliner] Add return attributes to callsites not marked `willreturn`/`nounwind` (authored by goldstein.w.n).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D156844/new/
https://reviews.llvm.org/D156844
Files:
llvm/lib/Transforms/Utils/InlineFunction.cpp
llvm/test/Transforms/Inline/nonnull.ll
Index: llvm/test/Transforms/Inline/nonnull.ll
===================================================================
--- llvm/test/Transforms/Inline/nonnull.ll
+++ llvm/test/Transforms/Inline/nonnull.ll
@@ -159,7 +159,7 @@
define ptr @caller8() {
; CHECK-LABEL: define ptr @caller8() {
-; CHECK-NEXT: [[R_I:%.*]] = call ptr @buz()
+; CHECK-NEXT: [[R_I:%.*]] = call nonnull ptr @buz()
; CHECK-NEXT: ret ptr [[R_I]]
;
%r = call nonnull ptr @callee8()
Index: llvm/lib/Transforms/Utils/InlineFunction.cpp
===================================================================
--- llvm/lib/Transforms/Utils/InlineFunction.cpp
+++ llvm/lib/Transforms/Utils/InlineFunction.cpp
@@ -1331,13 +1331,15 @@
}
}
-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 @@
// 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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156844.550974.patch
Type: text/x-patch
Size: 1937 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230817/4788318e/attachment.bin>
More information about the llvm-commits
mailing list