• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --scrub-attributes --check-attributes
2; Deep Wrapper disabled
3
4; RUN: opt -attributor -attributor-manifest-internal  -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=1 -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_CGSCC_NPM,NOT_CGSCC_OPM,NOT_TUNIT_NPM,IS__TUNIT____,IS________OPM,IS__TUNIT_OPM,CHECK_DISABLED,NOT_CGSCC_NPM_DISABLED,NOT_CGSCC_OPM_DISABLED,NOT_TUNIT_NPM_DISABLED,IS__TUNIT_____DISABLED,IS________OPM_DISABLED,IS__TUNIT_OPM_DISABLED
5; RUN: opt -aa-pipeline=basic-aa -passes=attributor -attributor-manifest-internal  -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=1  -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_CGSCC_OPM,NOT_CGSCC_NPM,NOT_TUNIT_OPM,IS__TUNIT____,IS________NPM,IS__TUNIT_NPM,CHECK_DISABLED,NOT_CGSCC_OPM_DISABLED,NOT_CGSCC_NPM_DISABLED,NOT_TUNIT_OPM_DISABLED,IS__TUNIT_____DISABLED,IS________NPM_DISABLED,IS__TUNIT_NPM_DISABLED
6; RUN: opt -attributor-cgscc -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,CHECK_DISABLED,NOT_TUNIT_NPM_DISABLED,NOT_TUNIT_OPM_DISABLED,NOT_CGSCC_NPM_DISABLED,IS__CGSCC_____DISABLED,IS________OPM_DISABLED,IS__CGSCC_OPM_DISABLED
7; 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,CHECK_DISABLED,NOT_TUNIT_NPM_DISABLED,NOT_TUNIT_OPM_DISABLED,NOT_CGSCC_OPM_DISABLED,IS__CGSCC_____DISABLED,IS________NPM_DISABLED,IS__CGSCC_NPM_DISABLED
8
9; Deep Wrapper enabled
10
11; RUN: opt -attributor -attributor-manifest-internal  -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=8 -attributor-allow-deep-wrappers -disable-inlining -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_CGSCC_NPM,NOT_CGSCC_OPM,NOT_TUNIT_NPM,IS__TUNIT____,IS________OPM,IS__TUNIT_OPM,CHECK_ENABLED,NOT_CGSCC_NPM_ENABLED,NOT_CGSCC_OPM_ENABLED,NOT_TUNIT_NPM_ENABLED,IS__TUNIT_____ENABLED,IS________OPM_ENABLED,IS__TUNIT_OPM_ENABLED
12; RUN: opt -aa-pipeline=basic-aa -passes=attributor -attributor-manifest-internal  -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=8 -attributor-allow-deep-wrappers -disable-inlining -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_CGSCC_OPM,NOT_CGSCC_NPM,NOT_TUNIT_OPM,IS__TUNIT____,IS________NPM,IS__TUNIT_NPM,CHECK_ENABLED,NOT_CGSCC_OPM_ENABLED,NOT_CGSCC_NPM_ENABLED,NOT_TUNIT_OPM_ENABLED,IS__TUNIT_____ENABLED,IS________NPM_ENABLED,IS__TUNIT_NPM_ENABLED
13; RUN: opt -attributor-cgscc -attributor-manifest-internal  -attributor-annotate-decl-cs -attributor-allow-deep-wrappers -disable-inlining -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_TUNIT_NPM,NOT_TUNIT_OPM,NOT_CGSCC_NPM,IS__CGSCC____,IS________OPM,IS__CGSCC_OPM,CHECK_ENABLED,NOT_TUNIT_NPM_ENABLED,NOT_TUNIT_OPM_ENABLED,NOT_CGSCC_NPM_ENABLED,IS__CGSCC_____ENABLED,IS________OPM_ENABLED,IS__CGSCC_OPM_ENABLED
14; RUN: opt -aa-pipeline=basic-aa -passes=attributor-cgscc -attributor-manifest-internal  -attributor-annotate-decl-cs -attributor-allow-deep-wrappers -disable-inlining -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_TUNIT_NPM,NOT_TUNIT_OPM,NOT_CGSCC_OPM,IS__CGSCC____,IS________NPM,IS__CGSCC_NPM,CHECK_ENABLED,NOT_TUNIT_NPM_ENABLED,NOT_TUNIT_OPM_ENABLED,NOT_CGSCC_OPM_ENABLED,IS__CGSCC_____ENABLED,IS________NPM_ENABLED,IS__CGSCC_NPM_ENABLED
15
16; TEST 1: This function is of linkage `linkonce`, we cannot internalize this
17;         function and use information derived from it
18;
19; CHECK-NOT: inner1.internalized
20define linkonce i32 @inner1(i32 %a, i32 %b) {
21; CHECK-LABEL: define {{[^@]+}}@inner1
22; CHECK-SAME: (i32 [[A:%.*]], i32 [[B:%.*]]) {
23; CHECK-NEXT:  entry:
24; CHECK-NEXT:    [[C:%.*]] = add i32 [[A]], [[B]]
25; CHECK-NEXT:    ret i32 [[C]]
26;
27entry:
28  %c = add i32 %a, %b
29  ret i32 %c
30}
31
32; TEST 2: This function is of linkage `weak`, we cannot internalize this function and
33;         use information derived from it
34;
35; CHECK-NOT: inner2.internalized
36define weak i32 @inner2(i32 %a, i32 %b) {
37; CHECK-LABEL: define {{[^@]+}}@inner2
38; CHECK-SAME: (i32 [[A:%.*]], i32 [[B:%.*]]) {
39; CHECK-NEXT:  entry:
40; CHECK-NEXT:    [[C:%.*]] = add i32 [[A]], [[B]]
41; CHECK-NEXT:    ret i32 [[C]]
42;
43entry:
44  %c = add i32 %a, %b
45  ret i32 %c
46}
47
48; TEST 3: This function is of linkage `linkonce_odr`, which can be internalized using the
49;         deep wrapper, and the IP information derived from this function can be used
50;
51define linkonce_odr i32 @inner3(i32 %a, i32 %b) {
52; CHECK_DISABLED-LABEL: define {{[^@]+}}@inner3
53; CHECK_DISABLED-SAME: (i32 [[A:%.*]], i32 [[B:%.*]]) {
54; CHECK_DISABLED-NEXT:  entry:
55; CHECK_DISABLED-NEXT:    [[C:%.*]] = add i32 [[A]], [[B]]
56; CHECK_DISABLED-NEXT:    ret i32 [[C]]
57;
58entry:
59  %c = add i32 %a, %b
60  ret i32 %c
61}
62
63; TEST 4: This function is of linkage `weak_odr`, which can be internalized using the deep
64;         wrapper
65;
66define weak_odr i32 @inner4(i32 %a, i32 %b) {
67; CHECK_DISABLED-LABEL: define {{[^@]+}}@inner4
68; CHECK_DISABLED-SAME: (i32 [[A:%.*]], i32 [[B:%.*]]) {
69; CHECK_DISABLED-NEXT:  entry:
70; CHECK_DISABLED-NEXT:    [[C:%.*]] = add i32 [[A]], [[B]]
71; CHECK_DISABLED-NEXT:    ret i32 [[C]]
72;
73entry:
74  %c = add i32 %a, %b
75  ret i32 %c
76}
77
78; TEST 5: This function has linkage `linkonce_odr` but is never called (num of use = 0), so there
79;         is no need to internalize this
80;
81; CHECK-NOT: inner5.internalized
82define linkonce_odr i32 @inner5(i32 %a, i32 %b) {
83; CHECK-LABEL: define {{[^@]+}}@inner5
84; CHECK-SAME: (i32 [[A:%.*]], i32 [[B:%.*]]) {
85; CHECK-NEXT:  entry:
86; CHECK-NEXT:    [[C:%.*]] = add i32 [[A]], [[B]]
87; CHECK-NEXT:    ret i32 [[C]]
88;
89entry:
90  %c = add i32 %a, %b
91  ret i32 %c
92}
93
94; Since the inner1 cannot be internalized, there should be no change to its callsite
95; Since the inner2 cannot be internalized, there should be no change to its callsite
96; Since the inner3 is internalized, the use of the original function should be replaced by the
97;  copied one
98;
99define i32 @outer1() {
100; CHECK_DISABLED-LABEL: define {{[^@]+}}@outer1() {
101; CHECK_DISABLED-NEXT:  entry:
102; CHECK_DISABLED-NEXT:    [[RET1:%.*]] = call i32 @inner1(i32 noundef 1, i32 noundef 2)
103; CHECK_DISABLED-NEXT:    [[RET2:%.*]] = call i32 @inner2(i32 noundef 1, i32 noundef 2)
104; CHECK_DISABLED-NEXT:    [[RET3:%.*]] = call i32 @inner3(i32 [[RET1]], i32 [[RET2]])
105; CHECK_DISABLED-NEXT:    [[RET4:%.*]] = call i32 @inner4(i32 [[RET3]], i32 [[RET3]])
106; CHECK_DISABLED-NEXT:    ret i32 [[RET4]]
107;
108; CHECK_ENABLED-LABEL: define {{[^@]+}}@outer1() {
109; CHECK_ENABLED-NEXT:  entry:
110; CHECK_ENABLED-NEXT:    [[RET1:%.*]] = call i32 @inner1(i32 noundef 1, i32 noundef 2)
111; CHECK_ENABLED-NEXT:    [[RET2:%.*]] = call i32 @inner2(i32 noundef 1, i32 noundef 2)
112; CHECK_ENABLED-NEXT:    [[RET3:%.*]] = call i32 @inner3.internalized(i32 [[RET1]], i32 [[RET2]])
113; CHECK_ENABLED-NEXT:    [[RET4:%.*]] = call i32 @inner4.internalized(i32 [[RET3]], i32 [[RET3]])
114; CHECK_ENABLED-NEXT:    ret i32 [[RET4]]
115;
116entry:
117  %ret1 = call i32 @inner1(i32 1, i32 2)
118  %ret2 = call i32 @inner2(i32 1, i32 2)
119  %ret3 = call i32 @inner3(i32 %ret1, i32 %ret2)
120  %ret4 = call i32 @inner4(i32 %ret3, i32 %ret3)
121  ret i32 %ret4
122}
123
124
125define linkonce_odr void @unused_arg(i8) {
126; CHECK_DISABLED-LABEL: define {{[^@]+}}@unused_arg
127; CHECK_DISABLED-SAME: (i8 [[TMP0:%.*]]) {
128; CHECK_DISABLED-NEXT:    unreachable
129;
130  unreachable
131}
132
133define void @unused_arg_caller() {
134; CHECK_DISABLED-LABEL: define {{[^@]+}}@unused_arg_caller() {
135; CHECK_DISABLED-NEXT:    call void @unused_arg(i8 noundef 0)
136; CHECK_DISABLED-NEXT:    ret void
137;
138; IS__TUNIT_____ENABLED: Function Attrs: nofree noreturn nosync nounwind readnone willreturn
139; IS__TUNIT_____ENABLED-LABEL: define {{[^@]+}}@unused_arg_caller
140; IS__TUNIT_____ENABLED-SAME: () [[ATTR1:#.*]] {
141; IS__TUNIT_____ENABLED-NEXT:    unreachable
142;
143; IS__CGSCC_____ENABLED: Function Attrs: nofree norecurse noreturn nosync nounwind readnone willreturn
144; IS__CGSCC_____ENABLED-LABEL: define {{[^@]+}}@unused_arg_caller
145; IS__CGSCC_____ENABLED-SAME: () [[ATTR2:#.*]] {
146; IS__CGSCC_____ENABLED-NEXT:    unreachable
147;
148  call void @unused_arg(i8 0)
149  ret void
150}
151
152; Don't crash on linkonce_odr hidden functions
153define linkonce_odr hidden void @__clang_call_terminate() {
154; CHECK_DISABLED-LABEL: define {{[^@]+}}@__clang_call_terminate() {
155; CHECK_DISABLED-NEXT:    call void @__clang_call_terminate()
156; CHECK_DISABLED-NEXT:    unreachable
157;
158  call void @__clang_call_terminate()
159  unreachable
160}
161
162