[llvm] 612a7f0 - [Inliner] Add the callsites called function return attributes to set addable attributes
Noah Goldstein via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 16 20:41:45 PDT 2023
Author: Noah Goldstein
Date: 2023-08-16T22:43:04-05:00
New Revision: 612a7f0b15a2b40d725bcfe618fbc69f1cb15607
URL: https://github.com/llvm/llvm-project/commit/612a7f0b15a2b40d725bcfe618fbc69f1cb15607
DIFF: https://github.com/llvm/llvm-project/commit/612a7f0b15a2b40d725bcfe618fbc69f1cb15607.diff
LOG: [Inliner] Add the callsites called function return attributes to set addable attributes
We can do this by just querying attribute in the callsite itself. This
is both cleaner code and produces bette results.
Differential Revision: https://reviews.llvm.org/D156843
Added:
Modified:
llvm/lib/Transforms/Utils/InlineFunction.cpp
llvm/test/Transforms/Inline/nonnull.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp
index 29e7ca01425141..9b4c62a7a70c85 100644
--- a/llvm/lib/Transforms/Utils/InlineFunction.cpp
+++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp
@@ -1341,21 +1341,17 @@ static bool MayContainThrowingOrExitingCall(Instruction *Begin,
}
static AttrBuilder IdentifyValidAttributes(CallBase &CB) {
-
- AttrBuilder AB(CB.getContext(), CB.getAttributes().getRetAttrs());
- if (!AB.hasAttributes())
- return AB;
AttrBuilder Valid(CB.getContext());
// Only allow these white listed attributes to be propagated back to the
// callee. This is because other attributes may only be valid on the call
// itself, i.e. attributes such as signext and zeroext.
- if (auto DerefBytes = AB.getDereferenceableBytes())
+ if (auto DerefBytes = CB.getRetDereferenceableBytes())
Valid.addDereferenceableAttr(DerefBytes);
- if (auto DerefOrNullBytes = AB.getDereferenceableOrNullBytes())
+ if (auto DerefOrNullBytes = CB.getRetDereferenceableOrNullBytes())
Valid.addDereferenceableOrNullAttr(DerefOrNullBytes);
- if (AB.contains(Attribute::NoAlias))
+ if (CB.hasRetAttr(Attribute::NoAlias))
Valid.addAttribute(Attribute::NoAlias);
- if (AB.contains(Attribute::NonNull))
+ if (CB.hasRetAttr(Attribute::NonNull))
Valid.addAttribute(Attribute::NonNull);
return Valid;
}
diff --git a/llvm/test/Transforms/Inline/nonnull.ll b/llvm/test/Transforms/Inline/nonnull.ll
index 270f753ca6f842..faaf65bb60d0f6 100644
--- a/llvm/test/Transforms/Inline/nonnull.ll
+++ b/llvm/test/Transforms/Inline/nonnull.ll
@@ -141,7 +141,7 @@ define nonnull ptr @callee7() {
define ptr @caller7() {
; CHECK-LABEL: define ptr @caller7() {
-; CHECK-NEXT: [[R_I:%.*]] = call ptr @buz() #[[ATTR0]]
+; CHECK-NEXT: [[R_I:%.*]] = call nonnull ptr @buz() #[[ATTR0]]
; CHECK-NEXT: ret ptr [[R_I]]
;
%r = call ptr @callee7()
More information about the llvm-commits
mailing list