[llvm] 8a43d0e - [Attributor] Check correct IRPosition in AANoCapture::isImpliedByIR()

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 29 08:34:23 PST 2025


Author: Nikita Popov
Date: 2025-01-29T17:34:10+01:00
New Revision: 8a43d0e8736cf5e0f95a5f02c9b6855a703b2e4e

URL: https://github.com/llvm/llvm-project/commit/8a43d0e8736cf5e0f95a5f02c9b6855a703b2e4e
DIFF: https://github.com/llvm/llvm-project/commit/8a43d0e8736cf5e0f95a5f02c9b6855a703b2e4e.diff

LOG: [Attributor] Check correct IRPosition in AANoCapture::isImpliedByIR()

This case is intended to check the callee argument, not the call-site.

Fixes an issue introduced in #123181.

Added: 
    

Modified: 
    llvm/lib/Transforms/IPO/AttributorAttributes.cpp
    llvm/test/Transforms/Attributor/liveness.ll
    llvm/test/Transforms/Attributor/nonnull.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
index 77f2e1cc880f71..17e7fada108276 100644
--- a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
+++ b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
@@ -5752,7 +5752,8 @@ bool AANoCapture::isImpliedByIR(Attributor &A, const IRPosition &IRP,
   if (IRP.getPositionKind() == IRP_CALL_SITE_ARGUMENT)
     if (Argument *Arg = IRP.getAssociatedArgument()) {
       SmallVector<Attribute, 1> Attrs;
-      A.getAttrs(IRP, {Attribute::Captures, Attribute::ByVal}, Attrs,
+      A.getAttrs(IRPosition::argument(*Arg),
+                 {Attribute::Captures, Attribute::ByVal}, Attrs,
                  /* IgnoreSubsumingPositions */ true);
       bool ArgNoCapture = any_of(Attrs, [](Attribute Attr) {
         return Attr.getKindAsEnum() == Attribute::ByVal ||

diff  --git a/llvm/test/Transforms/Attributor/liveness.ll b/llvm/test/Transforms/Attributor/liveness.ll
index 8830df6851c356..874eff661f0531 100644
--- a/llvm/test/Transforms/Attributor/liveness.ll
+++ b/llvm/test/Transforms/Attributor/liveness.ll
@@ -2364,7 +2364,7 @@ define internal void @call_via_pointer_with_dead_args_internal_a(ptr %a, ptr %b,
 ;
 ; CGSCC-LABEL: define {{[^@]+}}@call_via_pointer_with_dead_args_internal_a
 ; CGSCC-SAME: (ptr [[A:%.*]], ptr noundef nonnull align 128 dereferenceable(4) [[B:%.*]]) {
-; CGSCC-NEXT:    call void @called_via_pointer(ptr [[A]], ptr nofree noundef nonnull align 128 dereferenceable(4) [[B]], ptr nofree [[A]], i64 noundef -1, ptr nofree noundef null)
+; CGSCC-NEXT:    call void @called_via_pointer(ptr [[A]], ptr nofree noundef nonnull align 128 captures(none) dereferenceable(4) [[B]], ptr nofree captures(none) [[A]], i64 noundef -1, ptr nofree noundef null)
 ; CGSCC-NEXT:    ret void
 ;
   call void %fp(ptr %a, ptr %b, ptr %a, i64 -1, ptr null)

diff  --git a/llvm/test/Transforms/Attributor/nonnull.ll b/llvm/test/Transforms/Attributor/nonnull.ll
index c22f1f39e26e9f..efe2f06562be2b 100644
--- a/llvm/test/Transforms/Attributor/nonnull.ll
+++ b/llvm/test/Transforms/Attributor/nonnull.ll
@@ -1058,7 +1058,7 @@ define internal void @optnone(ptr dereferenceable(4) %a) optnone noinline {
 ; CHECK: Function Attrs: noinline optnone
 ; CHECK-LABEL: define {{[^@]+}}@optnone
 ; CHECK-SAME: (ptr noundef nonnull dereferenceable(4) [[A:%.*]]) #[[ATTR12:[0-9]+]] {
-; CHECK-NEXT:    call void @use_i32_ptr(ptr nofree noundef nonnull [[A]])
+; CHECK-NEXT:    call void @use_i32_ptr(ptr nofree noundef nonnull captures(none) [[A]])
 ; CHECK-NEXT:    ret void
 ;
   call void @use_i32_ptr(ptr %a)


        


More information about the llvm-commits mailing list