[PATCH] D156843: [Inliner] Add the callsites called function return attributes to set addable attributes

Noah Goldstein via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 1 18:45:32 PDT 2023


goldstein.w.n created this revision.
goldstein.w.n added reviewers: nikic, fhahn, efriedma.
Herald added subscribers: StephenFan, hiraditya.
Herald added a project: All.
goldstein.w.n requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

callsite attributes really should be a superset of the callsite +
callsite called functions attributes, but since its not we should use
the superset.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156843

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
@@ -142,7 +142,7 @@
 
 define ptr @caller7() {
 ; CHECK-LABEL: define ptr @caller7() {
-; CHECK-NEXT:    [[R_I:%.*]] = call ptr @buz() #[[ATTR1]]
+; CHECK-NEXT:    [[R_I:%.*]] = call nonnull ptr @buz() #[[ATTR1]]
 ; CHECK-NEXT:    ret ptr [[R_I]]
 ;
   %r = call ptr @callee7()
Index: llvm/lib/Transforms/Utils/InlineFunction.cpp
===================================================================
--- llvm/lib/Transforms/Utils/InlineFunction.cpp
+++ llvm/lib/Transforms/Utils/InlineFunction.cpp
@@ -1341,8 +1341,10 @@
 }
 
 static AttrBuilder IdentifyValidAttributes(CallBase &CB) {
-
-  AttrBuilder AB(CB.getContext(), CB.getAttributes().getRetAttrs());
+  AttrBuilder AB(CB.getContext(),
+                 CB.getAttributes().getRetAttrs().addAttributes(
+                     CB.getCalledFunction()->getContext(),
+                     CB.getCalledFunction()->getAttributes().getRetAttrs()));
   if (!AB.hasAttributes())
     return AB;
   AttrBuilder Valid(CB.getContext());


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156843.546289.patch
Type: text/x-patch
Size: 1179 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230802/ab80e9b6/attachment.bin>


More information about the llvm-commits mailing list