From 8a43d0e8736cf5e0f95a5f02c9b6855a703b2e4e Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Wed, 29 Jan 2025 17:27:25 +0100 Subject: [PATCH] [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. --- llvm/lib/Transforms/IPO/AttributorAttributes.cpp | 3 ++- llvm/test/Transforms/Attributor/liveness.ll | 2 +- llvm/test/Transforms/Attributor/nonnull.ll | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp index 77f2e1cc880f..17e7fada1082 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 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 8830df6851c3..874eff661f05 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 c22f1f39e26e..efe2f06562be 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)