Skip to content

Commit 741a3a0

Browse files
nikicronlieb
authored andcommitted
[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 llvm#123181.
1 parent 9e7eef7 commit 741a3a0

File tree

4 files changed

+11
-10
lines changed

4 files changed

+11
-10
lines changed

llvm/lib/Transforms/IPO/AttributorAttributes.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5752,7 +5752,8 @@ bool AANoCapture::isImpliedByIR(Attributor &A, const IRPosition &IRP,
57525752
if (IRP.getPositionKind() == IRP_CALL_SITE_ARGUMENT)
57535753
if (Argument *Arg = IRP.getAssociatedArgument()) {
57545754
SmallVector<Attribute, 1> Attrs;
5755-
A.getAttrs(IRP, {Attribute::Captures, Attribute::ByVal}, Attrs,
5755+
A.getAttrs(IRPosition::argument(*Arg),
5756+
{Attribute::Captures, Attribute::ByVal}, Attrs,
57565757
/* IgnoreSubsumingPositions */ true);
57575758
bool ArgNoCapture = any_of(Attrs, [](Attribute Attr) {
57585759
return Attr.getKindAsEnum() == Attribute::ByVal ||

llvm/test/Transforms/Attributor/liveness.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2364,7 +2364,7 @@ define internal void @call_via_pointer_with_dead_args_internal_a(ptr %a, ptr %b,
23642364
;
23652365
; CGSCC-LABEL: define {{[^@]+}}@call_via_pointer_with_dead_args_internal_a
23662366
; CGSCC-SAME: (ptr [[A:%.*]], ptr noundef nonnull align 128 dereferenceable(4) [[B:%.*]]) {
2367-
; 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)
2367+
; 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)
23682368
; CGSCC-NEXT: ret void
23692369
;
23702370
call void %fp(ptr %a, ptr %b, ptr %a, i64 -1, ptr null)

llvm/test/Transforms/Attributor/nonnull.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1058,7 +1058,7 @@ define internal void @optnone(ptr dereferenceable(4) %a) optnone noinline {
10581058
; CHECK: Function Attrs: noinline optnone
10591059
; CHECK-LABEL: define {{[^@]+}}@optnone
10601060
; CHECK-SAME: (ptr noundef nonnull dereferenceable(4) [[A:%.*]]) #[[ATTR12:[0-9]+]] {
1061-
; CHECK-NEXT: call void @use_i32_ptr(ptr nofree noundef nonnull [[A]])
1061+
; CHECK-NEXT: call void @use_i32_ptr(ptr nofree noundef nonnull captures(none) [[A]])
10621062
; CHECK-NEXT: ret void
10631063
;
10641064
call void @use_i32_ptr(ptr %a)

llvm/test/Transforms/Attributor/value-simplify.ll

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -973,11 +973,11 @@ define i1 @icmp() {
973973
define void @test_callee_is_undef(ptr %fn) {
974974
; TUNIT-LABEL: define {{[^@]+}}@test_callee_is_undef
975975
; TUNIT-SAME: (ptr nofree captures(none) [[FN:%.*]]) {
976-
; TUNIT-NEXT: call void @unknown_calle_arg_is_undef(ptr nofree noundef captures(none) [[FN]])
977-
; TUNIT-NEXT: ret void
976+
; TUNIT-NEXT: unreachable
978977
;
979978
; CGSCC-LABEL: define {{[^@]+}}@test_callee_is_undef
980-
; CGSCC-SAME: (ptr nofree noundef nonnull captures(none) [[FN:%.*]]) {
979+
; CGSCC-SAME: (ptr nofree captures(none) [[FN:%.*]]) {
980+
; CGSCC-NEXT: call void @callee_is_undef()
981981
; CGSCC-NEXT: call void @unknown_calle_arg_is_undef(ptr nofree noundef nonnull captures(none) [[FN]])
982982
; CGSCC-NEXT: ret void
983983
;
@@ -997,10 +997,10 @@ define internal void @callee_is_undef(ptr %fn) {
997997
}
998998
define internal void @unknown_calle_arg_is_undef(ptr %fn, i32 %arg) {
999999
;
1000-
; CHECK-LABEL: define {{[^@]+}}@unknown_calle_arg_is_undef
1001-
; CHECK-SAME: (ptr nofree noundef nonnull captures(none) [[FN:%.*]]) {
1002-
; CHECK-NEXT: call void [[FN]](i32 undef)
1003-
; CHECK-NEXT: ret void
1000+
; CGSCC-LABEL: define {{[^@]+}}@unknown_calle_arg_is_undef
1001+
; CGSCC-SAME: (ptr nofree noundef nonnull captures(none) [[FN:%.*]]) {
1002+
; CGSCC-NEXT: call void [[FN]](i32 undef)
1003+
; CGSCC-NEXT: ret void
10041004
;
10051005
call void %fn(i32 %arg)
10061006
ret void

0 commit comments

Comments
 (0)