1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-attributes --check-globals
2 ; RUN: opt -passes=attributor -S %s | FileCheck %s
4 @var1 = internal global [1 x i32] undef
5 @var2 = internal global i32 0
8 ; CHECK: @var1 = internal global [1 x i32] undef
9 ; CHECK: @var2 = internal global i32 0
11 define ptr addrspace(1) @foo(ptr addrspace(4) %arg) {
12 ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
13 ; CHECK-LABEL: define {{[^@]+}}@foo
14 ; CHECK-SAME: (ptr addrspace(4) nofree readnone [[ARG:%.*]]) #[[ATTR0:[0-9]+]] {
16 ; CHECK-NEXT: [[TMP0:%.*]] = addrspacecast ptr addrspace(4) [[ARG]] to ptr addrspace(1)
17 ; CHECK-NEXT: ret ptr addrspace(1) [[TMP0]]
20 %0 = addrspacecast ptr addrspace(4) %arg to ptr addrspace(1)
21 ret ptr addrspace(1) %0
25 ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
26 ; CHECK-LABEL: define {{[^@]+}}@func1
27 ; CHECK-SAME: () #[[ATTR0]] {
28 ; CHECK-NEXT: ret ptr @var1
30 %ptr = call ptr @func1a(ptr @var1)
34 define internal ptr @func1a(ptr %arg) {
38 define internal void @func2a(ptr %0) {
39 ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(write)
40 ; CHECK-LABEL: define {{[^@]+}}@func2a
41 ; CHECK-SAME: (ptr nocapture nofree nonnull writeonly align 4 dereferenceable(4) [[TMP0:%.*]]) #[[ATTR1:[0-9]+]] {
42 ; CHECK-NEXT: ret void
49 ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(write)
50 ; CHECK-LABEL: define {{[^@]+}}@func2
51 ; CHECK-SAME: () #[[ATTR1]] {
52 ; CHECK-NEXT: [[TMP1:%.*]] = tail call i32 (ptr, ...) @func2a(ptr nocapture nofree nonnull writeonly align 4 dereferenceable(4) undef) #[[ATTR3:[0-9]+]]
53 ; CHECK-NEXT: ret i32 0
55 %1 = tail call i32 (ptr, ...) @func2a(ptr @var2)
56 %2 = load i32, ptr @var2
60 define i32 @func3(i1 %false) {
61 ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(write)
62 ; CHECK-LABEL: define {{[^@]+}}@func3
63 ; CHECK-SAME: (i1 [[FALSE:%.*]]) #[[ATTR1]] {
64 ; CHECK-NEXT: [[TMP1:%.*]] = tail call i32 (ptr, ...) @func2a(ptr nocapture nofree nonnull writeonly align 4 dereferenceable(4) undef) #[[ATTR3]]
65 ; CHECK-NEXT: br i1 [[FALSE]], label [[USE_BB:%.*]], label [[RET_BB:%.*]]
67 ; CHECK-NEXT: ret i32 [[TMP1]]
69 ; CHECK-NEXT: ret i32 0
71 %1 = tail call i32 (ptr, ...) @func2a(ptr @var2)
72 br i1 %false, label %use_bb, label %ret_bb
76 %2 = load i32, ptr @var2
80 define void @func4() {
81 ; CHECK-LABEL: define {{[^@]+}}@func4() {
82 ; CHECK-NEXT: call void @func5()
83 ; CHECK-NEXT: ret void
85 call void @func5(i32 0)
89 define internal void @func5(i32 %0) {
90 ; CHECK: Function Attrs: memory(readwrite, argmem: none)
91 ; CHECK-LABEL: define {{[^@]+}}@func5
92 ; CHECK-SAME: () #[[ATTR2:[0-9]+]] {
93 ; CHECK-NEXT: br label [[BLOCK:%.*]]
95 ; CHECK-NEXT: call void @func6(ptr blockaddress(@func5, [[BLOCK]]))
96 ; CHECK-NEXT: ret void
102 store ptr blockaddress(@func5, %block), ptr %tmp
103 %addr = load ptr, ptr %tmp
104 call void @func6(ptr %addr)
109 ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
110 ; CHECK-LABEL: define {{[^@]+}}@foo3
111 ; CHECK-SAME: () #[[ATTR0]] {
112 ; CHECK-NEXT: [[CALL:%.*]] = call i16 @bar3() #[[ATTR4:[0-9]+]]
113 ; CHECK-NEXT: ret i16 [[CALL]]
115 %call = call i16 @bar3()
118 define internal i16 @bar3(ptr %p1, i16 %p2) {
119 ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
120 ; CHECK-LABEL: define {{[^@]+}}@bar3
121 ; CHECK-SAME: (ptr nocapture nofree readnone [[P1:%.*]], i16 returned [[P2:%.*]]) #[[ATTR0]] {
122 ; CHECK-NEXT: ret i16 [[P2]]
127 declare void @func6(ptr)
129 ; CHECK: attributes #[[ATTR0]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }
130 ; CHECK: attributes #[[ATTR1]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(write) }
131 ; CHECK: attributes #[[ATTR2]] = { memory(readwrite, argmem: none) }
132 ; CHECK: attributes #[[ATTR3]] = { nofree nosync nounwind willreturn memory(write) }
133 ; CHECK: attributes #[[ATTR4]] = { nofree nosync nounwind willreturn memory(none) }