1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-attributes --check-globals --prefix-filecheck-ir-name true
2 ; RUN: opt -mtriple=amdgcn-amd-amdhsa -aa-pipeline=basic-aa -passes=attributor -attributor-manifest-internal -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefix=CHECK
4 ; REQUIRES: amdgpu-registered-target
6 @dst = dso_local addrspace(1) externally_initialized global i32 0, align 4
7 @g1 = dso_local addrspace(1) externally_initialized global ptr null, align 4
8 @g2 = dso_local addrspace(1) externally_initialized global i32 0, align 4
9 @s1 = dso_local addrspace(3) global i32 undef, align 4
10 @s2 = dso_local addrspace(3) global i32 undef, align 4
13 ; CHECK: @dst = dso_local addrspace(1) externally_initialized global i32 0, align 4
14 ; CHECK: @g1 = dso_local addrspace(1) externally_initialized global ptr null, align 4
15 ; CHECK: @g2 = dso_local addrspace(1) externally_initialized global i32 0, align 4
16 ; CHECK: @s1 = dso_local addrspace(3) global i32 undef, align 4
17 ; CHECK: @s2 = dso_local addrspace(3) global i32 undef, align 4
19 define internal void @_Z12global_writePi(ptr noundef %p) #0 {
20 ; CHECK: Function Attrs: mustprogress nofree noinline norecurse nosync nounwind willreturn memory(write)
21 ; CHECK-LABEL: define {{[^@]+}}@_Z12global_writePi
22 ; CHECK-SAME: (ptr nofree noundef nonnull writeonly align 4 dereferenceable(8) [[P:%.*]]) #[[ATTR0:[0-9]+]] {
24 ; CHECK-NEXT: [[TMP0:%.*]] = addrspacecast ptr [[P]] to ptr addrspace(1)
25 ; CHECK-NEXT: store ptr [[P]], ptr addrspace(1) [[TMP0]], align 4
26 ; CHECK-NEXT: ret void
29 store ptr %p, ptr %p, align 4
33 ; Function Attrs: convergent mustprogress noinline nounwind
34 define internal void @_Z13unknown_writePi(ptr noundef %p) #0 {
35 ; CHECK: Function Attrs: mustprogress nofree noinline norecurse nosync nounwind willreturn memory(write)
36 ; CHECK-LABEL: define {{[^@]+}}@_Z13unknown_writePi
37 ; CHECK-SAME: (ptr nocapture nofree noundef nonnull writeonly align 4 dereferenceable(4) [[P:%.*]]) #[[ATTR0]] {
39 ; CHECK-NEXT: store i32 2, ptr [[P]], align 4
40 ; CHECK-NEXT: ret void
43 store i32 2, ptr %p, align 4
47 ; Function Attrs: convergent mustprogress noinline nounwind
48 define internal void @_Z12shared_writePi(ptr noundef %p) #0 {
49 ; CHECK: Function Attrs: mustprogress nofree noinline norecurse nosync nounwind willreturn memory(write)
50 ; CHECK-LABEL: define {{[^@]+}}@_Z12shared_writePi
51 ; CHECK-SAME: (ptr nocapture nofree noundef nonnull writeonly align 4 dereferenceable(4) [[P:%.*]]) #[[ATTR0]] {
53 ; CHECK-NEXT: [[TMP0:%.*]] = addrspacecast ptr [[P]] to ptr addrspace(3)
54 ; CHECK-NEXT: store i32 3, ptr addrspace(3) [[TMP0]], align 4
55 ; CHECK-NEXT: ret void
58 store i32 3, ptr %p, align 4
62 ; Function Attrs: convergent mustprogress noinline nounwind
63 define internal void @_Z11global_readPi(ptr noundef %p) #0 {
64 ; CHECK: Function Attrs: mustprogress nofree noinline norecurse nosync nounwind willreturn
65 ; CHECK-LABEL: define {{[^@]+}}@_Z11global_readPi
66 ; CHECK-SAME: (ptr nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[P:%.*]]) #[[ATTR1:[0-9]+]] {
68 ; CHECK-NEXT: [[TMP0:%.*]] = addrspacecast ptr [[P]] to ptr addrspace(1)
69 ; CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr addrspace(1) [[TMP0]], align 4
70 ; CHECK-NEXT: store i32 [[TMP1]], ptr addrspace(1) @dst, align 4
71 ; CHECK-NEXT: ret void
74 %0 = load i32, ptr %p, align 4
75 store i32 %0, ptr addrspacecast (ptr addrspace(1) @dst to ptr), align 4
79 ; Function Attrs: convergent mustprogress noinline nounwind
80 define internal void @_Z12unknown_readPi(ptr noundef %p) #0 {
81 ; CHECK: Function Attrs: mustprogress nofree noinline norecurse nosync nounwind willreturn
82 ; CHECK-LABEL: define {{[^@]+}}@_Z12unknown_readPi
83 ; CHECK-SAME: (ptr nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[P:%.*]]) #[[ATTR1]] {
85 ; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[P]], align 4
86 ; CHECK-NEXT: store i32 [[TMP0]], ptr addrspace(1) @dst, align 4
87 ; CHECK-NEXT: ret void
90 %0 = load i32, ptr %p, align 4
91 store i32 %0, ptr addrspacecast (ptr addrspace(1) @dst to ptr), align 4
95 ; Function Attrs: convergent mustprogress noinline nounwind
96 define internal void @_Z11shared_readPi(ptr noundef %p) #0 {
97 ; CHECK: Function Attrs: mustprogress nofree noinline norecurse nosync nounwind willreturn
98 ; CHECK-LABEL: define {{[^@]+}}@_Z11shared_readPi
99 ; CHECK-SAME: (ptr nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[P:%.*]]) #[[ATTR1]] {
101 ; CHECK-NEXT: [[TMP0:%.*]] = addrspacecast ptr [[P]] to ptr addrspace(3)
102 ; CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr addrspace(3) [[TMP0]], align 4
103 ; CHECK-NEXT: store i32 [[TMP1]], ptr addrspace(1) @dst, align 4
104 ; CHECK-NEXT: ret void
107 %0 = load i32, ptr %p, align 4
108 store i32 %0, ptr addrspacecast (ptr addrspace(1) @dst to ptr), align 4
112 ; Function Attrs: convergent mustprogress noinline nounwind
113 define dso_local void @_Z3bazv() #0 {
114 ; CHECK: Function Attrs: mustprogress nofree noinline norecurse nosync nounwind willreturn
115 ; CHECK-LABEL: define {{[^@]+}}@_Z3bazv
116 ; CHECK-SAME: () #[[ATTR1]] {
118 ; CHECK-NEXT: call void @_Z12global_writePi(ptr nofree noundef nonnull writeonly align 4 dereferenceable(8) addrspacecast (ptr addrspace(1) @g1 to ptr)) #[[ATTR2:[0-9]+]]
119 ; CHECK-NEXT: call void @_Z12global_writePi(ptr nofree noundef nonnull writeonly align 4 dereferenceable(4) addrspacecast (ptr addrspace(1) @g2 to ptr)) #[[ATTR2]]
120 ; CHECK-NEXT: call void @_Z13unknown_writePi(ptr nocapture nofree noundef nonnull writeonly align 4 dereferenceable(8) addrspacecast (ptr addrspace(1) @g1 to ptr)) #[[ATTR2]]
121 ; CHECK-NEXT: call void @_Z13unknown_writePi(ptr nocapture nofree noundef nonnull writeonly align 4 dereferenceable(4) addrspacecast (ptr addrspace(3) @s1 to ptr)) #[[ATTR2]]
122 ; CHECK-NEXT: call void @_Z12shared_writePi(ptr nocapture nofree noundef nonnull writeonly align 4 dereferenceable(4) addrspacecast (ptr addrspace(3) @s1 to ptr)) #[[ATTR2]]
123 ; CHECK-NEXT: call void @_Z12shared_writePi(ptr nocapture nofree noundef nonnull writeonly align 4 dereferenceable(4) addrspacecast (ptr addrspace(3) @s2 to ptr)) #[[ATTR2]]
124 ; CHECK-NEXT: call void @_Z11global_readPi(ptr nocapture nofree noundef nonnull readonly align 4 dereferenceable(8) addrspacecast (ptr addrspace(1) @g1 to ptr)) #[[ATTR3:[0-9]+]]
125 ; CHECK-NEXT: call void @_Z11global_readPi(ptr nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) addrspacecast (ptr addrspace(1) @g2 to ptr)) #[[ATTR3]]
126 ; CHECK-NEXT: call void @_Z12unknown_readPi(ptr nocapture nofree noundef nonnull readonly align 4 dereferenceable(8) addrspacecast (ptr addrspace(1) @g1 to ptr)) #[[ATTR3]]
127 ; CHECK-NEXT: call void @_Z12unknown_readPi(ptr nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) addrspacecast (ptr addrspace(3) @s1 to ptr)) #[[ATTR3]]
128 ; CHECK-NEXT: call void @_Z11shared_readPi(ptr nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) addrspacecast (ptr addrspace(3) @s1 to ptr)) #[[ATTR3]]
129 ; CHECK-NEXT: call void @_Z11shared_readPi(ptr nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) addrspacecast (ptr addrspace(3) @s2 to ptr)) #[[ATTR3]]
130 ; CHECK-NEXT: ret void
133 call void @_Z12global_writePi(ptr noundef addrspacecast (ptr addrspace(1) @g1 to ptr)) #1
134 call void @_Z12global_writePi(ptr noundef addrspacecast (ptr addrspace(1) @g2 to ptr)) #1
135 call void @_Z13unknown_writePi(ptr noundef addrspacecast (ptr addrspace(1) @g1 to ptr)) #1
136 call void @_Z13unknown_writePi(ptr noundef addrspacecast (ptr addrspace(3) @s1 to ptr)) #1
137 call void @_Z12shared_writePi(ptr noundef addrspacecast (ptr addrspace(3) @s1 to ptr)) #1
138 call void @_Z12shared_writePi(ptr noundef addrspacecast (ptr addrspace(3) @s2 to ptr)) #1
139 call void @_Z11global_readPi(ptr noundef addrspacecast (ptr addrspace(1) @g1 to ptr)) #1
140 call void @_Z11global_readPi(ptr noundef addrspacecast (ptr addrspace(1) @g2 to ptr)) #1
141 call void @_Z12unknown_readPi(ptr noundef addrspacecast (ptr addrspace(1) @g1 to ptr)) #1
142 call void @_Z12unknown_readPi(ptr noundef addrspacecast (ptr addrspace(3) @s1 to ptr)) #1
143 call void @_Z11shared_readPi(ptr noundef addrspacecast (ptr addrspace(3) @s1 to ptr)) #1
144 call void @_Z11shared_readPi(ptr noundef addrspacecast (ptr addrspace(3) @s2 to ptr)) #1
148 attributes #0 = { convergent mustprogress noinline nounwind }
149 attributes #1 = { convergent nounwind }
151 ; CHECK: attributes #[[ATTR0]] = { mustprogress nofree noinline norecurse nosync nounwind willreturn memory(write) }
152 ; CHECK: attributes #[[ATTR1]] = { mustprogress nofree noinline norecurse nosync nounwind willreturn }
153 ; CHECK: attributes #[[ATTR2]] = { convergent nofree nosync nounwind willreturn memory(write) }
154 ; CHECK: attributes #[[ATTR3]] = { convergent nofree nosync nounwind willreturn }