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
5 define i32 @defined() convergent {
6 ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
7 ; CHECK-LABEL: define {{[^@]+}}@defined
8 ; CHECK-SAME: () #[[ATTR0:[0-9]+]] {
9 ; CHECK-NEXT: ret i32 1
14 define i32 @calls_defined() convergent {
15 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
16 ; TUNIT-LABEL: define {{[^@]+}}@calls_defined
17 ; TUNIT-SAME: () #[[ATTR0]] {
18 ; TUNIT-NEXT: ret i32 1
20 ; CGSCC: Function Attrs: convergent mustprogress nofree nosync nounwind willreturn memory(none)
21 ; CGSCC-LABEL: define {{[^@]+}}@calls_defined
22 ; CGSCC-SAME: () #[[ATTR1:[0-9]+]] {
23 ; CGSCC-NEXT: [[A:%.*]] = call noundef i32 @defined() #[[ATTR6:[0-9]+]]
24 ; CGSCC-NEXT: ret i32 [[A]]
26 %a = call i32 @defined()
30 declare void @declared_non_convergent()
32 define void @calls_declared_non_convergent() convergent {
33 ; CHECK-LABEL: define {{[^@]+}}@calls_declared_non_convergent() {
34 ; CHECK-NEXT: call void @declared_non_convergent()
35 ; CHECK-NEXT: ret void
37 call void @declared_non_convergent()
41 ; CHECK: Function Attrs: convergent
42 ; CHECK-NEXT: declare i32 @declared_convergent()
43 declare i32 @declared_convergent() convergent
45 define i32 @calls_declared_convergent() convergent {
46 ; TUNIT: Function Attrs: convergent
47 ; TUNIT-LABEL: define {{[^@]+}}@calls_declared_convergent
48 ; TUNIT-SAME: () #[[ATTR1:[0-9]+]] {
49 ; TUNIT-NEXT: [[A:%.*]] = call i32 @declared_convergent()
50 ; TUNIT-NEXT: ret i32 [[A]]
52 ; CGSCC: Function Attrs: convergent
53 ; CGSCC-LABEL: define {{[^@]+}}@calls_declared_convergent
54 ; CGSCC-SAME: () #[[ATTR2:[0-9]+]] {
55 ; CGSCC-NEXT: [[A:%.*]] = call i32 @declared_convergent()
56 ; CGSCC-NEXT: ret i32 [[A]]
58 %a = call i32 @declared_convergent()
62 define i32 @defined_with_asm(i32 %a, i32 %b) {
63 ; CHECK-LABEL: define {{[^@]+}}@defined_with_asm
64 ; CHECK-SAME: (i32 [[A:%.*]], i32 [[B:%.*]]) {
65 ; CHECK-NEXT: [[RESULT:%.*]] = add i32 [[A]], [[B]]
66 ; CHECK-NEXT: [[ASM_RESULT:%.*]] = call i32 asm sideeffect "addl $1, $0", "=r,r"(i32 [[RESULT]])
67 ; CHECK-NEXT: ret i32 [[ASM_RESULT]]
69 %result = add i32 %a, %b
70 %asm_result = call i32 asm sideeffect "addl $1, $0", "=r,r"(i32 %result)
74 define i32 @calls_defined_with_asm(i32 %a, i32 %b) convergent {
75 ; TUNIT: Function Attrs: convergent
76 ; TUNIT-LABEL: define {{[^@]+}}@calls_defined_with_asm
77 ; TUNIT-SAME: (i32 [[A:%.*]], i32 [[B:%.*]]) #[[ATTR1]] {
78 ; TUNIT-NEXT: [[C:%.*]] = call i32 @defined_with_asm(i32 [[A]], i32 [[B]])
79 ; TUNIT-NEXT: ret i32 [[C]]
81 ; CGSCC: Function Attrs: convergent
82 ; CGSCC-LABEL: define {{[^@]+}}@calls_defined_with_asm
83 ; CGSCC-SAME: (i32 [[A:%.*]], i32 [[B:%.*]]) #[[ATTR2]] {
84 ; CGSCC-NEXT: [[C:%.*]] = call i32 @defined_with_asm(i32 [[A]], i32 [[B]])
85 ; CGSCC-NEXT: ret i32 [[C]]
87 %c = call i32 @defined_with_asm(i32 %a, i32 %b)
91 declare void @llvm.convergent.copy.p0i8.p0i8.i64(ptr %dest, ptr %src, i64 %size, i1 %isVolatile) #0
93 define void @calls_convergent_intrinsic(ptr %dest, ptr %src, i64 %size) convergent {
94 ; TUNIT: Function Attrs: convergent mustprogress nofree nosync nounwind willreturn memory(argmem: readwrite)
95 ; TUNIT-LABEL: define {{[^@]+}}@calls_convergent_intrinsic
96 ; TUNIT-SAME: (ptr nofree [[DEST:%.*]], ptr nofree [[SRC:%.*]], i64 [[SIZE:%.*]]) #[[ATTR3:[0-9]+]] {
97 ; TUNIT-NEXT: call void @llvm.convergent.copy.p0i8.p0i8.i64(ptr nofree [[DEST]], ptr nofree [[SRC]], i64 [[SIZE]], i1 noundef false) #[[ATTR5:[0-9]+]]
98 ; TUNIT-NEXT: ret void
100 ; CGSCC: Function Attrs: convergent mustprogress nofree nosync nounwind willreturn memory(argmem: readwrite)
101 ; CGSCC-LABEL: define {{[^@]+}}@calls_convergent_intrinsic
102 ; CGSCC-SAME: (ptr nofree [[DEST:%.*]], ptr nofree [[SRC:%.*]], i64 [[SIZE:%.*]]) #[[ATTR4:[0-9]+]] {
103 ; CGSCC-NEXT: call void @llvm.convergent.copy.p0i8.p0i8.i64(ptr nofree [[DEST]], ptr nofree [[SRC]], i64 [[SIZE]], i1 noundef false) #[[ATTR7:[0-9]+]]
104 ; CGSCC-NEXT: ret void
106 call void @llvm.convergent.copy.p0i8.p0i8.i64(ptr %dest, ptr %src, i64 %size, i1 false)
110 declare void @llvm.memcpy.p0i8.p0i8.i64(ptr %dest, ptr %src, i64 %size, i1 %isVolatile) #0
112 define void @calls_intrinsic(ptr %dest, ptr %src, i64 %size) convergent {
113 ; TUNIT: Function Attrs: convergent mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite)
114 ; TUNIT-LABEL: define {{[^@]+}}@calls_intrinsic
115 ; TUNIT-SAME: (ptr nocapture nofree writeonly [[DEST:%.*]], ptr nocapture nofree readonly [[SRC:%.*]], i64 [[SIZE:%.*]]) #[[ATTR2:[0-9]+]] {
116 ; TUNIT-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr nocapture nofree writeonly [[DEST]], ptr nocapture nofree readonly [[SRC]], i64 [[SIZE]], i1 noundef false) #[[ATTR5]]
117 ; TUNIT-NEXT: ret void
119 ; CGSCC: Function Attrs: convergent mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite)
120 ; CGSCC-LABEL: define {{[^@]+}}@calls_intrinsic
121 ; CGSCC-SAME: (ptr nocapture nofree writeonly [[DEST:%.*]], ptr nocapture nofree readonly [[SRC:%.*]], i64 [[SIZE:%.*]]) #[[ATTR3:[0-9]+]] {
122 ; CGSCC-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr nocapture nofree writeonly [[DEST]], ptr nocapture nofree readonly [[SRC]], i64 [[SIZE]], i1 noundef false) #[[ATTR7]]
123 ; CGSCC-NEXT: ret void
125 call void @llvm.memcpy.p0i8.p0i8.i64(ptr %dest, ptr %src, i64 %size, i1 false)
129 attributes #0 = { convergent mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) }
132 ; TUNIT: attributes #[[ATTR0]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }
133 ; TUNIT: attributes #[[ATTR1]] = { convergent }
134 ; TUNIT: attributes #[[ATTR2]] = { convergent mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) }
135 ; TUNIT: attributes #[[ATTR3]] = { convergent mustprogress nofree nosync nounwind willreturn memory(argmem: readwrite) }
136 ; TUNIT: attributes #[[ATTR4:[0-9]+]] = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
137 ; TUNIT: attributes #[[ATTR5]] = { nofree willreturn }
139 ; CGSCC: attributes #[[ATTR0]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }
140 ; CGSCC: attributes #[[ATTR1]] = { convergent mustprogress nofree nosync nounwind willreturn memory(none) }
141 ; CGSCC: attributes #[[ATTR2]] = { convergent }
142 ; CGSCC: attributes #[[ATTR3]] = { convergent mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) }
143 ; CGSCC: attributes #[[ATTR4]] = { convergent mustprogress nofree nosync nounwind willreturn memory(argmem: readwrite) }
144 ; CGSCC: attributes #[[ATTR5:[0-9]+]] = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
145 ; CGSCC: attributes #[[ATTR6]] = { nofree nosync willreturn }
146 ; CGSCC: attributes #[[ATTR7]] = { nofree willreturn }