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:[a-zA-Z0-9_$"\\.-]+]] = 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: [[L2:%.*]] = load i32, ptr [[P2]], align 4
59 ; CHECK-NEXT: ret i32 [[L2]]
62 %c2 = addrspacecast ptr %p2 to ptr addrspace(4)
63 %l2 = load i32, ptr addrspace(4) %c2
67 ; Should be memory(read)
68 define i32 @test_shared_as_call1() {
69 ; CHECK: Function Attrs: nosync memory(read)
70 ; CHECK-LABEL: define {{[^@]+}}@test_shared_as_call1
71 ; CHECK-SAME: () #[[ATTR2]] {
72 ; CHECK-NEXT: [[P1:%.*]] = call ptr addrspace(3) @ptr_to_shared() #[[ATTR4]]
73 ; CHECK-NEXT: [[L1:%.*]] = load i32, ptr addrspace(3) [[P1]], align 4
74 ; CHECK-NEXT: ret i32 [[L1]]
76 %p1 = call ptr addrspace(3) @ptr_to_shared()
77 %c1 = addrspacecast ptr addrspace(3) %p1 to ptr
78 %l1 = load i32, ptr %c1
81 ; Should be memory(read)
82 define i32 @test_shared_as_call2() {
83 ; CHECK: Function Attrs: nosync memory(read)
84 ; CHECK-LABEL: define {{[^@]+}}@test_shared_as_call2
85 ; CHECK-SAME: () #[[ATTR2]] {
86 ; CHECK-NEXT: [[P2:%.*]] = call ptr @ptr() #[[ATTR4]]
87 ; CHECK-NEXT: [[L2:%.*]] = load i32, ptr [[P2]], align 4
88 ; CHECK-NEXT: ret i32 [[L2]]
91 %c2 = addrspacecast ptr %p2 to ptr addrspace(3)
92 %l2 = load i32, ptr addrspace(3) %c2
96 ; CHECK: attributes #[[ATTR0:[0-9]+]] = { memory(none) }
97 ; CHECK: attributes #[[ATTR1]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }
98 ; CHECK: attributes #[[ATTR2]] = { nosync memory(read) }
99 ; CHECK: attributes #[[ATTR3]] = { nosync memory(none) }
100 ; CHECK: attributes #[[ATTR4]] = { nosync }
102 ;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line: