34 changes: 18 additions & 16 deletions llvm/test/Transforms/Attributor/IPConstantProp/PR26044.ll
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ define void @fn2(ptr %P, i1 %C) {
; TUNIT: if.end:
; TUNIT-NEXT: [[E_2:%.*]] = phi ptr [ [[P]], [[ENTRY:%.*]] ], [ null, [[FOR_COND1:%.*]] ]
; TUNIT-NEXT: [[TMP0:%.*]] = load i32, ptr [[E_2]], align 4
; TUNIT-NEXT: store i32 [[TMP0]], ptr [[P]], align 4
; TUNIT-NEXT: [[CALL:%.*]] = call i32 @fn1(i32 [[TMP0]]) #[[ATTR3:[0-9]+]]
; TUNIT-NEXT: store i32 [[CALL]], ptr [[P]], align 4
; TUNIT-NEXT: br label [[FOR_COND1]]
; TUNIT: exit:
; TUNIT-NEXT: ret void
Expand Down Expand Up @@ -54,11 +55,11 @@ exit:
}

define internal i32 @fn1(i32 %p1) {
; CGSCC: Function Attrs: nofree norecurse nosync nounwind willreturn memory(none)
; CGSCC-LABEL: define {{[^@]+}}@fn1
; CGSCC-SAME: (i32 returned [[P1:%.*]]) #[[ATTR1:[0-9]+]] {
; CGSCC-NEXT: entry:
; CGSCC-NEXT: ret i32 [[P1]]
; CHECK: Function Attrs: nofree norecurse nosync nounwind willreturn memory(none)
; CHECK-LABEL: define {{[^@]+}}@fn1
; CHECK-SAME: (i32 returned [[P1:%.*]]) #[[ATTR1:[0-9]+]] {
; CHECK-NEXT: entry:
; CHECK-NEXT: ret i32 [[P1]]
;
entry:
%tobool = icmp ne i32 %p1, 0
Expand All @@ -70,15 +71,16 @@ define void @fn_no_null_opt(ptr %P, i1 %C) null_pointer_is_valid {
;
; TUNIT: Function Attrs: nofree norecurse nosync nounwind null_pointer_is_valid
; TUNIT-LABEL: define {{[^@]+}}@fn_no_null_opt
; TUNIT-SAME: (ptr nocapture nofree writeonly [[P:%.*]], i1 [[C:%.*]]) #[[ATTR1:[0-9]+]] {
; TUNIT-SAME: (ptr nocapture nofree writeonly [[P:%.*]], i1 [[C:%.*]]) #[[ATTR2:[0-9]+]] {
; TUNIT-NEXT: entry:
; TUNIT-NEXT: br label [[IF_END:%.*]]
; TUNIT: for.cond1:
; TUNIT-NEXT: br i1 [[C]], label [[IF_END]], label [[EXIT:%.*]]
; TUNIT: if.end:
; TUNIT-NEXT: [[E_2:%.*]] = phi ptr [ undef, [[ENTRY:%.*]] ], [ null, [[FOR_COND1:%.*]] ]
; TUNIT-NEXT: [[TMP0:%.*]] = load i32, ptr null, align 4294967296
; TUNIT-NEXT: store i32 [[TMP0]], ptr [[P]], align 4
; TUNIT-NEXT: [[CALL:%.*]] = call i32 @fn0(i32 [[TMP0]]) #[[ATTR3]]
; TUNIT-NEXT: store i32 [[CALL]], ptr [[P]], align 4
; TUNIT-NEXT: br label [[FOR_COND1]]
; TUNIT: exit:
; TUNIT-NEXT: ret void
Expand Down Expand Up @@ -116,11 +118,11 @@ exit:
}

define internal i32 @fn0(i32 %p1) {
; CGSCC: Function Attrs: nofree norecurse nosync nounwind willreturn memory(none)
; CGSCC-LABEL: define {{[^@]+}}@fn0
; CGSCC-SAME: (i32 returned [[P1:%.*]]) #[[ATTR1]] {
; CGSCC-NEXT: entry:
; CGSCC-NEXT: ret i32 [[P1]]
; CHECK: Function Attrs: nofree norecurse nosync nounwind willreturn memory(none)
; CHECK-LABEL: define {{[^@]+}}@fn0
; CHECK-SAME: (i32 returned [[P1:%.*]]) #[[ATTR1]] {
; CHECK-NEXT: entry:
; CHECK-NEXT: ret i32 [[P1]]
;
entry:
%tobool = icmp ne i32 %p1, 0
Expand All @@ -129,11 +131,11 @@ entry:
}
;.
; TUNIT: attributes #[[ATTR0]] = { nofree norecurse nosync nounwind memory(argmem: readwrite) }
; TUNIT: attributes #[[ATTR1]] = { nofree norecurse nosync nounwind null_pointer_is_valid }
; TUNIT: attributes #[[ATTR1]] = { nofree norecurse nosync nounwind willreturn memory(none) }
; TUNIT: attributes #[[ATTR2]] = { nofree norecurse nosync nounwind null_pointer_is_valid }
; TUNIT: attributes #[[ATTR3]] = { nofree nosync nounwind }
;.
; CGSCC: attributes #[[ATTR0]] = { nofree nosync nounwind memory(argmem: readwrite) }
; CGSCC: attributes #[[ATTR1]] = { nofree norecurse nosync nounwind willreturn memory(none) }
; CGSCC: attributes #[[ATTR2]] = { nofree nosync nounwind null_pointer_is_valid }
;.
;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
; CHECK: {{.*}}
4 changes: 2 additions & 2 deletions llvm/test/Transforms/Attributor/dereferenceable-1.ll
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-attributes --check-globals
; RUN: opt -aa-pipeline=basic-aa -passes=attributor -attributor-manifest-internal -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=14 -S < %s | FileCheck %s --check-prefixes=CHECK,TUNIT
; RUN: opt -aa-pipeline=basic-aa -passes=attributor -attributor-manifest-internal -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=6 -S < %s | FileCheck %s --check-prefixes=CHECK,TUNIT
; RUN: opt -aa-pipeline=basic-aa -passes=attributor-cgscc -attributor-manifest-internal -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,CGSCC
; FIXME: Figure out why we need 16 iterations here.

Expand Down Expand Up @@ -95,7 +95,7 @@ define void @deref_phi_growing(ptr dereferenceable(4000) %a) {
; CHECK: for.cond:
; CHECK-NEXT: [[I_0:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[INC:%.*]], [[FOR_INC:%.*]] ]
; CHECK-NEXT: [[A_ADDR_0:%.*]] = phi ptr [ [[A]], [[ENTRY]] ], [ [[INCDEC_PTR:%.*]], [[FOR_INC]] ]
; CHECK-NEXT: call void @deref_phi_user(ptr nonnull dereferenceable(4000) [[A_ADDR_0]])
; CHECK-NEXT: call void @deref_phi_user(ptr nonnull [[A_ADDR_0]])
; CHECK-NEXT: [[TMP:%.*]] = load i32, ptr [[A_ADDR_0]], align 4
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[I_0]], [[TMP]]
; CHECK-NEXT: br i1 [[CMP]], label [[FOR_BODY:%.*]], label [[FOR_COND_CLEANUP:%.*]]
Expand Down
39 changes: 32 additions & 7 deletions llvm/test/Transforms/Attributor/heap_to_stack.ll
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,17 @@ declare void @foo(i32* %p)
declare void @foo_nounw(i32* %p) nounwind nofree

declare void @usei8(i8)
declare void @usei8p(i8* nocapture)

declare i32 @no_return_call() noreturn

declare void @free(i8* nocapture) allockind("free")

declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture) nounwind

;.
; CHECK: @[[G:[a-zA-Z0-9_$"\\.-]+]] = internal global i8* undef, align 4
;.
define void @h2s_value_simplify_interaction(i1 %c, i8* %A) {
; CHECK-LABEL: define {{[^@]+}}@h2s_value_simplify_interaction
; CHECK-SAME: (i1 [[C:%.*]], i8* nocapture nofree readnone [[A:%.*]]) {
Expand All @@ -42,13 +46,13 @@ define void @h2s_value_simplify_interaction(i1 %c, i8* %A) {
; CHECK: f2:
; CHECK-NEXT: [[L:%.*]] = load i8, i8* [[M]], align 16
; CHECK-NEXT: call void @usei8(i8 [[L]])
; CHECK-NEXT: call void @no_sync_func(i8* nocapture nofree noundef align 16 [[M]]) #[[ATTR10:[0-9]+]]
; CHECK-NEXT: call void @no_sync_func(i8* nocapture nofree noundef align 16 [[M]]) #[[ATTR11:[0-9]+]]
; CHECK-NEXT: br label [[J]]
; CHECK: dead:
; CHECK-NEXT: unreachable
; CHECK: j:
; CHECK-NEXT: [[PHI:%.*]] = phi i8* [ [[M]], [[F]] ], [ null, [[F2]] ]
; CHECK-NEXT: tail call void @no_sync_func(i8* nocapture nofree noundef align 16 [[PHI]]) #[[ATTR10]]
; CHECK-NEXT: tail call void @no_sync_func(i8* nocapture nofree noundef align 16 [[PHI]]) #[[ATTR11]]
; CHECK-NEXT: ret void
;
entry:
Expand Down Expand Up @@ -328,7 +332,7 @@ define void @test9() {
; CHECK-NEXT: tail call void @no_sync_func(i8* nocapture nofree [[TMP1]])
; CHECK-NEXT: [[TMP2:%.*]] = bitcast i8* [[TMP1]] to i32*
; CHECK-NEXT: store i32 10, i32* [[TMP2]], align 4
; CHECK-NEXT: tail call void @foo_nounw(i32* nofree noundef align 4 [[TMP2]]) #[[ATTR10]]
; CHECK-NEXT: tail call void @foo_nounw(i32* nofree noundef align 4 [[TMP2]]) #[[ATTR11]]
; CHECK-NEXT: tail call void @free(i8* nocapture noundef nonnull align 4 dereferenceable(4) [[TMP1]])
; CHECK-NEXT: ret void
;
Expand Down Expand Up @@ -387,7 +391,7 @@ define i32 @test_lifetime() {
define void @test11() {
; CHECK-LABEL: define {{[^@]+}}@test11() {
; CHECK-NEXT: [[DOTH2S:%.*]] = alloca i8, i64 4, align 1
; CHECK-NEXT: tail call void @sync_will_return(i8* [[DOTH2S]]) #[[ATTR10]]
; CHECK-NEXT: tail call void @sync_will_return(i8* [[DOTH2S]]) #[[ATTR11]]
; CHECK-NEXT: ret void
;
%1 = tail call noalias i8* @malloc(i64 4)
Expand Down Expand Up @@ -628,7 +632,7 @@ define void @test16c(i8 %v, i8** %P) {
; CHECK-SAME: (i8 [[V:%.*]], i8** nocapture nofree writeonly [[P:%.*]]) {
; CHECK-NEXT: [[DOTH2S:%.*]] = alloca i8, i64 4, align 1
; CHECK-NEXT: store i8* [[DOTH2S]], i8** [[P]], align 8
; CHECK-NEXT: tail call void @no_sync_func(i8* nocapture nofree [[DOTH2S]]) #[[ATTR10]]
; CHECK-NEXT: tail call void @no_sync_func(i8* nocapture nofree [[DOTH2S]]) #[[ATTR11]]
; CHECK-NEXT: ret void
;
%1 = tail call noalias i8* @malloc(i64 4)
Expand All @@ -649,6 +653,25 @@ define void @test16d(i8 %v, i8** %P) {
store i8* %1, i8** %P
ret void
}

@G = internal global i8* undef, align 4
define void @test16e(i8 %v) norecurse {
; CHECK: Function Attrs: norecurse
; CHECK-LABEL: define {{[^@]+}}@test16e
; CHECK-SAME: (i8 [[V:%.*]]) #[[ATTR9:[0-9]+]] {
; CHECK-NEXT: [[DOTH2S:%.*]] = alloca i8, i64 4, align 1
; CHECK-NEXT: store i8* [[DOTH2S]], i8** @G, align 8
; CHECK-NEXT: call void @usei8p(i8* nocapture nofree [[DOTH2S]]) #[[ATTR12:[0-9]+]]
; CHECK-NEXT: ret void
;
%1 = tail call noalias i8* @malloc(i64 4)
store i8* %1, i8** @G
%2 = load i8*, i8** @G
call void @usei8p(i8* nofree nocapture %2) nocallback nosync willreturn nounwind
call void @free(i8* %1)
ret void
}

;.
; CHECK: attributes #[[ATTR0:[0-9]+]] = { allockind("alloc,uninitialized") allocsize(0) }
; CHECK: attributes #[[ATTR1:[0-9]+]] = { nounwind willreturn }
Expand All @@ -659,8 +682,10 @@ define void @test16d(i8 %v, i8** %P) {
; CHECK: attributes #[[ATTR6:[0-9]+]] = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
; CHECK: attributes #[[ATTR7:[0-9]+]] = { allockind("alloc,uninitialized,aligned") allocsize(1) }
; CHECK: attributes #[[ATTR8:[0-9]+]] = { allockind("alloc,zeroed") allocsize(0,1) }
; CHECK: attributes #[[ATTR9:[0-9]+]] = { nocallback nofree nounwind willreturn memory(argmem: write) }
; CHECK: attributes #[[ATTR10]] = { nounwind }
; CHECK: attributes #[[ATTR9]] = { norecurse }
; CHECK: attributes #[[ATTR10:[0-9]+]] = { nocallback nofree nounwind willreturn memory(argmem: write) }
; CHECK: attributes #[[ATTR11]] = { nounwind }
; CHECK: attributes #[[ATTR12]] = { nocallback nosync nounwind willreturn }
;.
;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
; CGSCC: {{.*}}
Expand Down
62 changes: 53 additions & 9 deletions llvm/test/Transforms/Attributor/heap_to_stack_gpu.ll
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-attributes --check-globals
; RUN: opt -opaque-pointers=0 -aa-pipeline=basic-aa -passes=attributor -attributor-manifest-internal -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=5 -S < %s | FileCheck %s --check-prefixes=CHECK,TUNIT
; RUN: opt -opaque-pointers=0 -aa-pipeline=basic-aa -passes=attributor -attributor-manifest-internal -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=3 -S < %s | FileCheck %s --check-prefixes=CHECK,TUNIT
; RUN: opt -opaque-pointers=0 -aa-pipeline=basic-aa -passes=attributor-cgscc -attributor-manifest-internal -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,CGSCC

; FIXME: amdgpu doesn't claim malloc is a thing, so the test is somewhat
Expand Down Expand Up @@ -34,6 +34,10 @@ declare void @free(i8* nocapture)

declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture) nounwind

;.
; CHECK: @[[G:[a-zA-Z0-9_$"\\.-]+]] = internal global i8* undef, align 4
; CHECK: @[[GTL:[a-zA-Z0-9_$"\\.-]+]] = internal thread_local global i8* undef, align 4
;.
define void @nofree_arg_only(i8* %p1, i8* %p2) {
; CHECK-LABEL: define {{[^@]+}}@nofree_arg_only
; CHECK-SAME: (i8* nocapture nofree [[P1:%.*]], i8* nocapture [[P2:%.*]]) {
Expand Down Expand Up @@ -277,7 +281,7 @@ define void @test9() {
; CHECK-NEXT: tail call void @no_sync_func(i8* nocapture nofree [[TMP1]])
; CHECK-NEXT: [[TMP2:%.*]] = bitcast i8* [[TMP1]] to i32*
; CHECK-NEXT: store i32 10, i32* [[TMP2]], align 4
; CHECK-NEXT: tail call void @foo_nounw(i32* nofree noundef align 4 [[TMP2]]) #[[ATTR5:[0-9]+]]
; CHECK-NEXT: tail call void @foo_nounw(i32* nofree noundef align 4 [[TMP2]]) #[[ATTR6:[0-9]+]]
; CHECK-NEXT: tail call void @free(i8* nocapture noundef nonnull align 4 dereferenceable(4) [[TMP1]])
; CHECK-NEXT: ret void
;
Expand Down Expand Up @@ -338,7 +342,7 @@ define i32 @test_lifetime() {
define void @test11() {
; CHECK-LABEL: define {{[^@]+}}@test11() {
; CHECK-NEXT: [[TMP1:%.*]] = tail call noalias i8* @malloc(i64 noundef 4)
; CHECK-NEXT: tail call void @sync_will_return(i8* [[TMP1]]) #[[ATTR5]]
; CHECK-NEXT: tail call void @sync_will_return(i8* [[TMP1]]) #[[ATTR6]]
; CHECK-NEXT: tail call void @free(i8* nocapture [[TMP1]])
; CHECK-NEXT: ret void
;
Expand Down Expand Up @@ -584,7 +588,7 @@ define void @test16c(i8 %v, i8** %P) {
; CHECK-SAME: (i8 [[V:%.*]], i8** nocapture nofree writeonly [[P:%.*]]) {
; CHECK-NEXT: [[TMP1:%.*]] = tail call noalias i8* @malloc(i64 noundef 4)
; CHECK-NEXT: store i8* [[TMP1]], i8** [[P]], align 8
; CHECK-NEXT: tail call void @no_sync_func(i8* nocapture nofree [[TMP1]]) #[[ATTR5]]
; CHECK-NEXT: tail call void @no_sync_func(i8* nocapture nofree [[TMP1]]) #[[ATTR6]]
; CHECK-NEXT: tail call void @free(i8* nocapture [[TMP1]])
; CHECK-NEXT: ret void
;
Expand Down Expand Up @@ -614,7 +618,7 @@ define void @test17() {
; CHECK-LABEL: define {{[^@]+}}@test17() {
; CHECK-NEXT: [[DOTH2S:%.*]] = alloca i8, i64 4, align 1, addrspace(5)
; CHECK-NEXT: [[MALLOC_CAST:%.*]] = addrspacecast i8 addrspace(5)* [[DOTH2S]] to i8*
; CHECK-NEXT: tail call void @usei8(i8* noalias nocapture nofree [[MALLOC_CAST]]) #[[ATTR6:[0-9]+]]
; CHECK-NEXT: tail call void @usei8(i8* noalias nocapture nofree [[MALLOC_CAST]]) #[[ATTR7:[0-9]+]]
; CHECK-NEXT: ret void
;
%1 = tail call noalias i8* @__kmpc_alloc_shared(i64 4)
Expand All @@ -626,7 +630,7 @@ define void @test17() {
define void @test17b() {
; CHECK-LABEL: define {{[^@]+}}@test17b() {
; CHECK-NEXT: [[TMP1:%.*]] = tail call noalias i8* @__kmpc_alloc_shared(i64 noundef 4)
; CHECK-NEXT: tail call void @usei8(i8* nofree [[TMP1]]) #[[ATTR6]]
; CHECK-NEXT: tail call void @usei8(i8* nofree [[TMP1]]) #[[ATTR7]]
; CHECK-NEXT: tail call void @__kmpc_free_shared(i8* nocapture [[TMP1]], i64 noundef 4)
; CHECK-NEXT: ret void
;
Expand All @@ -643,7 +647,7 @@ define void @move_alloca() {
; CHECK-NEXT: br label [[NOT_ENTRY:%.*]]
; CHECK: not_entry:
; CHECK-NEXT: [[MALLOC_CAST:%.*]] = addrspacecast i8 addrspace(5)* [[DOTH2S]] to i8*
; CHECK-NEXT: tail call void @usei8(i8* noalias nocapture nofree [[MALLOC_CAST]]) #[[ATTR6]]
; CHECK-NEXT: tail call void @usei8(i8* noalias nocapture nofree [[MALLOC_CAST]]) #[[ATTR7]]
; CHECK-NEXT: ret void
;
entry:
Expand All @@ -656,15 +660,55 @@ not_entry:
ret void
}

@G = internal global i8* undef, align 4
define void @test16e(i8 %v) norecurse {
; CHECK: Function Attrs: norecurse
; CHECK-LABEL: define {{[^@]+}}@test16e
; CHECK-SAME: (i8 [[V:%.*]]) #[[ATTR5:[0-9]+]] {
; CHECK-NEXT: [[TMP1:%.*]] = tail call noalias i8* @__kmpc_alloc_shared(i64 noundef 4)
; CHECK-NEXT: store i8* [[TMP1]], i8** @G, align 8
; CHECK-NEXT: call void @usei8(i8* nocapture nofree [[TMP1]]) #[[ATTR8:[0-9]+]]
; CHECK-NEXT: tail call void @__kmpc_free_shared(i8* noalias nocapture [[TMP1]], i64 noundef 4)
; CHECK-NEXT: ret void
;
%1 = tail call noalias i8* @__kmpc_alloc_shared(i64 4)
store i8* %1, i8** @G
%2 = load i8*, i8** @G
call void @usei8(i8* nofree nocapture %2) nocallback nosync willreturn nounwind
tail call void @__kmpc_free_shared(i8* %1, i64 4)
ret void
}

@Gtl = internal thread_local global i8* undef, align 4
define void @test16f(i8 %v) norecurse {
; CHECK: Function Attrs: norecurse
; CHECK-LABEL: define {{[^@]+}}@test16f
; CHECK-SAME: (i8 [[V:%.*]]) #[[ATTR5]] {
; CHECK-NEXT: [[DOTH2S:%.*]] = alloca i8, i64 4, align 1, addrspace(5)
; CHECK-NEXT: [[MALLOC_CAST:%.*]] = addrspacecast i8 addrspace(5)* [[DOTH2S]] to i8*
; CHECK-NEXT: store i8* [[MALLOC_CAST]], i8** @Gtl, align 8
; CHECK-NEXT: call void @usei8(i8* nocapture nofree [[MALLOC_CAST]]) #[[ATTR8]]
; CHECK-NEXT: ret void
;
%1 = tail call noalias i8* @__kmpc_alloc_shared(i64 4)
store i8* %1, i8** @Gtl
%2 = load i8*, i8** @Gtl
call void @usei8(i8* nofree nocapture %2) nocallback nosync willreturn nounwind
tail call void @__kmpc_free_shared(i8* %1, i64 4)
ret void
}


;.
; CHECK: attributes #[[ATTR0:[0-9]+]] = { nounwind willreturn }
; CHECK: attributes #[[ATTR1:[0-9]+]] = { nofree nosync willreturn }
; CHECK: attributes #[[ATTR2:[0-9]+]] = { nofree nounwind }
; CHECK: attributes #[[ATTR3]] = { noreturn }
; CHECK: attributes #[[ATTR4:[0-9]+]] = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
; CHECK: attributes #[[ATTR5]] = { nounwind }
; CHECK: attributes #[[ATTR6]] = { nosync nounwind willreturn }
; CHECK: attributes #[[ATTR5]] = { norecurse }
; CHECK: attributes #[[ATTR6]] = { nounwind }
; CHECK: attributes #[[ATTR7]] = { nosync nounwind willreturn }
; CHECK: attributes #[[ATTR8]] = { nocallback nosync nounwind willreturn }
;.
;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
; CGSCC: {{.*}}
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/Transforms/Attributor/liveness.ll
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-attributes --check-globals
; RUN: opt -opaque-pointers=0 -aa-pipeline=basic-aa -passes=attributor -attributor-manifest-internal -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=16 -S < %s | FileCheck %s --check-prefixes=CHECK,TUNIT
; RUN: opt -opaque-pointers=0 -aa-pipeline=basic-aa -passes=attributor -attributor-manifest-internal -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=9 -S < %s | FileCheck %s --check-prefixes=CHECK,TUNIT
; RUN: opt -opaque-pointers=0 -aa-pipeline=basic-aa -passes=attributor-cgscc -attributor-manifest-internal -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,CGSCC

; NOT_CGSCC___: @dead_with_blockaddress_users.l = constant [2 x i8*] [i8* inttoptr (i32 1 to i8*), i8* inttoptr (i32 1 to i8*)]
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/Transforms/Attributor/lvi-after-jumpthreading.ll
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-attributes --check-globals
; RUN: opt -aa-pipeline=basic-aa -passes=attributor -attributor-manifest-internal -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=13 -S < %s | FileCheck %s --check-prefixes=CHECK,TUNIT
; RUN: opt -aa-pipeline=basic-aa -passes=attributor -attributor-manifest-internal -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=6 -S < %s | FileCheck %s --check-prefixes=CHECK,TUNIT
; RUN: opt -aa-pipeline=basic-aa -passes=attributor-cgscc -attributor-manifest-internal -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,CGSCC

define i8 @test1(i32 %a, i32 %length) {
Expand Down
13 changes: 9 additions & 4 deletions llvm/test/Transforms/Attributor/nonnull.ll
Original file line number Diff line number Diff line change
Expand Up @@ -1495,10 +1495,15 @@ define ptr @nonnull_function_ptr_1() {

declare ptr @function_decl()
define ptr @nonnull_function_ptr_2() {
; CHECK: Function Attrs: nofree norecurse nosync nounwind willreturn memory(none)
; CHECK-LABEL: define {{[^@]+}}@nonnull_function_ptr_2
; CHECK-SAME: () #[[ATTR1]] {
; CHECK-NEXT: ret ptr @function_decl
; TUNIT: Function Attrs: nofree norecurse nosync nounwind willreturn memory(none)
; TUNIT-LABEL: define {{[^@]+}}@nonnull_function_ptr_2
; TUNIT-SAME: () #[[ATTR1]] {
; TUNIT-NEXT: ret ptr @function_decl
;
; CGSCC: Function Attrs: nofree norecurse nosync nounwind willreturn memory(none)
; CGSCC-LABEL: define {{[^@]+}}@nonnull_function_ptr_2
; CGSCC-SAME: () #[[ATTR1]] {
; CGSCC-NEXT: ret ptr @function_decl
;
ret ptr @function_decl
}
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/Transforms/Attributor/potential.ll
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-attributes --check-globals
; RUN: opt -aa-pipeline=basic-aa -passes=attributor -attributor-manifest-internal -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=13 -S < %s | FileCheck %s --check-prefixes=CHECK,TUNIT
; RUN: opt -aa-pipeline=basic-aa -passes=attributor -attributor-manifest-internal -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=6 -S < %s | FileCheck %s --check-prefixes=CHECK,TUNIT
; RUN: opt -aa-pipeline=basic-aa -passes=attributor-cgscc -attributor-manifest-internal -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,CGSCC
;
; Test for multiple potential values
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/Transforms/Attributor/range.ll
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-attributes --check-globals
; RUN: opt -aa-pipeline=basic-aa -passes=attributor -attributor-manifest-internal -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=14 -S < %s | FileCheck %s --check-prefixes=CHECK,TUNIT
; RUN: opt -aa-pipeline=basic-aa -passes=attributor -attributor-manifest-internal -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=12 -S < %s | FileCheck %s --check-prefixes=CHECK,TUNIT
; RUN: opt -aa-pipeline=basic-aa -passes=attributor-cgscc -attributor-manifest-internal -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,CGSCC

; FIXME: CGSCC is not looking at callees and calleers even though it could be allowed.
Expand Down
36 changes: 36 additions & 0 deletions llvm/test/Transforms/Attributor/reduced/openmp_opt_global_read.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --scrub-attributes --check-attributes --check-globals --include-generated-funcs
; RUN: opt -passes=openmp-opt -S < %s | FileCheck %s --check-prefixes=CHECK

@IsSPMDMode = internal addrspace(3) global i32 undef

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: readwrite)
declare void @llvm.assume(i1 noundef) #0

define weak_odr amdgpu_kernel void @__omp_offloading_16_2e1d69__ZN11qmcplusplus7ompBLAS9gemv_implIfEEiRiciiT_PKS3_iS5_iS3_PS3_i_l44() {
bb:
%i36 = load i32, ptr addrspace(3) @IsSPMDMode, align 4
%i37 = icmp eq i32 %i36, 0
tail call void @llvm.assume(i1 %i37)
ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: readwrite) }

!llvm.module.flags = !{!0, !1}

!0 = !{i32 7, !"openmp", i32 50}
!1 = !{i32 7, !"openmp-device", i32 50}
;.
; CHECK: @[[ISSPMDMODE:[a-zA-Z0-9_$"\\.-]+]] = internal addrspace(3) global i32 undef
;.
; CHECK-LABEL: define {{[^@]+}}@__omp_offloading_16_2e1d69__ZN11qmcplusplus7ompBLAS9gemv_implIfEEiRiciiT_PKS3_iS5_iS3_PS3_i_l44() {
; CHECK-NEXT: bb:
; CHECK-NEXT: tail call void @llvm.assume(i1 true)
; CHECK-NEXT: ret void
;
;.
; CHECK: attributes #[[ATTR0:[0-9]+]] = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: readwrite) }
;.
; CHECK: [[META0:![0-9]+]] = !{i32 7, !"openmp", i32 50}
; CHECK: [[META1:![0-9]+]] = !{i32 7, !"openmp-device", i32 50}
;.
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --scrub-attributes --check-attributes --check-globals --include-generated-funcs
; RUN: opt -passes=openmp-opt -S < %s | FileCheck %s --check-prefixes=CHECK

@_ZN4ompx5state9TeamStateE = internal addrspace(3) global ptr undef

define internal fastcc i1 @__kmpc_kernel_parallel() {
bb:
%i = load ptr, ptr addrspace(3) @_ZN4ompx5state9TeamStateE, align 16
%i1 = icmp eq ptr %i, null
ret i1 %i1
}

define weak_odr amdgpu_kernel void @__omp_offloading_16_2e1d69__ZN11qmcplusplus7ompBLAS9gemv_implIfEEiRiciiT_PKS3_iS5_iS3_PS3_i_l44() #1 {
bb:
call void @barrier()
%i31 = call fastcc i1 @__kmpc_kernel_parallel()
call void @barrier()
store ptr @use, ptr addrspace(3) @_ZN4ompx5state9TeamStateE, align 16
call void @barrier()
store ptr null, ptr addrspace(3) @_ZN4ompx5state9TeamStateE, align 16
call void @barrier()
call void @use(i1 %i31)
ret void
}

declare void @use(i1)
declare void @barrier() nocallback

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "kernel" }

!llvm.module.flags = !{!0, !1}

!0 = !{i32 7, !"openmp", i32 50}
!1 = !{i32 7, !"openmp-device", i32 50}
;.
; CHECK: @[[_ZN4OMPX5STATE9TEAMSTATEE:[a-zA-Z0-9_$"\\.-]+]] = internal addrspace(3) global ptr undef
;.
; CHECK: Function Attrs: norecurse nosync nounwind memory(read)
; CHECK-LABEL: define {{[^@]+}}@__kmpc_kernel_parallel
; CHECK-SAME: () #[[ATTR0:[0-9]+]] {
; CHECK-NEXT: bb:
; CHECK-NEXT: [[I:%.*]] = load ptr, ptr addrspace(3) @_ZN4ompx5state9TeamStateE, align 16
; CHECK-NEXT: [[I1:%.*]] = icmp eq ptr [[I]], null
; CHECK-NEXT: ret i1 [[I1]]
;
;
; CHECK-LABEL: define {{[^@]+}}@__omp_offloading_16_2e1d69__ZN11qmcplusplus7ompBLAS9gemv_implIfEEiRiciiT_PKS3_iS5_iS3_PS3_i_l44
; CHECK-SAME: () #[[ATTR1:[0-9]+]] {
; CHECK-NEXT: bb:
; CHECK-NEXT: call void @barrier()
; CHECK-NEXT: [[I31:%.*]] = call fastcc i1 @__kmpc_kernel_parallel()
; CHECK-NEXT: call void @barrier()
; CHECK-NEXT: store ptr @use, ptr addrspace(3) @_ZN4ompx5state9TeamStateE, align 16
; CHECK-NEXT: call void @barrier()
; CHECK-NEXT: store ptr null, ptr addrspace(3) @_ZN4ompx5state9TeamStateE, align 16
; CHECK-NEXT: call void @barrier()
; CHECK-NEXT: call void @use(i1 [[I31]])
; CHECK-NEXT: ret void
;
;.
; CHECK: attributes #[[ATTR0]] = { norecurse nosync nounwind memory(read) }
; CHECK: attributes #[[ATTR1]] = { "kernel" }
; CHECK: attributes #[[ATTR2:[0-9]+]] = { nocallback }
; CHECK: attributes #[[ATTR3:[0-9]+]] = { nosync nounwind }
;.
; CHECK: [[META0:![0-9]+]] = !{i32 7, !"openmp", i32 50}
; CHECK: [[META1:![0-9]+]] = !{i32 7, !"openmp-device", i32 50}
;.
86 changes: 78 additions & 8 deletions llvm/test/Transforms/Attributor/value-simplify-instances.ll
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ define internal i1 @recursive_inst_generator(i1 %c, ptr %p) {
; TUNIT-NEXT: [[A:%.*]] = call ptr @geti1Ptr()
; TUNIT-NEXT: br i1 [[C]], label [[T:%.*]], label [[F:%.*]]
; TUNIT: t:
; TUNIT-NEXT: [[R1:%.*]] = call i1 @recursive_inst_comparator(ptr noalias nofree readnone [[A]], ptr noalias nofree readnone [[P]]) #[[ATTR6:[0-9]+]]
; TUNIT-NEXT: [[R1:%.*]] = call i1 @recursive_inst_comparator(ptr noalias nofree readnone [[A]], ptr noalias nofree readnone [[P]]) #[[ATTR7:[0-9]+]]
; TUNIT-NEXT: ret i1 [[R1]]
; TUNIT: f:
; TUNIT-NEXT: [[R2:%.*]] = call i1 @recursive_inst_generator(i1 noundef true, ptr nofree [[A]])
Expand Down Expand Up @@ -148,7 +148,7 @@ define i1 @recursive_alloca_compare_caller(i1 %c) {
; CGSCC: Function Attrs: nofree nosync nounwind memory(none)
; CGSCC-LABEL: define {{[^@]+}}@recursive_alloca_compare_caller
; CGSCC-SAME: (i1 noundef [[C:%.*]]) #[[ATTR1]] {
; CGSCC-NEXT: [[CALL:%.*]] = call i1 @recursive_alloca_compare(i1 noundef [[C]], ptr undef) #[[ATTR4:[0-9]+]]
; CGSCC-NEXT: [[CALL:%.*]] = call i1 @recursive_alloca_compare(i1 noundef [[C]], ptr undef) #[[ATTR5:[0-9]+]]
; CGSCC-NEXT: ret i1 [[CALL]]
;
%call = call i1 @recursive_alloca_compare(i1 %c, ptr undef)
Expand Down Expand Up @@ -207,7 +207,7 @@ define i8 @recursive_alloca_load_return_caller(i1 %c) {
; CGSCC: Function Attrs: nofree nosync nounwind memory(none)
; CGSCC-LABEL: define {{[^@]+}}@recursive_alloca_load_return_caller
; CGSCC-SAME: (i1 noundef [[C:%.*]]) #[[ATTR1]] {
; CGSCC-NEXT: [[CALL:%.*]] = call i8 @recursive_alloca_load_return(i1 noundef [[C]], ptr undef, i8 noundef 42) #[[ATTR4]]
; CGSCC-NEXT: [[CALL:%.*]] = call i8 @recursive_alloca_load_return(i1 noundef [[C]], ptr undef, i8 noundef 42) #[[ATTR5]]
; CGSCC-NEXT: ret i8 [[CALL]]
;
%call = call i8 @recursive_alloca_load_return(i1 %c, ptr undef, i8 42)
Expand Down Expand Up @@ -271,7 +271,7 @@ define i1 @recursive_alloca_compare_caller_global1(i1 %c) {
; CGSCC: Function Attrs: nofree nosync nounwind
; CGSCC-LABEL: define {{[^@]+}}@recursive_alloca_compare_caller_global1
; CGSCC-SAME: (i1 noundef [[C:%.*]]) #[[ATTR3]] {
; CGSCC-NEXT: [[CALL:%.*]] = call i1 @recursive_alloca_compare_global1(i1 noundef [[C]]) #[[ATTR4]]
; CGSCC-NEXT: [[CALL:%.*]] = call i1 @recursive_alloca_compare_global1(i1 noundef [[C]]) #[[ATTR5]]
; CGSCC-NEXT: ret i1 [[CALL]]
;
%call = call i1 @recursive_alloca_compare_global1(i1 %c)
Expand Down Expand Up @@ -330,7 +330,7 @@ define i1 @recursive_alloca_compare_caller_global2(i1 %c) {
; CGSCC: Function Attrs: nofree nosync nounwind
; CGSCC-LABEL: define {{[^@]+}}@recursive_alloca_compare_caller_global2
; CGSCC-SAME: (i1 noundef [[C:%.*]]) #[[ATTR3]] {
; CGSCC-NEXT: [[CALL:%.*]] = call i1 @recursive_alloca_compare_global2(i1 noundef [[C]]) #[[ATTR4]]
; CGSCC-NEXT: [[CALL:%.*]] = call i1 @recursive_alloca_compare_global2(i1 noundef [[C]]) #[[ATTR5]]
; CGSCC-NEXT: ret i1 [[CALL]]
;
%call = call i1 @recursive_alloca_compare_global2(i1 %c)
Expand Down Expand Up @@ -386,24 +386,94 @@ define i1 @recursive_inst_compare_caller_global3(i1 %c) {
; CGSCC: Function Attrs: nofree nosync nounwind
; CGSCC-LABEL: define {{[^@]+}}@recursive_inst_compare_caller_global3
; CGSCC-SAME: (i1 noundef [[C:%.*]]) #[[ATTR3]] {
; CGSCC-NEXT: [[CALL:%.*]] = call i1 @recursive_inst_compare_global3(i1 noundef [[C]]) #[[ATTR4]]
; CGSCC-NEXT: [[CALL:%.*]] = call i1 @recursive_inst_compare_global3(i1 noundef [[C]]) #[[ATTR5]]
; CGSCC-NEXT: ret i1 [[CALL]]
;
%call = call i1 @recursive_inst_compare_global3(i1 %c)
ret i1 %call
}

define i32 @non_unique_phi_ops(ptr %ptr) {
; TUNIT: Function Attrs: nofree norecurse nosync nounwind willreturn memory(argmem: read)
; TUNIT-LABEL: define {{[^@]+}}@non_unique_phi_ops
; TUNIT-SAME: (ptr nocapture nofree readonly [[PTR:%.*]]) #[[ATTR6:[0-9]+]] {
; TUNIT-NEXT: entry:
; TUNIT-NEXT: br label [[HEADER:%.*]]
; TUNIT: header:
; TUNIT-NEXT: [[I:%.*]] = phi i32 [ [[ADD:%.*]], [[F:%.*]] ], [ 0, [[ENTRY:%.*]] ]
; TUNIT-NEXT: [[P:%.*]] = phi i32 [ [[NON_UNIQUE:%.*]], [[F]] ], [ poison, [[ENTRY]] ]
; TUNIT-NEXT: [[ADD]] = add i32 [[I]], 1
; TUNIT-NEXT: [[G:%.*]] = getelementptr i32, ptr [[PTR]], i32 [[I]]
; TUNIT-NEXT: [[NON_UNIQUE_INPUT:%.*]] = load i32, ptr [[G]], align 4
; TUNIT-NEXT: [[CMP1:%.*]] = icmp eq i32 [[I]], [[NON_UNIQUE_INPUT]]
; TUNIT-NEXT: br i1 [[CMP1]], label [[T:%.*]], label [[F]]
; TUNIT: t:
; TUNIT-NEXT: br label [[F]]
; TUNIT: f:
; TUNIT-NEXT: [[NON_UNIQUE]] = phi i32 [ [[NON_UNIQUE_INPUT]], [[T]] ], [ [[P]], [[HEADER]] ]
; TUNIT-NEXT: [[CMP2:%.*]] = icmp slt i32 [[I]], 42
; TUNIT-NEXT: br i1 [[CMP2]], label [[HEADER]], label [[END:%.*]]
; TUNIT: end:
; TUNIT-NEXT: ret i32 [[P]]
;
; CGSCC: Function Attrs: nofree norecurse nosync nounwind willreturn memory(argmem: read)
; CGSCC-LABEL: define {{[^@]+}}@non_unique_phi_ops
; CGSCC-SAME: (ptr nocapture nofree readonly [[PTR:%.*]]) #[[ATTR4:[0-9]+]] {
; CGSCC-NEXT: entry:
; CGSCC-NEXT: br label [[HEADER:%.*]]
; CGSCC: header:
; CGSCC-NEXT: [[I:%.*]] = phi i32 [ [[ADD:%.*]], [[F:%.*]] ], [ 0, [[ENTRY:%.*]] ]
; CGSCC-NEXT: [[P:%.*]] = phi i32 [ [[NON_UNIQUE:%.*]], [[F]] ], [ poison, [[ENTRY]] ]
; CGSCC-NEXT: [[ADD]] = add i32 [[I]], 1
; CGSCC-NEXT: [[G:%.*]] = getelementptr i32, ptr [[PTR]], i32 [[I]]
; CGSCC-NEXT: [[NON_UNIQUE_INPUT:%.*]] = load i32, ptr [[G]], align 4
; CGSCC-NEXT: [[CMP1:%.*]] = icmp eq i32 [[I]], [[NON_UNIQUE_INPUT]]
; CGSCC-NEXT: br i1 [[CMP1]], label [[T:%.*]], label [[F]]
; CGSCC: t:
; CGSCC-NEXT: br label [[F]]
; CGSCC: f:
; CGSCC-NEXT: [[NON_UNIQUE]] = phi i32 [ [[NON_UNIQUE_INPUT]], [[T]] ], [ [[P]], [[HEADER]] ]
; CGSCC-NEXT: [[CMP2:%.*]] = icmp slt i32 [[I]], 42
; CGSCC-NEXT: br i1 [[CMP2]], label [[HEADER]], label [[END:%.*]]
; CGSCC: end:
; CGSCC-NEXT: ret i32 [[P]]
;
entry:
br label %header

header:
%i = phi i32 [ %add, %f ], [ 0, %entry ]
%p = phi i32 [ %non_unique, %f ], [ poison, %entry ]
%add = add i32 %i, 1
%g = getelementptr i32, ptr %ptr, i32 %i
%non_unique_input = load i32, ptr %g, align 4
%cmp1 = icmp eq i32 %i, %non_unique_input
br i1 %cmp1, label %t, label %f
t:
br label %f
f:
%non_unique = phi i32 [ %non_unique_input, %t ], [ %p, %header ]
%cmp2 = icmp slt i32 %i, 42
br i1 %cmp2, label %header, label %end

end:
ret i32 %p
}

;.
; TUNIT: attributes #[[ATTR0]] = { nofree norecurse nosync nounwind willreturn memory(none) }
; TUNIT: attributes #[[ATTR1]] = { nofree nosync nounwind memory(none) }
; TUNIT: attributes #[[ATTR2]] = { nofree norecurse nosync nounwind memory(none) }
; TUNIT: attributes #[[ATTR3]] = { nofree nosync nounwind memory(argmem: readwrite) }
; TUNIT: attributes #[[ATTR4]] = { nofree nosync nounwind }
; TUNIT: attributes #[[ATTR5]] = { nofree norecurse nosync nounwind }
; TUNIT: attributes #[[ATTR6]] = { nounwind }
; TUNIT: attributes #[[ATTR6]] = { nofree norecurse nosync nounwind willreturn memory(argmem: read) }
; TUNIT: attributes #[[ATTR7]] = { nounwind }
;.
; CGSCC: attributes #[[ATTR0]] = { nofree norecurse nosync nounwind willreturn memory(none) }
; CGSCC: attributes #[[ATTR1]] = { nofree nosync nounwind memory(none) }
; CGSCC: attributes #[[ATTR2]] = { nofree nosync nounwind memory(argmem: readwrite) }
; CGSCC: attributes #[[ATTR3]] = { nofree nosync nounwind }
; CGSCC: attributes #[[ATTR4]] = { nounwind }
; CGSCC: attributes #[[ATTR4]] = { nofree norecurse nosync nounwind willreturn memory(argmem: read) }
; CGSCC: attributes #[[ATTR5]] = { nounwind }
;.
10 changes: 5 additions & 5 deletions llvm/test/Transforms/Attributor/value-simplify-pointer-info.ll
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-attributes --check-globals
; RUN: opt -aa-pipeline=basic-aa -passes=attributor -attributor-manifest-internal -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=22 -S < %s | FileCheck %s --check-prefixes=CHECK,TUNIT
; RUN: opt -aa-pipeline=basic-aa -passes=attributor -attributor-manifest-internal -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=14 -S < %s | FileCheck %s --check-prefixes=CHECK,TUNIT
; RUN: opt -aa-pipeline=basic-aa -passes=attributor-cgscc -attributor-manifest-internal -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,CGSCC
;
%struct.S = type { i32, i32, i32, float, float, float }
Expand Down Expand Up @@ -2112,7 +2112,7 @@ define i8 @phi_no_store_2() {
; TUNIT: loop:
; TUNIT-NEXT: [[P:%.*]] = phi ptr [ @a2, [[ENTRY:%.*]] ], [ [[G:%.*]], [[LOOP]] ]
; TUNIT-NEXT: [[I:%.*]] = phi i8 [ 0, [[ENTRY]] ], [ [[O:%.*]], [[LOOP]] ]
; TUNIT-NEXT: store i8 1, ptr [[P]], align 2
; TUNIT-NEXT: store i8 1, ptr [[P]], align 1
; TUNIT-NEXT: [[G]] = getelementptr i8, ptr @a2, i64 2
; TUNIT-NEXT: [[O]] = add nsw i8 [[I]], 1
; TUNIT-NEXT: [[C:%.*]] = icmp eq i8 [[O]], 7
Expand All @@ -2133,7 +2133,7 @@ define i8 @phi_no_store_2() {
; CGSCC: loop:
; CGSCC-NEXT: [[P:%.*]] = phi ptr [ @a2, [[ENTRY:%.*]] ], [ [[G:%.*]], [[LOOP]] ]
; CGSCC-NEXT: [[I:%.*]] = phi i8 [ 0, [[ENTRY]] ], [ [[O:%.*]], [[LOOP]] ]
; CGSCC-NEXT: store i8 1, ptr [[P]], align 2
; CGSCC-NEXT: store i8 1, ptr [[P]], align 1
; CGSCC-NEXT: [[G]] = getelementptr i8, ptr @a2, i64 2
; CGSCC-NEXT: [[O]] = add nsw i8 [[I]], 1
; CGSCC-NEXT: [[C:%.*]] = icmp eq i8 [[O]], 7
Expand Down Expand Up @@ -2176,7 +2176,7 @@ define i8 @phi_no_store_3() {
; TUNIT: loop:
; TUNIT-NEXT: [[P:%.*]] = phi ptr [ @a3, [[ENTRY:%.*]] ], [ [[G:%.*]], [[LOOP]] ]
; TUNIT-NEXT: [[I:%.*]] = phi i8 [ 0, [[ENTRY]] ], [ [[O:%.*]], [[LOOP]] ]
; TUNIT-NEXT: store i8 1, ptr [[P]], align 2
; TUNIT-NEXT: store i8 1, ptr [[P]], align 1
; TUNIT-NEXT: [[G]] = getelementptr i8, ptr @a3, i64 2
; TUNIT-NEXT: [[O]] = add nsw i8 [[I]], 1
; TUNIT-NEXT: [[C:%.*]] = icmp eq i8 [[O]], 7
Expand All @@ -2202,7 +2202,7 @@ define i8 @phi_no_store_3() {
; CGSCC: loop:
; CGSCC-NEXT: [[P:%.*]] = phi ptr [ @a3, [[ENTRY:%.*]] ], [ [[G:%.*]], [[LOOP]] ]
; CGSCC-NEXT: [[I:%.*]] = phi i8 [ 0, [[ENTRY]] ], [ [[O:%.*]], [[LOOP]] ]
; CGSCC-NEXT: store i8 1, ptr [[P]], align 2
; CGSCC-NEXT: store i8 1, ptr [[P]], align 1
; CGSCC-NEXT: [[G]] = getelementptr i8, ptr @a3, i64 2
; CGSCC-NEXT: [[O]] = add nsw i8 [[I]], 1
; CGSCC-NEXT: [[C:%.*]] = icmp eq i8 [[O]], 7
Expand Down
8 changes: 4 additions & 4 deletions llvm/test/Transforms/Attributor/willreturn.ll
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-attributes --check-globals
; RUN: opt -opaque-pointers=0 -aa-pipeline=basic-aa -passes=attributor -attributor-manifest-internal -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=14 -S < %s | FileCheck %s --check-prefixes=CHECK,TUNIT
; RUN: opt -opaque-pointers=0 -aa-pipeline=basic-aa -passes=attributor -attributor-manifest-internal -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=7 -S < %s | FileCheck %s --check-prefixes=CHECK,TUNIT
; RUN: opt -opaque-pointers=0 -aa-pipeline=basic-aa -passes=attributor-cgscc -attributor-manifest-internal -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,CGSCC

target datalayout = "e-m:e-i54:64-f80:128-n8:16:32:64-S128"
Expand Down Expand Up @@ -854,7 +854,7 @@ define i32 @bounded_nested_loops(i32 %n) {
; CHECK-NEXT: [[INC1]] = add nuw nsw i32 [[I_0]], 1
; CHECK-NEXT: br label [[FOR_COND]]
; CHECK: for.end:
; CHECK-NEXT: ret i32 [[ANS_0_LCSSA]]
; CHECK-NEXT: ret i32 [[ANS_0]]
;
entry:
br label %for.cond
Expand Down Expand Up @@ -933,7 +933,7 @@ define i32 @bounded_loop_inside_unbounded_loop(i32 %n) {
; CHECK-NEXT: br label [[WHILE_COND]]
; CHECK: while.end:
; CHECK-NEXT: [[ANS_0_LCSSA:%.*]] = phi i32 [ [[ANS_0]], [[WHILE_COND]] ]
; CHECK-NEXT: ret i32 [[ANS_0_LCSSA]]
; CHECK-NEXT: ret i32 [[ANS_0]]
;
entry:
br label %while.cond
Expand Down Expand Up @@ -1016,7 +1016,7 @@ define i32 @nested_unbounded_loops(i32 %n) {
; CHECK-NEXT: br label [[WHILE_COND]]
; CHECK: while.end11:
; CHECK-NEXT: [[ANS_0_LCSSA:%.*]] = phi i32 [ [[ANS_0]], [[WHILE_COND]] ]
; CHECK-NEXT: ret i32 [[ANS_0_LCSSA]]
; CHECK-NEXT: ret i32 [[ANS_0]]
;
entry:
br label %while.cond
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/Transforms/OpenMP/attributor_recursion_crash.ll
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ define weak amdgpu_kernel void @k() {
; CHECK-NEXT: [[PRE1:%.*]] = phi ptr [ [[DOTPRE158_I]], [[BB3]] ], [ null, [[BB2]] ]
; CHECK-NEXT: br i1 false, label [[BB6]], label [[BB5:%.*]]
; CHECK: BB5:
; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds [[STRUCT_TS:%.*]], ptr [[PRE1]], i64 0, i32 1
; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds [[STRUCT_TS:%.*]], ptr [[DOTPRE158_I]], i64 0, i32 1
; CHECK-NEXT: [[Q3:%.*]] = load ptr, ptr [[GEP]], align 8
; CHECK-NEXT: br label [[BB6]]
; CHECK: BB6:
Expand Down
53 changes: 42 additions & 11 deletions llvm/test/Transforms/OpenMP/barrier_removal.ll
Original file line number Diff line number Diff line change
Expand Up @@ -632,16 +632,11 @@ m:
}

define internal void @write_then_barrier0(i32* %p) {
; MODULE-LABEL: define {{[^@]+}}@write_then_barrier0
; MODULE-SAME: (ptr [[P:%.*]]) {
; MODULE-NEXT: store i32 0, ptr [[P]], align 4
; MODULE-NEXT: ret void
;
; CGSCC-LABEL: define {{[^@]+}}@write_then_barrier0
; CGSCC-SAME: (ptr [[P:%.*]]) {
; CGSCC-NEXT: store i32 0, ptr [[P]], align 4
; CGSCC-NEXT: call void @aligned_barrier()
; CGSCC-NEXT: ret void
; CHECK-LABEL: define {{[^@]+}}@write_then_barrier0
; CHECK-SAME: (ptr [[P:%.*]]) {
; CHECK-NEXT: store i32 0, ptr [[P]], align 4
; CHECK-NEXT: call void @aligned_barrier()
; CHECK-NEXT: ret void
;
store i32 0, i32* %p
call void @aligned_barrier()
Expand Down Expand Up @@ -980,8 +975,40 @@ m3:
ret void
}

; Verify we do not remove the barrier in the callee.
define internal void @callee_barrier() {
; CHECK-LABEL: define {{[^@]+}}@callee_barrier() {
; CHECK-NEXT: call void @aligned_barrier()
; CHECK-NEXT: ret void
;
call void @aligned_barrier()
ret void
}
define void @caller_barrier1() {
; CHECK-LABEL: define {{[^@]+}}@caller_barrier1() {
; CHECK-NEXT: call void @callee_barrier()
; CHECK-NEXT: ret void
;
call void @aligned_barrier()
call void @callee_barrier()
call void @aligned_barrier()
ret void
}
define void @caller_barrier2() {
; CHECK-LABEL: define {{[^@]+}}@caller_barrier2() {
; CHECK-NEXT: call void @unknown()
; CHECK-NEXT: call void @callee_barrier()
; CHECK-NEXT: call void @unknown()
; CHECK-NEXT: ret void
;
call void @unknown()
call void @callee_barrier()
call void @unknown()
ret void
}

!llvm.module.flags = !{!16,!15}
!nvvm.annotations = !{!0,!1,!2,!3,!4,!5,!6,!7,!8,!9,!10,!11,!12,!13,!14,!17,!18,!19,!20,!21,!22,!23}
!nvvm.annotations = !{!0,!1,!2,!3,!4,!5,!6,!7,!8,!9,!10,!11,!12,!13,!14,!17,!18,!19,!20,!21,!22,!23,!24,!25}

!0 = !{void ()* @pos_empty_1, !"kernel", i32 1}
!1 = !{void ()* @pos_empty_2, !"kernel", i32 1}
Expand All @@ -992,6 +1019,8 @@ m3:
!17 = !{void ()* @pos_empty_7a, !"kernel", i32 1}
!18 = !{void ()* @pos_empty_7b, !"kernel", i32 1}
!23 = !{void (i1)* @pos_empty_8, !"kernel", i32 1}
!24 = !{void ()* @caller_barrier1, !"kernel", i32 1}
!25 = !{void ()* @caller_barrier2, !"kernel", i32 1}
!6 = !{void ()* @neg_empty_8, !"kernel", i32 1}
!19 = !{void (i1)* @neg_empty_9, !"kernel", i32 1}
!20 = !{void ()* @pos_empty_10, !"kernel", i32 1}
Expand Down Expand Up @@ -1038,4 +1067,6 @@ m3:
; CHECK: [[META21:![0-9]+]] = !{ptr @pos_empty_11, !"kernel", i32 1}
; CHECK: [[META22:![0-9]+]] = !{ptr @neg_empty_12, !"kernel", i32 1}
; CHECK: [[META23:![0-9]+]] = !{ptr @pos_empty_8, !"kernel", i32 1}
; CHECK: [[META24:![0-9]+]] = !{ptr @caller_barrier1, !"kernel", i32 1}
; CHECK: [[META25:![0-9]+]] = !{ptr @caller_barrier2, !"kernel", i32 1}
;.
1 change: 1 addition & 0 deletions llvm/test/Transforms/OpenMP/value-simplify-openmp-opt.ll
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ define void @kernel() "kernel" {
; CHECK: if.else:
; CHECK-NEXT: call void @barrier() #[[ATTR6:[0-9]+]]
; CHECK-NEXT: call void @use1(i32 undef) #[[ATTR6]]
; CHECK-NEXT: call void @llvm.assume(i1 true)
; CHECK-NEXT: call void @barrier() #[[ATTR6]]
; CHECK-NEXT: br label [[IF_MERGE]]
; CHECK: if.merge:
Expand Down