[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
Wed Aug 16 20:42:02 PDT 2023


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG612a7f0b15a2: [Inliner] Add the callsites called function return attributes to set addable… (authored by goldstein.w.n).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156843/new/

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
@@ -141,7 +141,7 @@
 
 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()
Index: llvm/lib/Transforms/Utils/InlineFunction.cpp
===================================================================
--- llvm/lib/Transforms/Utils/InlineFunction.cpp
+++ llvm/lib/Transforms/Utils/InlineFunction.cpp
@@ -1341,21 +1341,17 @@
 }
 
 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;
 }


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


More information about the llvm-commits mailing list