1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-attributes --check-globals
2 ; RUN: opt -attributor -enable-new-pm=0 -attributor-manifest-internal -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=4 -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_CGSCC_NPM,NOT_CGSCC_OPM,NOT_TUNIT_NPM,IS__TUNIT____,IS________OPM,IS__TUNIT_OPM
3 ; RUN: opt -aa-pipeline=basic-aa -passes=attributor -attributor-manifest-internal -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=4 -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_CGSCC_OPM,NOT_CGSCC_NPM,NOT_TUNIT_OPM,IS__TUNIT____,IS________NPM,IS__TUNIT_NPM
4 ; RUN: opt -attributor-cgscc -enable-new-pm=0 -attributor-manifest-internal -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_TUNIT_NPM,NOT_TUNIT_OPM,NOT_CGSCC_NPM,IS__CGSCC____,IS________OPM,IS__CGSCC_OPM
5 ; RUN: opt -aa-pipeline=basic-aa -passes=attributor-cgscc -attributor-manifest-internal -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_TUNIT_NPM,NOT_TUNIT_OPM,NOT_CGSCC_OPM,IS__CGSCC____,IS________NPM,IS__CGSCC_NPM
8 ; /---------------------------------------|
9 ; | /----------------------|----|
12 ; void broker(int (*cb0)(int), int (*cb1)(int), int (*cb2)(int), int, int);
14 ; static int cb0(int zero) {
17 ; static int cb1(int unknown) {
20 ; static int cb2(int unknown) {
24 ; static int cb3(int unknown) {
27 ; static int cb4(int unknown) {
34 ; broker(cb0, cb1, cb0, 0, 1);
35 ; broker(cb1, cb2, cb2, 0, 1);
36 ; broker(cb3, cb2, cb3, 0, 1);
37 ; broker(cb4, cb4, cb4, 0, 1);
40 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
42 define internal i32 @cb0(i32 %zero) {
43 ; IS__TUNIT____: Function Attrs: nofree nosync nounwind readnone willreturn
44 ; IS__TUNIT____-LABEL: define {{[^@]+}}@cb0
45 ; IS__TUNIT____-SAME: (i32 [[ZERO:%.*]]) #[[ATTR0:[0-9]+]] {
46 ; IS__TUNIT____-NEXT: entry:
47 ; IS__TUNIT____-NEXT: ret i32 0
49 ; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
50 ; IS__CGSCC____-LABEL: define {{[^@]+}}@cb0
51 ; IS__CGSCC____-SAME: (i32 [[ZERO:%.*]]) #[[ATTR0:[0-9]+]] {
52 ; IS__CGSCC____-NEXT: entry:
53 ; IS__CGSCC____-NEXT: ret i32 0
59 define internal i32 @cb1(i32 %unknown) {
60 ; IS__TUNIT____: Function Attrs: nofree nosync nounwind readnone willreturn
61 ; IS__TUNIT____-LABEL: define {{[^@]+}}@cb1
62 ; IS__TUNIT____-SAME: (i32 noundef returned [[UNKNOWN:%.*]]) #[[ATTR0]] {
63 ; IS__TUNIT____-NEXT: entry:
64 ; IS__TUNIT____-NEXT: ret i32 [[UNKNOWN]]
66 ; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
67 ; IS__CGSCC____-LABEL: define {{[^@]+}}@cb1
68 ; IS__CGSCC____-SAME: (i32 noundef returned [[UNKNOWN:%.*]]) #[[ATTR0]] {
69 ; IS__CGSCC____-NEXT: entry:
70 ; IS__CGSCC____-NEXT: ret i32 [[UNKNOWN]]
76 define internal i32 @cb2(i32 %unknown) {
77 ; IS__TUNIT____: Function Attrs: nofree nosync nounwind readnone willreturn
78 ; IS__TUNIT____-LABEL: define {{[^@]+}}@cb2
79 ; IS__TUNIT____-SAME: (i32 noundef returned [[UNKNOWN:%.*]]) #[[ATTR0]] {
80 ; IS__TUNIT____-NEXT: entry:
81 ; IS__TUNIT____-NEXT: ret i32 [[UNKNOWN]]
83 ; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
84 ; IS__CGSCC____-LABEL: define {{[^@]+}}@cb2
85 ; IS__CGSCC____-SAME: (i32 noundef returned [[UNKNOWN:%.*]]) #[[ATTR0]] {
86 ; IS__CGSCC____-NEXT: entry:
87 ; IS__CGSCC____-NEXT: ret i32 [[UNKNOWN]]
90 %call = call i32 @cb0(i32 0)
94 define internal i32 @cb3(i32 %unknown) {
95 ; IS__TUNIT____: Function Attrs: nofree nosync nounwind readnone willreturn
96 ; IS__TUNIT____-LABEL: define {{[^@]+}}@cb3
97 ; IS__TUNIT____-SAME: (i32 noundef returned [[UNKNOWN:%.*]]) #[[ATTR0]] {
98 ; IS__TUNIT____-NEXT: entry:
99 ; IS__TUNIT____-NEXT: ret i32 [[UNKNOWN]]
101 ; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
102 ; IS__CGSCC____-LABEL: define {{[^@]+}}@cb3
103 ; IS__CGSCC____-SAME: (i32 noundef returned [[UNKNOWN:%.*]]) #[[ATTR0]] {
104 ; IS__CGSCC____-NEXT: entry:
105 ; IS__CGSCC____-NEXT: ret i32 [[UNKNOWN]]
111 define internal i32 @cb4(i32 %unknown) {
112 ; IS__TUNIT____: Function Attrs: nofree nosync nounwind readnone willreturn
113 ; IS__TUNIT____-LABEL: define {{[^@]+}}@cb4
114 ; IS__TUNIT____-SAME: (i32 noundef returned [[UNKNOWN:%.*]]) #[[ATTR0]] {
115 ; IS__TUNIT____-NEXT: entry:
116 ; IS__TUNIT____-NEXT: ret i32 [[UNKNOWN]]
118 ; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
119 ; IS__CGSCC____-LABEL: define {{[^@]+}}@cb4
120 ; IS__CGSCC____-SAME: (i32 noundef returned [[UNKNOWN:%.*]]) #[[ATTR0]] {
121 ; IS__CGSCC____-NEXT: entry:
122 ; IS__CGSCC____-NEXT: ret i32 [[UNKNOWN]]
129 ; CHECK-LABEL: define {{[^@]+}}@foo() {
131 ; CHECK-NEXT: call void @broker(i32 (i32)* noundef nonnull @cb0, i32 (i32)* noundef nonnull @cb1, i32 (i32)* noundef nonnull @cb0, i32 noundef 0, i32 noundef 1)
132 ; CHECK-NEXT: call void @broker(i32 (i32)* noundef nonnull @cb1, i32 (i32)* noundef nonnull @cb2, i32 (i32)* noundef nonnull @cb2, i32 noundef 0, i32 noundef 1)
133 ; CHECK-NEXT: call void @broker(i32 (i32)* noundef nonnull @cb3, i32 (i32)* noundef nonnull @cb2, i32 (i32)* noundef nonnull @cb3, i32 noundef 0, i32 noundef 1)
134 ; CHECK-NEXT: call void @broker(i32 (i32)* noundef nonnull @cb4, i32 (i32)* noundef nonnull @cb4, i32 (i32)* noundef nonnull @cb4, i32 noundef 0, i32 noundef 1)
135 ; CHECK-NEXT: ret void
138 %call = call i32 @cb0(i32 0)
139 %call1 = call i32 @cb3(i32 1)
140 call void @broker(i32 (i32)* nonnull @cb0, i32 (i32)* nonnull @cb1, i32 (i32)* nonnull @cb0, i32 0, i32 1)
141 call void @broker(i32 (i32)* nonnull @cb1, i32 (i32)* nonnull @cb2, i32 (i32)* nonnull @cb2, i32 0, i32 1)
142 call void @broker(i32 (i32)* nonnull @cb3, i32 (i32)* nonnull @cb2, i32 (i32)* nonnull @cb3, i32 0, i32 1)
143 call void @broker(i32 (i32)* nonnull @cb4, i32 (i32)* nonnull @cb4, i32 (i32)* nonnull @cb4, i32 0, i32 1)
147 declare !callback !3 void @broker(i32 (i32)*, i32 (i32)*, i32 (i32)*, i32, i32)
149 !0 = !{i64 0, i64 3, i1 false}
150 !1 = !{i64 1, i64 4, i1 false}
151 !2 = !{i64 2, i64 3, i1 false}
154 ; IS__TUNIT____: attributes #[[ATTR0]] = { nofree nosync nounwind readnone willreturn }
156 ; IS__CGSCC____: attributes #[[ATTR0]] = { nofree norecurse nosync nounwind readnone willreturn }
158 ; CHECK: [[META0:![0-9]+]] = !{!1, !2, !3}
159 ; CHECK: [[META1:![0-9]+]] = !{i64 0, i64 3, i1 false}
160 ; CHECK: [[META2:![0-9]+]] = !{i64 2, i64 3, i1 false}
161 ; CHECK: [[META3:![0-9]+]] = !{i64 1, i64 4, i1 false}