1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-attributes --check-globals
2 ; RUN: opt -aa-pipeline=basic-aa -passes=attributor -attributor-manifest-internal -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,TUNIT
3 ; RUN: opt -aa-pipeline=basic-aa -passes=attributor-cgscc -attributor-manifest-internal -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,CGSCC
4 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
5 target triple = "amdgcn-amd-amdhsa"
7 @G = external dso_local addrspace(4) global i32, align 4
9 declare ptr @ptr() memory(none)
10 declare ptr addrspace(4) @ptr_to_const() memory(none)
11 declare ptr addrspace(3) @ptr_to_shared() memory(none)
13 ; Should be memory(none)
15 ; CHECK: @G = external dso_local addrspace(4) global i32, align 4
17 define i32 @test_const_as_global1() {
18 ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
19 ; CHECK-LABEL: define {{[^@]+}}@test_const_as_global1
20 ; CHECK-SAME: () #[[ATTR1:[0-9]+]] {
21 ; CHECK-NEXT: [[L1:%.*]] = load i32, ptr addrspace(4) @G, align 4
22 ; CHECK-NEXT: ret i32 [[L1]]
24 %l1 = load i32, ptr addrspace(4) @G
27 ; Should be memory(none)
28 define i32 @test_const_as_global2() {
29 ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
30 ; CHECK-LABEL: define {{[^@]+}}@test_const_as_global2
31 ; CHECK-SAME: () #[[ATTR1]] {
32 ; CHECK-NEXT: [[L2:%.*]] = load i32, ptr addrspace(4) @G, align 4
33 ; CHECK-NEXT: ret i32 [[L2]]
35 %l2 = load i32, ptr addrspacecast (ptr addrspace(4) @G to ptr)
38 ; Should be memory(none)
39 define i32 @test_const_as_call1() {
40 ; CHECK: Function Attrs: nosync memory(read)
41 ; CHECK-LABEL: define {{[^@]+}}@test_const_as_call1
42 ; CHECK-SAME: () #[[ATTR2:[0-9]+]] {
43 ; CHECK-NEXT: [[P1:%.*]] = call ptr addrspace(4) @ptr_to_const() #[[ATTR4:[0-9]+]]
44 ; CHECK-NEXT: [[L1:%.*]] = load i32, ptr addrspace(4) [[P1]], align 4
45 ; CHECK-NEXT: ret i32 [[L1]]
47 %p1 = call ptr addrspace(4) @ptr_to_const()
48 %c1 = addrspacecast ptr addrspace(4) %p1 to ptr
49 %l1 = load i32, ptr %c1
52 ; Should be memory(none)
53 define i32 @test_const_as_call2() {
54 ; CHECK: Function Attrs: nosync memory(none)
55 ; CHECK-LABEL: define {{[^@]+}}@test_const_as_call2
56 ; CHECK-SAME: () #[[ATTR3:[0-9]+]] {
57 ; CHECK-NEXT: [[P2:%.*]] = call ptr @ptr() #[[ATTR4]]
58 ; CHECK-NEXT: [[C2:%.*]] = addrspacecast ptr [[P2]] to ptr addrspace(4)
59 ; CHECK-NEXT: [[L2:%.*]] = load i32, ptr addrspace(4) [[C2]], align 4
60 ; CHECK-NEXT: ret i32 [[L2]]
63 %c2 = addrspacecast ptr %p2 to ptr addrspace(4)
64 %l2 = load i32, ptr addrspace(4) %c2
68 ; Should be memory(read)
69 define i32 @test_shared_as_call1() {
70 ; CHECK: Function Attrs: nosync memory(read)
71 ; CHECK-LABEL: define {{[^@]+}}@test_shared_as_call1
72 ; CHECK-SAME: () #[[ATTR2]] {
73 ; CHECK-NEXT: [[P1:%.*]] = call ptr addrspace(3) @ptr_to_shared() #[[ATTR4]]
74 ; CHECK-NEXT: [[L1:%.*]] = load i32, ptr addrspace(3) [[P1]], align 4
75 ; CHECK-NEXT: ret i32 [[L1]]
77 %p1 = call ptr addrspace(3) @ptr_to_shared()
78 %c1 = addrspacecast ptr addrspace(3) %p1 to ptr
79 %l1 = load i32, ptr %c1
82 ; Should be memory(read)
83 define i32 @test_shared_as_call2() {
84 ; CHECK: Function Attrs: nosync memory(read)
85 ; CHECK-LABEL: define {{[^@]+}}@test_shared_as_call2
86 ; CHECK-SAME: () #[[ATTR2]] {
87 ; CHECK-NEXT: [[P2:%.*]] = call ptr @ptr() #[[ATTR4]]
88 ; CHECK-NEXT: [[C2:%.*]] = addrspacecast ptr [[P2]] to ptr addrspace(3)
89 ; CHECK-NEXT: [[L2:%.*]] = load i32, ptr addrspace(3) [[C2]], align 4
90 ; CHECK-NEXT: ret i32 [[L2]]
93 %c2 = addrspacecast ptr %p2 to ptr addrspace(3)
94 %l2 = load i32, ptr addrspace(3) %c2
98 ; CHECK: attributes #[[ATTR0:[0-9]+]] = { memory(none) }
99 ; CHECK: attributes #[[ATTR1]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }
100 ; CHECK: attributes #[[ATTR2]] = { nosync memory(read) }
101 ; CHECK: attributes #[[ATTR3]] = { nosync memory(none) }
102 ; CHECK: attributes #[[ATTR4]] = { nosync }
104 ;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line: