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=16 -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=16 -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
6
7target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
8declare void @f(i32)
9declare token @llvm.call.preallocated.setup(i32)
10declare i8* @llvm.call.preallocated.arg(token, i32)
11
12@ConstAS3Ptr = addrspace(3) global i32 0, align 4
13
14;.
15; CHECK: @[[CONSTAS3PTR:[a-zA-Z0-9_$"\\.-]+]] = addrspace(3) global i32 0, align 4
16; CHECK: @[[S:[a-zA-Z0-9_$"\\.-]+]] = external global [[STRUCT_X:%.*]]
17; CHECK: @[[G:[a-zA-Z0-9_$"\\.-]+]] = internal constant { [2 x i8*] } { [2 x i8*] [i8* bitcast (void (i8***)* @f1 to i8*), i8* bitcast (void (i1 (i8*)*)* @f2 to i8*)] }
18;.
19define internal i32 addrspace(3)* @const_ptr_return_as3() {
20; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
21; IS__CGSCC____-LABEL: define {{[^@]+}}@const_ptr_return_as3
22; IS__CGSCC____-SAME: () #[[ATTR1:[0-9]+]] {
23; IS__CGSCC____-NEXT:    ret i32 addrspace(3)* undef
24;
25  ret i32 addrspace(3)* @ConstAS3Ptr
26}
27define internal i32* @const_ptr_return() {
28; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
29; IS__CGSCC____-LABEL: define {{[^@]+}}@const_ptr_return
30; IS__CGSCC____-SAME: () #[[ATTR1]] {
31; IS__CGSCC____-NEXT:    ret i32* undef
32;
33  ret i32* addrspacecast (i32 addrspace(3)* @ConstAS3Ptr to i32*)
34}
35
36; Test1: Replace argument with constant
37define internal void @test1(i32 %a) {
38; CHECK-LABEL: define {{[^@]+}}@test1() {
39; CHECK-NEXT:    tail call void @f(i32 noundef 1)
40; CHECK-NEXT:    ret void
41;
42  tail call void @f(i32 %a)
43  ret void
44}
45
46define void @test1_helper() {
47; CHECK-LABEL: define {{[^@]+}}@test1_helper() {
48; CHECK-NEXT:    tail call void @test1()
49; CHECK-NEXT:    ret void
50;
51  tail call void @test1(i32 1)
52  ret void
53}
54
55; TEST 2 : Simplify return value
56define i32 @return0() {
57; IS__TUNIT____: Function Attrs: nofree nosync nounwind readnone willreturn
58; IS__TUNIT____-LABEL: define {{[^@]+}}@return0
59; IS__TUNIT____-SAME: () #[[ATTR1:[0-9]+]] {
60; IS__TUNIT____-NEXT:    ret i32 0
61;
62; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
63; IS__CGSCC____-LABEL: define {{[^@]+}}@return0
64; IS__CGSCC____-SAME: () #[[ATTR1]] {
65; IS__CGSCC____-NEXT:    ret i32 0
66;
67  ret i32 0
68}
69
70define i32 @return1() {
71; IS__TUNIT____: Function Attrs: nofree nosync nounwind readnone willreturn
72; IS__TUNIT____-LABEL: define {{[^@]+}}@return1
73; IS__TUNIT____-SAME: () #[[ATTR1]] {
74; IS__TUNIT____-NEXT:    ret i32 1
75;
76; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
77; IS__CGSCC____-LABEL: define {{[^@]+}}@return1
78; IS__CGSCC____-SAME: () #[[ATTR1]] {
79; IS__CGSCC____-NEXT:    ret i32 1
80;
81  ret i32 1
82}
83
84define i32 @test2_1(i1 %c) {
85; IS__TUNIT____: Function Attrs: nofree nosync nounwind readnone willreturn
86; IS__TUNIT____-LABEL: define {{[^@]+}}@test2_1
87; IS__TUNIT____-SAME: (i1 [[C:%.*]]) #[[ATTR1]] {
88; IS__TUNIT____-NEXT:    br i1 [[C]], label [[IF_TRUE:%.*]], label [[IF_FALSE:%.*]]
89; IS__TUNIT____:       if.true:
90; IS__TUNIT____-NEXT:    [[RET0:%.*]] = add i32 0, 1
91; IS__TUNIT____-NEXT:    br label [[END:%.*]]
92; IS__TUNIT____:       if.false:
93; IS__TUNIT____-NEXT:    br label [[END]]
94; IS__TUNIT____:       end:
95; IS__TUNIT____-NEXT:    [[RET:%.*]] = phi i32 [ [[RET0]], [[IF_TRUE]] ], [ 1, [[IF_FALSE]] ]
96; IS__TUNIT____-NEXT:    ret i32 1
97;
98; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
99; IS__CGSCC____-LABEL: define {{[^@]+}}@test2_1
100; IS__CGSCC____-SAME: (i1 [[C:%.*]]) #[[ATTR1]] {
101; IS__CGSCC____-NEXT:    br i1 [[C]], label [[IF_TRUE:%.*]], label [[IF_FALSE:%.*]]
102; IS__CGSCC____:       if.true:
103; IS__CGSCC____-NEXT:    [[RET0:%.*]] = add i32 0, 1
104; IS__CGSCC____-NEXT:    br label [[END:%.*]]
105; IS__CGSCC____:       if.false:
106; IS__CGSCC____-NEXT:    br label [[END]]
107; IS__CGSCC____:       end:
108; IS__CGSCC____-NEXT:    [[RET:%.*]] = phi i32 [ [[RET0]], [[IF_TRUE]] ], [ 1, [[IF_FALSE]] ]
109; IS__CGSCC____-NEXT:    ret i32 1
110;
111  br i1 %c, label %if.true, label %if.false
112if.true:
113  %call = tail call i32 @return0()
114  %ret0 = add i32 %call, 1
115  br label %end
116if.false:
117  %ret1 = tail call i32 @return1()
118  br label %end
119end:
120
121  %ret = phi i32 [ %ret0, %if.true ], [ %ret1, %if.false ]
122
123  ret i32 1
124}
125
126
127
128define i32 @test2_2(i1 %c) {
129; IS__TUNIT____: Function Attrs: nofree nosync nounwind readnone willreturn
130; IS__TUNIT____-LABEL: define {{[^@]+}}@test2_2
131; IS__TUNIT____-SAME: (i1 [[C:%.*]]) #[[ATTR1]] {
132; IS__TUNIT____-NEXT:    ret i32 1
133;
134; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
135; IS__CGSCC____-LABEL: define {{[^@]+}}@test2_2
136; IS__CGSCC____-SAME: (i1 [[C:%.*]]) #[[ATTR1]] {
137; IS__CGSCC____-NEXT:    ret i32 1
138;
139  %ret = tail call i32 @test2_1(i1 %c)
140  ret i32 %ret
141}
142
143declare void @use(i32)
144define void @test3(i1 %c) {
145; CHECK-LABEL: define {{[^@]+}}@test3
146; CHECK-SAME: (i1 [[C:%.*]]) {
147; CHECK-NEXT:    br i1 [[C]], label [[IF_TRUE:%.*]], label [[IF_FALSE:%.*]]
148; CHECK:       if.true:
149; CHECK-NEXT:    br label [[END:%.*]]
150; CHECK:       if.false:
151; CHECK-NEXT:    br label [[END]]
152; CHECK:       end:
153; CHECK-NEXT:    [[R:%.*]] = phi i32 [ 1, [[IF_TRUE]] ], [ 1, [[IF_FALSE]] ]
154; CHECK-NEXT:    tail call void @use(i32 noundef 1)
155; CHECK-NEXT:    ret void
156;
157  br i1 %c, label %if.true, label %if.false
158if.true:
159  br label %end
160if.false:
161  %ret1 = tail call i32 @return1()
162  br label %end
163end:
164
165  %r = phi i32 [ 1, %if.true ], [ %ret1, %if.false ]
166
167  tail call void @use(i32 %r)
168  ret void
169}
170
171define void @test-select-phi(i1 %c) {
172; CHECK-LABEL: define {{[^@]+}}@test-select-phi
173; CHECK-SAME: (i1 [[C:%.*]]) {
174; CHECK-NEXT:    tail call void @use(i32 noundef 1)
175; CHECK-NEXT:    [[SELECT_NOT_SAME:%.*]] = select i1 [[C]], i32 1, i32 0
176; CHECK-NEXT:    tail call void @use(i32 noundef [[SELECT_NOT_SAME]])
177; CHECK-NEXT:    br i1 [[C]], label [[IF_TRUE:%.*]], label [[IF_FALSE:%.*]]
178; CHECK:       if-true:
179; CHECK-NEXT:    br label [[END:%.*]]
180; CHECK:       if-false:
181; CHECK-NEXT:    br label [[END]]
182; CHECK:       end:
183; CHECK-NEXT:    [[PHI_SAME:%.*]] = phi i32 [ 1, [[IF_TRUE]] ], [ 1, [[IF_FALSE]] ]
184; CHECK-NEXT:    [[PHI_NOT_SAME:%.*]] = phi i32 [ 0, [[IF_TRUE]] ], [ 1, [[IF_FALSE]] ]
185; CHECK-NEXT:    [[PHI_SAME_PROP:%.*]] = phi i32 [ 1, [[IF_TRUE]] ], [ 1, [[IF_FALSE]] ]
186; CHECK-NEXT:    [[PHI_SAME_UNDEF:%.*]] = phi i32 [ 1, [[IF_TRUE]] ], [ undef, [[IF_FALSE]] ]
187; CHECK-NEXT:    [[SELECT_NOT_SAME_UNDEF:%.*]] = select i1 [[C]], i32 [[PHI_NOT_SAME]], i32 undef
188; CHECK-NEXT:    tail call void @use(i32 noundef 1)
189; CHECK-NEXT:    tail call void @use(i32 noundef [[PHI_NOT_SAME]])
190; CHECK-NEXT:    tail call void @use(i32 noundef 1)
191; CHECK-NEXT:    tail call void @use(i32 1)
192; CHECK-NEXT:    tail call void @use(i32 [[SELECT_NOT_SAME_UNDEF]])
193; CHECK-NEXT:    ret void
194;
195  %select-same = select i1 %c, i32 1, i32 1
196  tail call void @use(i32 %select-same)
197
198  %select-not-same = select i1 %c, i32 1, i32 0
199  tail call void @use(i32 %select-not-same)
200  br i1 %c, label %if-true, label %if-false
201if-true:
202  br label %end
203if-false:
204  br label %end
205end:
206  %phi-same = phi i32 [ 1, %if-true ], [ 1, %if-false ]
207  %phi-not-same = phi i32 [ 0, %if-true ], [ 1, %if-false ]
208  %phi-same-prop = phi i32 [ 1, %if-true ], [ %select-same, %if-false ]
209  %phi-same-undef = phi i32 [ 1, %if-true ], [ undef, %if-false ]
210  %select-not-same-undef = select i1 %c, i32 %phi-not-same, i32 undef
211
212
213  tail call void @use(i32 %phi-same)
214
215  tail call void @use(i32 %phi-not-same)
216
217  tail call void @use(i32 %phi-same-prop)
218
219  tail call void @use(i32 %phi-same-undef)
220
221  tail call void @use(i32 %select-not-same-undef)
222
223  ret void
224
225}
226
227define i32 @ipccp1(i32 %a) {
228; IS__TUNIT____: Function Attrs: nofree nosync nounwind readnone willreturn
229; IS__TUNIT____-LABEL: define {{[^@]+}}@ipccp1
230; IS__TUNIT____-SAME: (i32 returned [[A:%.*]]) #[[ATTR1]] {
231; IS__TUNIT____-NEXT:    br i1 true, label [[T:%.*]], label [[F:%.*]]
232; IS__TUNIT____:       t:
233; IS__TUNIT____-NEXT:    ret i32 [[A]]
234; IS__TUNIT____:       f:
235; IS__TUNIT____-NEXT:    unreachable
236;
237; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
238; IS__CGSCC____-LABEL: define {{[^@]+}}@ipccp1
239; IS__CGSCC____-SAME: (i32 returned [[A:%.*]]) #[[ATTR1]] {
240; IS__CGSCC____-NEXT:    br i1 true, label [[T:%.*]], label [[F:%.*]]
241; IS__CGSCC____:       t:
242; IS__CGSCC____-NEXT:    ret i32 [[A]]
243; IS__CGSCC____:       f:
244; IS__CGSCC____-NEXT:    unreachable
245;
246  br i1 true, label %t, label %f
247t:
248  ret i32 %a
249f:
250  %r = call i32 @ipccp1(i32 5)
251  ret i32 %r
252}
253
254define internal i1 @ipccp2i(i1 %a) {
255; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
256; IS__CGSCC____-LABEL: define {{[^@]+}}@ipccp2i
257; IS__CGSCC____-SAME: () #[[ATTR1]] {
258; IS__CGSCC____-NEXT:    br label [[T:%.*]]
259; IS__CGSCC____:       t:
260; IS__CGSCC____-NEXT:    ret i1 undef
261; IS__CGSCC____:       f:
262; IS__CGSCC____-NEXT:    unreachable
263;
264  br i1 %a, label %t, label %f
265t:
266  ret i1 %a
267f:
268  %r = call i1 @ipccp2i(i1 false)
269  ret i1 %r
270}
271
272define i1 @ipccp2() {
273; IS__TUNIT____: Function Attrs: nofree nosync nounwind readnone willreturn
274; IS__TUNIT____-LABEL: define {{[^@]+}}@ipccp2
275; IS__TUNIT____-SAME: () #[[ATTR1]] {
276; IS__TUNIT____-NEXT:    ret i1 true
277;
278; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
279; IS__CGSCC____-LABEL: define {{[^@]+}}@ipccp2
280; IS__CGSCC____-SAME: () #[[ATTR1]] {
281; IS__CGSCC____-NEXT:    ret i1 true
282;
283  %r = call i1 @ipccp2i(i1 true)
284  ret i1 %r
285}
286
287define internal i1 @ipccp2ib(i1 %a) {
288; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
289; IS__CGSCC____-LABEL: define {{[^@]+}}@ipccp2ib
290; IS__CGSCC____-SAME: () #[[ATTR1]] {
291; IS__CGSCC____-NEXT:    br label [[T:%.*]]
292; IS__CGSCC____:       t:
293; IS__CGSCC____-NEXT:    ret i1 undef
294; IS__CGSCC____:       f:
295; IS__CGSCC____-NEXT:    unreachable
296;
297  br i1 %a, label %t, label %f
298t:
299  ret i1 true
300f:
301  %r = call i1 @ipccp2ib(i1 false)
302  ret i1 %r
303}
304
305define i1 @ipccp2b() {
306; IS__TUNIT____: Function Attrs: nofree nosync nounwind readnone willreturn
307; IS__TUNIT____-LABEL: define {{[^@]+}}@ipccp2b
308; IS__TUNIT____-SAME: () #[[ATTR1]] {
309; IS__TUNIT____-NEXT:    ret i1 true
310;
311; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
312; IS__CGSCC____-LABEL: define {{[^@]+}}@ipccp2b
313; IS__CGSCC____-SAME: () #[[ATTR1]] {
314; IS__CGSCC____-NEXT:    ret i1 true
315;
316  %r = call i1 @ipccp2ib(i1 true)
317  ret i1 %r
318}
319
320define internal i32 @ipccp3i(i32 %a) {
321; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
322; IS__CGSCC____-LABEL: define {{[^@]+}}@ipccp3i
323; IS__CGSCC____-SAME: () #[[ATTR1]] {
324; IS__CGSCC____-NEXT:    br label [[T:%.*]]
325; IS__CGSCC____:       t:
326; IS__CGSCC____-NEXT:    ret i32 undef
327; IS__CGSCC____:       f:
328; IS__CGSCC____-NEXT:    unreachable
329;
330  %c = icmp eq i32 %a, 7
331  br i1 %c, label %t, label %f
332t:
333  ret i32 %a
334f:
335  %r = call i32 @ipccp3i(i32 5)
336  ret i32 %r
337}
338
339define i32 @ipccp3() {
340; IS__TUNIT____: Function Attrs: nofree nosync nounwind readnone willreturn
341; IS__TUNIT____-LABEL: define {{[^@]+}}@ipccp3
342; IS__TUNIT____-SAME: () #[[ATTR1]] {
343; IS__TUNIT____-NEXT:    ret i32 7
344;
345; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
346; IS__CGSCC____-LABEL: define {{[^@]+}}@ipccp3
347; IS__CGSCC____-SAME: () #[[ATTR1]] {
348; IS__CGSCC____-NEXT:    ret i32 7
349;
350  %r = call i32 @ipccp3i(i32 7)
351  ret i32 %r
352}
353
354define internal i32 @ipccp4ia(i1 %c) {
355; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
356; IS__CGSCC____-LABEL: define {{[^@]+}}@ipccp4ia
357; IS__CGSCC____-SAME: () #[[ATTR1]] {
358; IS__CGSCC____-NEXT:    br label [[T:%.*]]
359; IS__CGSCC____:       t:
360; IS__CGSCC____-NEXT:    ret i32 undef
361; IS__CGSCC____:       f:
362; IS__CGSCC____-NEXT:    unreachable
363;
364  br i1 %c, label %t, label %f
365t:
366  ret i32 0
367f:
368  ret i32 1
369}
370define internal i32 @ipccp4ib(i32 %a) {
371; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
372; IS__CGSCC____-LABEL: define {{[^@]+}}@ipccp4ib
373; IS__CGSCC____-SAME: () #[[ATTR1]] {
374; IS__CGSCC____-NEXT:    [[C:%.*]] = icmp eq i32 7, 7
375; IS__CGSCC____-NEXT:    br i1 true, label [[T:%.*]], label [[F:%.*]]
376; IS__CGSCC____:       t:
377; IS__CGSCC____-NEXT:    ret i32 undef
378; IS__CGSCC____:       f:
379; IS__CGSCC____-NEXT:    unreachable
380;
381  %c = icmp eq i32 %a, 7
382  br i1 %c, label %t, label %f
383t:
384  %r = call i32 @ipccp4ia(i1 %c)
385  ret i32 %r
386f:
387  ret i32 1
388}
389
390define i32 @ipccp4(i1 %c) {
391; IS__TUNIT____: Function Attrs: nofree nosync nounwind readnone willreturn
392; IS__TUNIT____-LABEL: define {{[^@]+}}@ipccp4
393; IS__TUNIT____-SAME: (i1 [[C:%.*]]) #[[ATTR1]] {
394; IS__TUNIT____-NEXT:    br i1 [[C]], label [[T:%.*]], label [[F:%.*]]
395; IS__TUNIT____:       t:
396; IS__TUNIT____-NEXT:    br label [[F]]
397; IS__TUNIT____:       f:
398; IS__TUNIT____-NEXT:    ret i32 0
399;
400; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
401; IS__CGSCC____-LABEL: define {{[^@]+}}@ipccp4
402; IS__CGSCC____-SAME: (i1 [[C:%.*]]) #[[ATTR1]] {
403; IS__CGSCC____-NEXT:    br i1 [[C]], label [[T:%.*]], label [[F:%.*]]
404; IS__CGSCC____:       t:
405; IS__CGSCC____-NEXT:    br label [[F]]
406; IS__CGSCC____:       f:
407; IS__CGSCC____-NEXT:    ret i32 0
408;
409  br i1 %c, label %t, label %f
410t:
411  %q = call i32 @ipccp4ia(i1 undef)
412  br label %f
413f:
414  %r = call i32 @ipccp4ib(i32 7)
415  ret i32 %r
416}
417
418; Do not touch complicated arguments (for now)
419%struct.X = type { i8* }
420define internal i32* @test_inalloca(i32* inalloca(i32) %a) {
421; IS__TUNIT____: Function Attrs: nofree nosync nounwind readnone willreturn
422; IS__TUNIT____-LABEL: define {{[^@]+}}@test_inalloca
423; IS__TUNIT____-SAME: (i32* noalias nofree nonnull returned writeonly inalloca(i32) dereferenceable(4) "no-capture-maybe-returned" [[A:%.*]]) #[[ATTR1]] {
424; IS__TUNIT____-NEXT:    ret i32* [[A]]
425;
426; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
427; IS__CGSCC____-LABEL: define {{[^@]+}}@test_inalloca
428; IS__CGSCC____-SAME: (i32* noalias nofree noundef nonnull returned writeonly inalloca(i32) dereferenceable(4) "no-capture-maybe-returned" [[A:%.*]]) #[[ATTR1]] {
429; IS__CGSCC____-NEXT:    ret i32* [[A]]
430;
431  ret i32* %a
432}
433define i32* @complicated_args_inalloca(i32* %arg) {
434; IS__TUNIT____: Function Attrs: nofree nosync nounwind readnone willreturn
435; IS__TUNIT____-LABEL: define {{[^@]+}}@complicated_args_inalloca
436; IS__TUNIT____-SAME: (i32* nofree readnone "no-capture-maybe-returned" [[ARG:%.*]]) #[[ATTR1]] {
437; IS__TUNIT____-NEXT:    [[CALL:%.*]] = call nonnull dereferenceable(4) i32* @test_inalloca(i32* noalias nofree writeonly inalloca(i32) "no-capture-maybe-returned" [[ARG]]) #[[ATTR1]]
438; IS__TUNIT____-NEXT:    ret i32* [[CALL]]
439;
440; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
441; IS__CGSCC____-LABEL: define {{[^@]+}}@complicated_args_inalloca
442; IS__CGSCC____-SAME: (i32* nofree noundef nonnull readnone returned dereferenceable(4) "no-capture-maybe-returned" [[ARG:%.*]]) #[[ATTR1]] {
443; IS__CGSCC____-NEXT:    ret i32* [[ARG]]
444;
445  %call = call i32* @test_inalloca(i32* inalloca(i32) %arg)
446  ret i32* %call
447}
448
449define internal i32* @test_preallocated(i32* preallocated(i32) %a) {
450; IS__TUNIT____: Function Attrs: nofree nosync nounwind readnone willreturn
451; IS__TUNIT____-LABEL: define {{[^@]+}}@test_preallocated
452; IS__TUNIT____-SAME: (i32* noalias nofree noundef nonnull returned writeonly preallocated(i32) align 4294967296 dereferenceable(4) "no-capture-maybe-returned" [[A:%.*]]) #[[ATTR1]] {
453; IS__TUNIT____-NEXT:    ret i32* [[A]]
454;
455; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
456; IS__CGSCC____-LABEL: define {{[^@]+}}@test_preallocated
457; IS__CGSCC____-SAME: (i32* noalias nofree noundef nonnull returned writeonly preallocated(i32) align 4294967296 dereferenceable(4) "no-capture-maybe-returned" [[A:%.*]]) #[[ATTR1]] {
458; IS__CGSCC____-NEXT:    ret i32* [[A]]
459;
460  ret i32* %a
461}
462define i32* @complicated_args_preallocated() {
463; IS__TUNIT_OPM: Function Attrs: nofree nosync nounwind willreturn
464; IS__TUNIT_OPM-LABEL: define {{[^@]+}}@complicated_args_preallocated
465; IS__TUNIT_OPM-SAME: () #[[ATTR0:[0-9]+]] {
466; IS__TUNIT_OPM-NEXT:    [[C:%.*]] = call token @llvm.call.preallocated.setup(i32 noundef 1) #[[ATTR5:[0-9]+]]
467; IS__TUNIT_OPM-NEXT:    [[CALL:%.*]] = call noundef nonnull align 4294967296 dereferenceable(4) i32* @test_preallocated(i32* noalias nocapture nofree noundef writeonly preallocated(i32) align 4294967296 null) #[[ATTR1]] [ "preallocated"(token [[C]]) ]
468; IS__TUNIT_OPM-NEXT:    ret i32* [[CALL]]
469;
470; IS__TUNIT_NPM: Function Attrs: nofree nosync nounwind willreturn
471; IS__TUNIT_NPM-LABEL: define {{[^@]+}}@complicated_args_preallocated
472; IS__TUNIT_NPM-SAME: () #[[ATTR0:[0-9]+]] {
473; IS__TUNIT_NPM-NEXT:    [[C:%.*]] = call token @llvm.call.preallocated.setup(i32 noundef 1) #[[ATTR4:[0-9]+]]
474; IS__TUNIT_NPM-NEXT:    [[CALL:%.*]] = call noundef nonnull align 4294967296 dereferenceable(4) i32* @test_preallocated(i32* noalias nocapture nofree noundef writeonly preallocated(i32) align 4294967296 null) #[[ATTR1]] [ "preallocated"(token [[C]]) ]
475; IS__TUNIT_NPM-NEXT:    ret i32* [[CALL]]
476;
477; IS__CGSCC_OPM: Function Attrs: nofree nosync nounwind willreturn
478; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@complicated_args_preallocated
479; IS__CGSCC_OPM-SAME: () #[[ATTR0:[0-9]+]] {
480; IS__CGSCC_OPM-NEXT:    [[C:%.*]] = call token @llvm.call.preallocated.setup(i32 noundef 1) #[[ATTR5:[0-9]+]]
481; IS__CGSCC_OPM-NEXT:    ret i32* null
482;
483; IS__CGSCC_NPM: Function Attrs: nofree nosync nounwind willreturn
484; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@complicated_args_preallocated
485; IS__CGSCC_NPM-SAME: () #[[ATTR0:[0-9]+]] {
486; IS__CGSCC_NPM-NEXT:    [[C:%.*]] = call token @llvm.call.preallocated.setup(i32 noundef 1) #[[ATTR4:[0-9]+]]
487; IS__CGSCC_NPM-NEXT:    ret i32* null
488;
489  %c = call token @llvm.call.preallocated.setup(i32 1)
490  %call = call i32* @test_preallocated(i32* preallocated(i32) null) ["preallocated"(token %c)]
491  ret i32* %call
492}
493
494define internal void @test_sret(%struct.X* sret(%struct.X) %a, %struct.X** %b) {
495;
496; IS__TUNIT____: Function Attrs: argmemonly nofree nosync nounwind willreturn writeonly
497; IS__TUNIT____-LABEL: define {{[^@]+}}@test_sret
498; IS__TUNIT____-SAME: (%struct.X* noalias nofree noundef nonnull writeonly sret([[STRUCT_X:%.*]]) align 4294967296 dereferenceable(8) [[A:%.*]], %struct.X** nocapture nofree noundef nonnull writeonly align 8 dereferenceable(8) [[B:%.*]]) #[[ATTR2:[0-9]+]] {
499; IS__TUNIT____-NEXT:    store %struct.X* [[A]], %struct.X** [[B]], align 8
500; IS__TUNIT____-NEXT:    ret void
501;
502; IS__CGSCC____: Function Attrs: argmemonly nofree norecurse nosync nounwind willreturn writeonly
503; IS__CGSCC____-LABEL: define {{[^@]+}}@test_sret
504; IS__CGSCC____-SAME: (%struct.X* noalias nofree noundef nonnull writeonly sret([[STRUCT_X:%.*]]) align 4294967296 dereferenceable(8) [[A:%.*]], %struct.X** nocapture nofree noundef nonnull writeonly align 8 dereferenceable(8) [[B:%.*]]) #[[ATTR2:[0-9]+]] {
505; IS__CGSCC____-NEXT:    store %struct.X* [[A]], %struct.X** [[B]], align 8
506; IS__CGSCC____-NEXT:    ret void
507;
508  store %struct.X* %a, %struct.X** %b
509  ret void
510}
511; FIXME: Alignment and dereferenceability are not propagated to the argument
512define void @complicated_args_sret(%struct.X** %b) {
513;
514;
515; IS__TUNIT____: Function Attrs: argmemonly nofree nosync nounwind willreturn writeonly
516; IS__TUNIT____-LABEL: define {{[^@]+}}@complicated_args_sret
517; IS__TUNIT____-SAME: (%struct.X** nocapture nofree writeonly [[B:%.*]]) #[[ATTR2]] {
518; IS__TUNIT____-NEXT:    call void @test_sret(%struct.X* noalias nocapture nofree noundef writeonly sret([[STRUCT_X:%.*]]) align 4294967296 null, %struct.X** nocapture nofree writeonly align 8 [[B]]) #[[ATTR3:[0-9]+]]
519; IS__TUNIT____-NEXT:    ret void
520;
521; IS__CGSCC____: Function Attrs: argmemonly nofree norecurse nosync nounwind willreturn writeonly
522; IS__CGSCC____-LABEL: define {{[^@]+}}@complicated_args_sret
523; IS__CGSCC____-SAME: (%struct.X** nocapture nofree noundef nonnull writeonly align 8 dereferenceable(8) [[B:%.*]]) #[[ATTR2]] {
524; IS__CGSCC____-NEXT:    unreachable
525;
526  call void @test_sret(%struct.X* sret(%struct.X) null, %struct.X** %b)
527  ret void
528}
529
530define internal %struct.X* @test_nest(%struct.X* nest %a) {
531; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
532; IS__CGSCC____-LABEL: define {{[^@]+}}@test_nest
533; IS__CGSCC____-SAME: (%struct.X* nest noalias nocapture nofree readnone align 4294967296 [[A:%.*]]) #[[ATTR1]] {
534; IS__CGSCC____-NEXT:    ret %struct.X* undef
535;
536  ret %struct.X* %a
537}
538define %struct.X* @complicated_args_nest() {
539; IS__TUNIT____: Function Attrs: nofree nosync nounwind readnone willreturn
540; IS__TUNIT____-LABEL: define {{[^@]+}}@complicated_args_nest
541; IS__TUNIT____-SAME: () #[[ATTR1]] {
542; IS__TUNIT____-NEXT:    ret %struct.X* null
543;
544; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
545; IS__CGSCC____-LABEL: define {{[^@]+}}@complicated_args_nest
546; IS__CGSCC____-SAME: () #[[ATTR1]] {
547; IS__CGSCC____-NEXT:    ret %struct.X* null
548;
549  %call = call %struct.X* @test_nest(%struct.X* null)
550  ret %struct.X* %call
551}
552
553@S = external global %struct.X
554define internal void @test_byval(%struct.X* byval(%struct.X) %a) {
555; IS__TUNIT_OPM: Function Attrs: argmemonly nofree nosync nounwind willreturn writeonly
556; IS__TUNIT_OPM-LABEL: define {{[^@]+}}@test_byval
557; IS__TUNIT_OPM-SAME: (%struct.X* noalias nocapture nofree noundef nonnull writeonly byval([[STRUCT_X:%.*]]) align 8 dereferenceable(8) [[A:%.*]]) #[[ATTR2]] {
558; IS__TUNIT_OPM-NEXT:    [[G0:%.*]] = getelementptr [[STRUCT_X]], %struct.X* [[A]], i32 0, i32 0
559; IS__TUNIT_OPM-NEXT:    store i8* null, i8** [[G0]], align 8
560; IS__TUNIT_OPM-NEXT:    ret void
561;
562; IS__TUNIT_NPM: Function Attrs: argmemonly nofree nosync nounwind willreturn writeonly
563; IS__TUNIT_NPM-LABEL: define {{[^@]+}}@test_byval
564; IS__TUNIT_NPM-SAME: (i8* [[TMP0:%.*]]) #[[ATTR2]] {
565; IS__TUNIT_NPM-NEXT:    [[A_PRIV:%.*]] = alloca [[STRUCT_X:%.*]], align 8
566; IS__TUNIT_NPM-NEXT:    [[A_PRIV_CAST:%.*]] = bitcast %struct.X* [[A_PRIV]] to i8**
567; IS__TUNIT_NPM-NEXT:    store i8* [[TMP0]], i8** [[A_PRIV_CAST]], align 8
568; IS__TUNIT_NPM-NEXT:    [[G0:%.*]] = getelementptr [[STRUCT_X]], %struct.X* [[A_PRIV]], i32 0, i32 0
569; IS__TUNIT_NPM-NEXT:    store i8* null, i8** [[G0]], align 8
570; IS__TUNIT_NPM-NEXT:    ret void
571;
572; IS__CGSCC_OPM: Function Attrs: argmemonly nofree norecurse nosync nounwind willreturn writeonly
573; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@test_byval
574; IS__CGSCC_OPM-SAME: (%struct.X* noalias nocapture nofree noundef nonnull writeonly byval([[STRUCT_X:%.*]]) align 8 dereferenceable(8) [[A:%.*]]) #[[ATTR2]] {
575; IS__CGSCC_OPM-NEXT:    [[G0:%.*]] = getelementptr [[STRUCT_X]], %struct.X* [[A]], i32 0, i32 0
576; IS__CGSCC_OPM-NEXT:    store i8* null, i8** [[G0]], align 8
577; IS__CGSCC_OPM-NEXT:    ret void
578;
579; IS__CGSCC_NPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
580; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@test_byval
581; IS__CGSCC_NPM-SAME: (i8* noalias nocapture nofree readnone [[TMP0:%.*]]) #[[ATTR1]] {
582; IS__CGSCC_NPM-NEXT:    [[A_PRIV:%.*]] = alloca [[STRUCT_X:%.*]], align 8
583; IS__CGSCC_NPM-NEXT:    [[A_PRIV_CAST:%.*]] = bitcast %struct.X* [[A_PRIV]] to i8**
584; IS__CGSCC_NPM-NEXT:    [[G0:%.*]] = getelementptr [[STRUCT_X]], %struct.X* [[A_PRIV]], i32 0, i32 0
585; IS__CGSCC_NPM-NEXT:    ret void
586;
587  %g0 = getelementptr %struct.X, %struct.X* %a, i32 0, i32 0
588  store i8* null, i8** %g0
589  ret void
590}
591define void @complicated_args_byval() {
592; IS__TUNIT_OPM: Function Attrs: nofree nosync nounwind willreturn writeonly
593; IS__TUNIT_OPM-LABEL: define {{[^@]+}}@complicated_args_byval
594; IS__TUNIT_OPM-SAME: () #[[ATTR3]] {
595; IS__TUNIT_OPM-NEXT:    call void @test_byval(%struct.X* nocapture nofree noundef nonnull readonly byval([[STRUCT_X:%.*]]) align 8 dereferenceable(8) @S) #[[ATTR3]]
596; IS__TUNIT_OPM-NEXT:    ret void
597;
598; IS__TUNIT_NPM: Function Attrs: nofree nosync nounwind willreturn writeonly
599; IS__TUNIT_NPM-LABEL: define {{[^@]+}}@complicated_args_byval
600; IS__TUNIT_NPM-SAME: () #[[ATTR3]] {
601; IS__TUNIT_NPM-NEXT:    [[S_CAST:%.*]] = bitcast %struct.X* @S to i8**
602; IS__TUNIT_NPM-NEXT:    [[TMP1:%.*]] = load i8*, i8** [[S_CAST]], align 8
603; IS__TUNIT_NPM-NEXT:    call void @test_byval(i8* [[TMP1]]) #[[ATTR3]]
604; IS__TUNIT_NPM-NEXT:    ret void
605;
606; IS__CGSCC_OPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
607; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@complicated_args_byval
608; IS__CGSCC_OPM-SAME: () #[[ATTR1]] {
609; IS__CGSCC_OPM-NEXT:    call void @test_byval(%struct.X* noalias nocapture nofree noundef nonnull readnone byval([[STRUCT_X:%.*]]) align 8 dereferenceable(8) @S) #[[ATTR6:[0-9]+]]
610; IS__CGSCC_OPM-NEXT:    ret void
611;
612; IS__CGSCC_NPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
613; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@complicated_args_byval
614; IS__CGSCC_NPM-SAME: () #[[ATTR1]] {
615; IS__CGSCC_NPM-NEXT:    ret void
616;
617  call void @test_byval(%struct.X* byval(%struct.X) @S)
618  ret void
619}
620
621declare void @sync()
622; Make sure we *do not* load @S here!
623define internal i8*@test_byval2(%struct.X* byval(%struct.X) %a) {
624; IS________OPM-LABEL: define {{[^@]+}}@test_byval2
625; IS________OPM-SAME: (%struct.X* noalias nocapture nofree noundef nonnull readonly byval([[STRUCT_X:%.*]]) align 8 dereferenceable(8) [[A:%.*]]) {
626; IS________OPM-NEXT:    call void @sync()
627; IS________OPM-NEXT:    [[G0:%.*]] = getelementptr [[STRUCT_X]], %struct.X* [[A]], i32 0, i32 0
628; IS________OPM-NEXT:    [[L:%.*]] = load i8*, i8** [[G0]], align 8
629; IS________OPM-NEXT:    ret i8* [[L]]
630;
631; IS__TUNIT_NPM-LABEL: define {{[^@]+}}@test_byval2
632; IS__TUNIT_NPM-SAME: (i8* [[TMP0:%.*]]) {
633; IS__TUNIT_NPM-NEXT:    [[A_PRIV:%.*]] = alloca [[STRUCT_X:%.*]], align 8
634; IS__TUNIT_NPM-NEXT:    [[A_PRIV_CAST:%.*]] = bitcast %struct.X* [[A_PRIV]] to i8**
635; IS__TUNIT_NPM-NEXT:    store i8* [[TMP0]], i8** [[A_PRIV_CAST]], align 8
636; IS__TUNIT_NPM-NEXT:    call void @sync()
637; IS__TUNIT_NPM-NEXT:    [[G0:%.*]] = getelementptr [[STRUCT_X]], %struct.X* [[A_PRIV]], i32 0, i32 0
638; IS__TUNIT_NPM-NEXT:    [[L:%.*]] = load i8*, i8** [[G0]], align 8
639; IS__TUNIT_NPM-NEXT:    ret i8* [[L]]
640;
641; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@test_byval2
642; IS__CGSCC_NPM-SAME: (i8* noalias nofree readnone returned "no-capture-maybe-returned" [[TMP0:%.*]]) {
643; IS__CGSCC_NPM-NEXT:    [[A_PRIV:%.*]] = alloca [[STRUCT_X:%.*]], align 8
644; IS__CGSCC_NPM-NEXT:    [[A_PRIV_CAST:%.*]] = bitcast %struct.X* [[A_PRIV]] to i8**
645; IS__CGSCC_NPM-NEXT:    store i8* [[TMP0]], i8** [[A_PRIV_CAST]], align 8
646; IS__CGSCC_NPM-NEXT:    call void @sync()
647; IS__CGSCC_NPM-NEXT:    [[G0:%.*]] = getelementptr [[STRUCT_X]], %struct.X* [[A_PRIV]], i32 0, i32 0
648; IS__CGSCC_NPM-NEXT:    [[L:%.*]] = load i8*, i8** [[G0]], align 8
649; IS__CGSCC_NPM-NEXT:    ret i8* [[TMP0]]
650;
651  call void @sync()
652  %g0 = getelementptr %struct.X, %struct.X* %a, i32 0, i32 0
653  %l = load i8*, i8** %g0
654  ret i8* %l
655}
656define i8* @complicated_args_byval2() {
657;
658; IS__TUNIT_OPM-LABEL: define {{[^@]+}}@complicated_args_byval2() {
659; IS__TUNIT_OPM-NEXT:    [[C:%.*]] = call i8* @test_byval2(%struct.X* nocapture nofree noundef nonnull readonly byval([[STRUCT_X:%.*]]) align 8 dereferenceable(8) @S)
660; IS__TUNIT_OPM-NEXT:    ret i8* [[C]]
661;
662; IS__TUNIT_NPM-LABEL: define {{[^@]+}}@complicated_args_byval2() {
663; IS__TUNIT_NPM-NEXT:    [[S_CAST:%.*]] = bitcast %struct.X* @S to i8**
664; IS__TUNIT_NPM-NEXT:    [[TMP1:%.*]] = load i8*, i8** [[S_CAST]], align 8
665; IS__TUNIT_NPM-NEXT:    [[C:%.*]] = call i8* @test_byval2(i8* [[TMP1]])
666; IS__TUNIT_NPM-NEXT:    ret i8* [[C]]
667;
668; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@complicated_args_byval2() {
669; IS__CGSCC_OPM-NEXT:    [[C:%.*]] = call i8* @test_byval2(%struct.X* noalias nocapture nofree noundef nonnull readonly byval([[STRUCT_X:%.*]]) align 8 dereferenceable(8) @S)
670; IS__CGSCC_OPM-NEXT:    ret i8* [[C]]
671;
672; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@complicated_args_byval2() {
673; IS__CGSCC_NPM-NEXT:    [[TMP1:%.*]] = load i8*, i8** getelementptr inbounds ([[STRUCT_X:%.*]], %struct.X* @S, i32 0, i32 0), align 8
674; IS__CGSCC_NPM-NEXT:    [[C:%.*]] = call i8* @test_byval2(i8* noalias nofree readnone "no-capture-maybe-returned" [[TMP1]])
675; IS__CGSCC_NPM-NEXT:    ret i8* [[TMP1]]
676;
677  %c = call i8* @test_byval2(%struct.X* byval(%struct.X) @S)
678  ret i8* %c
679}
680
681define void @fixpoint_changed(i32* %p) {
682; IS__TUNIT_OPM: Function Attrs: argmemonly nofree nosync nounwind writeonly
683; IS__TUNIT_OPM-LABEL: define {{[^@]+}}@fixpoint_changed
684; IS__TUNIT_OPM-SAME: (i32* nocapture nofree writeonly [[P:%.*]]) #[[ATTR4:[0-9]+]] {
685; IS__TUNIT_OPM-NEXT:  entry:
686; IS__TUNIT_OPM-NEXT:    br label [[FOR_COND:%.*]]
687; IS__TUNIT_OPM:       for.cond:
688; IS__TUNIT_OPM-NEXT:    [[J_0:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[INC:%.*]], [[SW_EPILOG:%.*]] ]
689; IS__TUNIT_OPM-NEXT:    [[CMP:%.*]] = icmp slt i32 [[J_0]], 30
690; IS__TUNIT_OPM-NEXT:    br i1 [[CMP]], label [[FOR_BODY:%.*]], label [[FOR_END:%.*]]
691; IS__TUNIT_OPM:       for.body:
692; IS__TUNIT_OPM-NEXT:    switch i32 [[J_0]], label [[SW_EPILOG]] [
693; IS__TUNIT_OPM-NEXT:    i32 1, label [[SW_BB:%.*]]
694; IS__TUNIT_OPM-NEXT:    ]
695; IS__TUNIT_OPM:       sw.bb:
696; IS__TUNIT_OPM-NEXT:    br label [[SW_EPILOG]]
697; IS__TUNIT_OPM:       sw.epilog:
698; IS__TUNIT_OPM-NEXT:    [[X_0:%.*]] = phi i32 [ 255, [[FOR_BODY]] ], [ 253, [[SW_BB]] ]
699; IS__TUNIT_OPM-NEXT:    store i32 [[X_0]], i32* [[P]], align 4
700; IS__TUNIT_OPM-NEXT:    [[INC]] = add nsw i32 [[J_0]], 1
701; IS__TUNIT_OPM-NEXT:    br label [[FOR_COND]]
702; IS__TUNIT_OPM:       for.end:
703; IS__TUNIT_OPM-NEXT:    ret void
704;
705; IS__TUNIT_NPM: Function Attrs: argmemonly nofree nosync nounwind willreturn writeonly
706; IS__TUNIT_NPM-LABEL: define {{[^@]+}}@fixpoint_changed
707; IS__TUNIT_NPM-SAME: (i32* nocapture nofree writeonly [[P:%.*]]) #[[ATTR2]] {
708; IS__TUNIT_NPM-NEXT:  entry:
709; IS__TUNIT_NPM-NEXT:    br label [[FOR_COND:%.*]]
710; IS__TUNIT_NPM:       for.cond:
711; IS__TUNIT_NPM-NEXT:    [[J_0:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[INC:%.*]], [[SW_EPILOG:%.*]] ]
712; IS__TUNIT_NPM-NEXT:    [[CMP:%.*]] = icmp slt i32 [[J_0]], 30
713; IS__TUNIT_NPM-NEXT:    br i1 [[CMP]], label [[FOR_BODY:%.*]], label [[FOR_END:%.*]]
714; IS__TUNIT_NPM:       for.body:
715; IS__TUNIT_NPM-NEXT:    switch i32 [[J_0]], label [[SW_EPILOG]] [
716; IS__TUNIT_NPM-NEXT:    i32 1, label [[SW_BB:%.*]]
717; IS__TUNIT_NPM-NEXT:    ]
718; IS__TUNIT_NPM:       sw.bb:
719; IS__TUNIT_NPM-NEXT:    br label [[SW_EPILOG]]
720; IS__TUNIT_NPM:       sw.epilog:
721; IS__TUNIT_NPM-NEXT:    [[X_0:%.*]] = phi i32 [ 255, [[FOR_BODY]] ], [ 253, [[SW_BB]] ]
722; IS__TUNIT_NPM-NEXT:    store i32 [[X_0]], i32* [[P]], align 4
723; IS__TUNIT_NPM-NEXT:    [[INC]] = add nsw i32 [[J_0]], 1
724; IS__TUNIT_NPM-NEXT:    br label [[FOR_COND]]
725; IS__TUNIT_NPM:       for.end:
726; IS__TUNIT_NPM-NEXT:    ret void
727;
728; IS__CGSCC_OPM: Function Attrs: argmemonly nofree norecurse nosync nounwind writeonly
729; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@fixpoint_changed
730; IS__CGSCC_OPM-SAME: (i32* nocapture nofree writeonly [[P:%.*]]) #[[ATTR3:[0-9]+]] {
731; IS__CGSCC_OPM-NEXT:  entry:
732; IS__CGSCC_OPM-NEXT:    br label [[FOR_COND:%.*]]
733; IS__CGSCC_OPM:       for.cond:
734; IS__CGSCC_OPM-NEXT:    [[J_0:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[INC:%.*]], [[SW_EPILOG:%.*]] ]
735; IS__CGSCC_OPM-NEXT:    [[CMP:%.*]] = icmp slt i32 [[J_0]], 30
736; IS__CGSCC_OPM-NEXT:    br i1 [[CMP]], label [[FOR_BODY:%.*]], label [[FOR_END:%.*]]
737; IS__CGSCC_OPM:       for.body:
738; IS__CGSCC_OPM-NEXT:    switch i32 [[J_0]], label [[SW_EPILOG]] [
739; IS__CGSCC_OPM-NEXT:    i32 1, label [[SW_BB:%.*]]
740; IS__CGSCC_OPM-NEXT:    ]
741; IS__CGSCC_OPM:       sw.bb:
742; IS__CGSCC_OPM-NEXT:    br label [[SW_EPILOG]]
743; IS__CGSCC_OPM:       sw.epilog:
744; IS__CGSCC_OPM-NEXT:    [[X_0:%.*]] = phi i32 [ 255, [[FOR_BODY]] ], [ 253, [[SW_BB]] ]
745; IS__CGSCC_OPM-NEXT:    store i32 [[X_0]], i32* [[P]], align 4
746; IS__CGSCC_OPM-NEXT:    [[INC]] = add nsw i32 [[J_0]], 1
747; IS__CGSCC_OPM-NEXT:    br label [[FOR_COND]]
748; IS__CGSCC_OPM:       for.end:
749; IS__CGSCC_OPM-NEXT:    ret void
750;
751; IS__CGSCC_NPM: Function Attrs: argmemonly nofree norecurse nosync nounwind willreturn writeonly
752; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@fixpoint_changed
753; IS__CGSCC_NPM-SAME: (i32* nocapture nofree writeonly [[P:%.*]]) #[[ATTR2]] {
754; IS__CGSCC_NPM-NEXT:  entry:
755; IS__CGSCC_NPM-NEXT:    br label [[FOR_COND:%.*]]
756; IS__CGSCC_NPM:       for.cond:
757; IS__CGSCC_NPM-NEXT:    [[J_0:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[INC:%.*]], [[SW_EPILOG:%.*]] ]
758; IS__CGSCC_NPM-NEXT:    [[CMP:%.*]] = icmp slt i32 [[J_0]], 30
759; IS__CGSCC_NPM-NEXT:    br i1 [[CMP]], label [[FOR_BODY:%.*]], label [[FOR_END:%.*]]
760; IS__CGSCC_NPM:       for.body:
761; IS__CGSCC_NPM-NEXT:    switch i32 [[J_0]], label [[SW_EPILOG]] [
762; IS__CGSCC_NPM-NEXT:    i32 1, label [[SW_BB:%.*]]
763; IS__CGSCC_NPM-NEXT:    ]
764; IS__CGSCC_NPM:       sw.bb:
765; IS__CGSCC_NPM-NEXT:    br label [[SW_EPILOG]]
766; IS__CGSCC_NPM:       sw.epilog:
767; IS__CGSCC_NPM-NEXT:    [[X_0:%.*]] = phi i32 [ 255, [[FOR_BODY]] ], [ 253, [[SW_BB]] ]
768; IS__CGSCC_NPM-NEXT:    store i32 [[X_0]], i32* [[P]], align 4
769; IS__CGSCC_NPM-NEXT:    [[INC]] = add nsw i32 [[J_0]], 1
770; IS__CGSCC_NPM-NEXT:    br label [[FOR_COND]]
771; IS__CGSCC_NPM:       for.end:
772; IS__CGSCC_NPM-NEXT:    ret void
773;
774entry:
775  br label %for.cond
776
777for.cond:
778  %j.0 = phi i32 [ 0, %entry ], [ %inc, %sw.epilog ]
779  %cmp = icmp slt i32 %j.0, 30
780  br i1 %cmp, label %for.body, label %for.end
781
782for.body:
783  switch i32 %j.0, label %sw.epilog [
784  i32 1, label %sw.bb
785  ]
786
787sw.bb:
788  br label %sw.epilog
789
790sw.epilog:
791  %x.0 = phi i32 [ 255, %for.body ], [ 253, %sw.bb ]
792  store i32 %x.0, i32* %p
793  %inc = add nsw i32 %j.0, 1
794  br label %for.cond
795
796for.end:
797  ret void
798}
799
800; Check we merge undef and a constant properly.
801define i8 @caller0() {
802; IS__TUNIT____: Function Attrs: nofree nosync nounwind readnone willreturn
803; IS__TUNIT____-LABEL: define {{[^@]+}}@caller0
804; IS__TUNIT____-SAME: () #[[ATTR1]] {
805; IS__TUNIT____-NEXT:    ret i8 49
806;
807; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
808; IS__CGSCC____-LABEL: define {{[^@]+}}@caller0
809; IS__CGSCC____-SAME: () #[[ATTR1]] {
810; IS__CGSCC____-NEXT:    ret i8 49
811;
812  %c = call i8 @callee(i8 undef)
813  ret i8 %c
814}
815define i8 @caller1() {
816; IS__TUNIT____: Function Attrs: nofree nosync nounwind readnone willreturn
817; IS__TUNIT____-LABEL: define {{[^@]+}}@caller1
818; IS__TUNIT____-SAME: () #[[ATTR1]] {
819; IS__TUNIT____-NEXT:    ret i8 49
820;
821; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
822; IS__CGSCC____-LABEL: define {{[^@]+}}@caller1
823; IS__CGSCC____-SAME: () #[[ATTR1]] {
824; IS__CGSCC____-NEXT:    ret i8 49
825;
826  %c = call i8 @callee(i8 undef)
827  ret i8 %c
828}
829define i8 @caller2() {
830; IS__TUNIT____: Function Attrs: nofree nosync nounwind readnone willreturn
831; IS__TUNIT____-LABEL: define {{[^@]+}}@caller2
832; IS__TUNIT____-SAME: () #[[ATTR1]] {
833; IS__TUNIT____-NEXT:    ret i8 49
834;
835; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
836; IS__CGSCC____-LABEL: define {{[^@]+}}@caller2
837; IS__CGSCC____-SAME: () #[[ATTR1]] {
838; IS__CGSCC____-NEXT:    ret i8 49
839;
840  %c = call i8 @callee(i8 undef)
841  ret i8 %c
842}
843define i8 @caller_middle() {
844; IS__TUNIT____: Function Attrs: nofree nosync nounwind readnone willreturn
845; IS__TUNIT____-LABEL: define {{[^@]+}}@caller_middle
846; IS__TUNIT____-SAME: () #[[ATTR1]] {
847; IS__TUNIT____-NEXT:    ret i8 49
848;
849; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
850; IS__CGSCC____-LABEL: define {{[^@]+}}@caller_middle
851; IS__CGSCC____-SAME: () #[[ATTR1]] {
852; IS__CGSCC____-NEXT:    ret i8 49
853;
854  %c = call i8 @callee(i8 42)
855  ret i8 %c
856}
857define i8 @caller3() {
858; IS__TUNIT____: Function Attrs: nofree nosync nounwind readnone willreturn
859; IS__TUNIT____-LABEL: define {{[^@]+}}@caller3
860; IS__TUNIT____-SAME: () #[[ATTR1]] {
861; IS__TUNIT____-NEXT:    ret i8 49
862;
863; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
864; IS__CGSCC____-LABEL: define {{[^@]+}}@caller3
865; IS__CGSCC____-SAME: () #[[ATTR1]] {
866; IS__CGSCC____-NEXT:    ret i8 49
867;
868  %c = call i8 @callee(i8 undef)
869  ret i8 %c
870}
871define i8 @caller4() {
872; IS__TUNIT____: Function Attrs: nofree nosync nounwind readnone willreturn
873; IS__TUNIT____-LABEL: define {{[^@]+}}@caller4
874; IS__TUNIT____-SAME: () #[[ATTR1]] {
875; IS__TUNIT____-NEXT:    ret i8 49
876;
877; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
878; IS__CGSCC____-LABEL: define {{[^@]+}}@caller4
879; IS__CGSCC____-SAME: () #[[ATTR1]] {
880; IS__CGSCC____-NEXT:    ret i8 49
881;
882  %c = call i8 @callee(i8 undef)
883  ret i8 %c
884}
885define internal i8 @callee(i8 %a) {
886; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
887; IS__CGSCC____-LABEL: define {{[^@]+}}@callee
888; IS__CGSCC____-SAME: () #[[ATTR1]] {
889; IS__CGSCC____-NEXT:    ret i8 undef
890;
891  %c = add i8 %a, 7
892  ret i8 %c
893}
894
895define void @user_as3() {
896; IS__TUNIT____: Function Attrs: nofree nosync nounwind willreturn writeonly
897; IS__TUNIT____-LABEL: define {{[^@]+}}@user_as3
898; IS__TUNIT____-SAME: () #[[ATTR3]] {
899; IS__TUNIT____-NEXT:    store i32 0, i32 addrspace(3)* @ConstAS3Ptr, align 4
900; IS__TUNIT____-NEXT:    ret void
901;
902; IS__CGSCC_OPM: Function Attrs: nofree norecurse nosync nounwind willreturn writeonly
903; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@user_as3
904; IS__CGSCC_OPM-SAME: () #[[ATTR4:[0-9]+]] {
905; IS__CGSCC_OPM-NEXT:    store i32 0, i32 addrspace(3)* @ConstAS3Ptr, align 4
906; IS__CGSCC_OPM-NEXT:    ret void
907;
908; IS__CGSCC_NPM: Function Attrs: nofree norecurse nosync nounwind willreturn writeonly
909; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@user_as3
910; IS__CGSCC_NPM-SAME: () #[[ATTR3:[0-9]+]] {
911; IS__CGSCC_NPM-NEXT:    store i32 0, i32 addrspace(3)* @ConstAS3Ptr, align 4
912; IS__CGSCC_NPM-NEXT:    ret void
913;
914  %call = call fastcc i32 addrspace(3)* @const_ptr_return_as3()
915  store i32 0, i32 addrspace(3)* %call
916  ret void
917}
918define void @user() {
919; IS__TUNIT____: Function Attrs: nofree nosync nounwind willreturn writeonly
920; IS__TUNIT____-LABEL: define {{[^@]+}}@user
921; IS__TUNIT____-SAME: () #[[ATTR3]] {
922; IS__TUNIT____-NEXT:    store i32 0, i32* addrspacecast (i32 addrspace(3)* @ConstAS3Ptr to i32*), align 4
923; IS__TUNIT____-NEXT:    ret void
924;
925; IS__CGSCC_OPM: Function Attrs: nofree norecurse nosync nounwind willreturn writeonly
926; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@user
927; IS__CGSCC_OPM-SAME: () #[[ATTR4]] {
928; IS__CGSCC_OPM-NEXT:    store i32 0, i32* addrspacecast (i32 addrspace(3)* @ConstAS3Ptr to i32*), align 4
929; IS__CGSCC_OPM-NEXT:    ret void
930;
931; IS__CGSCC_NPM: Function Attrs: nofree norecurse nosync nounwind willreturn writeonly
932; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@user
933; IS__CGSCC_NPM-SAME: () #[[ATTR3]] {
934; IS__CGSCC_NPM-NEXT:    store i32 0, i32* addrspacecast (i32 addrspace(3)* @ConstAS3Ptr to i32*), align 4
935; IS__CGSCC_NPM-NEXT:    ret void
936;
937  %call = call fastcc i32* @const_ptr_return()
938  store i32 0, i32* %call
939  ret void
940}
941
942
943define i1 @test_merge_with_undef_values_ptr(i1 %c) {
944; IS__TUNIT____: Function Attrs: nofree nosync nounwind readnone willreturn
945; IS__TUNIT____-LABEL: define {{[^@]+}}@test_merge_with_undef_values_ptr
946; IS__TUNIT____-SAME: (i1 [[C:%.*]]) #[[ATTR1]] {
947; IS__TUNIT____-NEXT:    ret i1 false
948;
949; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
950; IS__CGSCC____-LABEL: define {{[^@]+}}@test_merge_with_undef_values_ptr
951; IS__CGSCC____-SAME: (i1 [[C:%.*]]) #[[ATTR1]] {
952; IS__CGSCC____-NEXT:    ret i1 false
953;
954  %r1 = call i1 @undef_then_null(i1 %c, i32* undef, i32* undef)
955  ret i1 %r1
956}
957define internal i1 @undef_then_null(i1 %c, i32* %i32Aptr, i32* %i32Bptr) {
958; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
959; IS__CGSCC____-LABEL: define {{[^@]+}}@undef_then_null
960; IS__CGSCC____-SAME: (i1 [[C:%.*]]) #[[ATTR1]] {
961; IS__CGSCC____-NEXT:    br i1 [[C]], label [[A:%.*]], label [[B:%.*]]
962; IS__CGSCC____:       a:
963; IS__CGSCC____-NEXT:    ret i1 undef
964; IS__CGSCC____:       b:
965; IS__CGSCC____-NEXT:    ret i1 undef
966;
967  %cmp1 = icmp eq i32* %i32Aptr, %i32Bptr
968  %cmp2 = icmp eq i1 %cmp1, false
969  %or = or i1 %cmp2, %c
970  br i1 %or, label %a, label %b
971a:
972  %r2 = call i1 @undef_then_null(i1 false, i32* null, i32* null)
973  ret i1 %r2
974b:
975  ret i1 %cmp2
976}
977
978define i1 @test_merge_with_undef_values(i1 %c) {
979; IS__TUNIT____: Function Attrs: nofree nosync nounwind readnone willreturn
980; IS__TUNIT____-LABEL: define {{[^@]+}}@test_merge_with_undef_values
981; IS__TUNIT____-SAME: (i1 [[C:%.*]]) #[[ATTR1]] {
982; IS__TUNIT____-NEXT:    ret i1 false
983;
984; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
985; IS__CGSCC____-LABEL: define {{[^@]+}}@test_merge_with_undef_values
986; IS__CGSCC____-SAME: (i1 [[C:%.*]]) #[[ATTR1]] {
987; IS__CGSCC____-NEXT:    ret i1 false
988;
989  %r1 = call i1 @undef_then_1(i1 %c, i32 undef, i32 undef)
990  ret i1 %r1
991}
992define internal i1 @undef_then_1(i1 %c, i32 %i32A, i32 %i32B) {
993;
994; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
995; IS__CGSCC____-LABEL: define {{[^@]+}}@undef_then_1
996; IS__CGSCC____-SAME: (i1 [[C:%.*]]) #[[ATTR1]] {
997; IS__CGSCC____-NEXT:    br i1 [[C]], label [[A:%.*]], label [[B:%.*]]
998; IS__CGSCC____:       a:
999; IS__CGSCC____-NEXT:    ret i1 undef
1000; IS__CGSCC____:       b:
1001; IS__CGSCC____-NEXT:    ret i1 undef
1002;
1003  %cmp1 = icmp eq i32 %i32A, %i32B
1004  %cmp2 = icmp eq i1 %cmp1, false
1005  %or = or i1 %cmp2, %c
1006  br i1 %or, label %a, label %b
1007a:
1008  %r2 = call i1 @undef_then_1(i1 false, i32 1, i32 1)
1009  ret i1 %r2
1010b:
1011  ret i1 %cmp2
1012}
1013
1014define i32 @test_select(i32 %c) {
1015; IS__TUNIT____: Function Attrs: nofree nosync nounwind readnone willreturn
1016; IS__TUNIT____-LABEL: define {{[^@]+}}@test_select
1017; IS__TUNIT____-SAME: (i32 [[C:%.*]]) #[[ATTR1]] {
1018; IS__TUNIT____-NEXT:    ret i32 42
1019;
1020; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1021; IS__CGSCC____-LABEL: define {{[^@]+}}@test_select
1022; IS__CGSCC____-SAME: (i32 [[C:%.*]]) #[[ATTR1]] {
1023; IS__CGSCC____-NEXT:    ret i32 42
1024;
1025  %call = call i32 @select(i1 1, i32 42, i32 %c)
1026  ret i32 %call
1027}
1028
1029define internal i32 @select(i1 %a, i32 %b, i32 %c) {
1030; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1031; IS__CGSCC____-LABEL: define {{[^@]+}}@select
1032; IS__CGSCC____-SAME: () #[[ATTR1]] {
1033; IS__CGSCC____-NEXT:    ret i32 undef
1034;
1035  %s = select i1 %a, i32 %b, i32 %c
1036  ret i32 %s
1037}
1038
1039define i1 @icmp() {
1040; IS__TUNIT____: Function Attrs: nofree nosync nounwind readnone willreturn
1041; IS__TUNIT____-LABEL: define {{[^@]+}}@icmp
1042; IS__TUNIT____-SAME: () #[[ATTR1]] {
1043; IS__TUNIT____-NEXT:    ret i1 true
1044;
1045; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1046; IS__CGSCC____-LABEL: define {{[^@]+}}@icmp
1047; IS__CGSCC____-SAME: () #[[ATTR1]] {
1048; IS__CGSCC____-NEXT:    ret i1 true
1049;
1050  %c = icmp eq i8* null, null
1051  ret i1 %c
1052}
1053
1054define void @test_callee_is_undef(void (i32)* %fn) {
1055; IS__TUNIT____-LABEL: define {{[^@]+}}@test_callee_is_undef
1056; IS__TUNIT____-SAME: (void (i32)* nocapture nofree [[FN:%.*]]) {
1057; IS__TUNIT____-NEXT:    call void @callee_is_undef()
1058; IS__TUNIT____-NEXT:    call void @unknown_calle_arg_is_undef(void (i32)* nocapture nofree [[FN]])
1059; IS__TUNIT____-NEXT:    ret void
1060;
1061; IS__CGSCC____-LABEL: define {{[^@]+}}@test_callee_is_undef
1062; IS__CGSCC____-SAME: (void (i32)* nocapture nofree [[FN:%.*]]) {
1063; IS__CGSCC____-NEXT:    unreachable
1064;
1065  call void @callee_is_undef(void ()* undef)
1066  call void @unknown_calle_arg_is_undef(void (i32)* %fn, i32 undef)
1067  ret void
1068}
1069define internal void @callee_is_undef(void ()* %fn) {
1070;
1071; IS__TUNIT____-LABEL: define {{[^@]+}}@callee_is_undef() {
1072; IS__TUNIT____-NEXT:    call void undef()
1073; IS__TUNIT____-NEXT:    ret void
1074;
1075; IS__CGSCC____-LABEL: define {{[^@]+}}@callee_is_undef
1076; IS__CGSCC____-SAME: (void ()* nocapture nofree noundef nonnull [[FN:%.*]]) {
1077; IS__CGSCC____-NEXT:    call void [[FN]]()
1078; IS__CGSCC____-NEXT:    ret void
1079;
1080  call void %fn()
1081  ret void
1082}
1083define internal void @unknown_calle_arg_is_undef(void (i32)* %fn, i32 %arg) {
1084;
1085; CHECK-LABEL: define {{[^@]+}}@unknown_calle_arg_is_undef
1086; CHECK-SAME: (void (i32)* nocapture nofree noundef nonnull [[FN:%.*]]) {
1087; CHECK-NEXT:    call void [[FN]](i32 undef)
1088; CHECK-NEXT:    ret void
1089;
1090  call void %fn(i32 %arg)
1091  ret void
1092}
1093
1094; Taken from 50683
1095; {{{
1096
1097@g = internal constant { [2 x i8*] } { [2 x i8*] [i8* bitcast (void (i8***)* @f1 to i8*), i8* bitcast (void (i1 (i8*)*)* @f2 to i8*)] }
1098
1099define internal void @f1(i8*** %a) {
1100; IS__TUNIT____: Function Attrs: argmemonly nofree nosync nounwind willreturn writeonly
1101; IS__TUNIT____-LABEL: define {{[^@]+}}@f1
1102; IS__TUNIT____-SAME: (i8*** nocapture nofree noundef nonnull writeonly align 8 dereferenceable(8) [[A:%.*]]) #[[ATTR2]] {
1103; IS__TUNIT____-NEXT:  entry:
1104; IS__TUNIT____-NEXT:    [[X:%.*]] = getelementptr { [2 x i8*] }, { [2 x i8*] }* @g, i32 0, i32 0, i32 0
1105; IS__TUNIT____-NEXT:    store i8** [[X]], i8*** [[A]], align 8
1106; IS__TUNIT____-NEXT:    ret void
1107;
1108; IS__CGSCC____: Function Attrs: argmemonly nofree norecurse nosync nounwind willreturn writeonly
1109; IS__CGSCC____-LABEL: define {{[^@]+}}@f1
1110; IS__CGSCC____-SAME: (i8*** nocapture nofree noundef nonnull writeonly align 8 dereferenceable(8) [[A:%.*]]) #[[ATTR2]] {
1111; IS__CGSCC____-NEXT:  entry:
1112; IS__CGSCC____-NEXT:    [[X:%.*]] = getelementptr { [2 x i8*] }, { [2 x i8*] }* @g, i32 0, i32 0, i32 0
1113; IS__CGSCC____-NEXT:    store i8** [[X]], i8*** [[A]], align 8
1114; IS__CGSCC____-NEXT:    ret void
1115;
1116entry:
1117  %x = getelementptr { [2 x i8*] }, { [2 x i8*] }* @g, i32 0, i32 0, i32 0
1118  store i8** %x , i8*** %a, align 8
1119  ret void
1120}
1121
1122define internal void @f2(i1 (i8*)* %a) {
1123; CHECK-LABEL: define {{[^@]+}}@f2
1124; CHECK-SAME: (i1 (i8*)* [[A:%.*]]) {
1125; CHECK-NEXT:  cont461:
1126; CHECK-NEXT:    [[C1:%.*]] = bitcast i1 (i8*)* [[A]] to i8*
1127; CHECK-NEXT:    call void @f3(i8* [[C1]], i1 (i8*)* nocapture nofree [[A]])
1128; CHECK-NEXT:    ret void
1129;
1130cont461:
1131  %c1 = bitcast i1 (i8*)* %a to i8*
1132  call void @f3(i8* %c1, i1 (i8*)* %a)
1133  ret void
1134}
1135
1136define internal void @f3(i8* %a1, i1 (i8*)* %a) {
1137; CHECK-LABEL: define {{[^@]+}}@f3
1138; CHECK-SAME: (i8* [[A1:%.*]], i1 (i8*)* nocapture nofree [[A:%.*]]) {
1139; CHECK-NEXT:  entry:
1140; CHECK-NEXT:    [[CALL20:%.*]] = call i1 @f9()
1141; CHECK-NEXT:    br i1 [[CALL20]], label [[LAND_LHS_TRUE:%.*]], label [[IF_END40:%.*]]
1142; CHECK:       land.lhs.true:
1143; CHECK-NEXT:    [[TMP0:%.*]] = call i1 [[A]](i8* [[A1]])
1144; CHECK-NEXT:    br label [[IF_END40]]
1145; CHECK:       if.end40:
1146; CHECK-NEXT:    ret void
1147;
1148entry:
1149  %call20 = call i1 @f9()
1150  br i1 %call20, label %land.lhs.true, label %if.end40
1151
1152land.lhs.true:
1153  call i1 %a(i8* %a1)
1154  br label %if.end40
1155
1156if.end40:
1157  ret void
1158}
1159
1160define linkonce_odr i1 @f9() {
1161; CHECK-LABEL: define {{[^@]+}}@f9() {
1162; CHECK-NEXT:  entry:
1163; CHECK-NEXT:    ret i1 false
1164;
1165entry:
1166  ret i1 false
1167}
1168
1169; }}}
1170
1171
1172define i1 @test_cmp_null_after_cast() {
1173; IS__TUNIT____: Function Attrs: nofree nosync nounwind readnone willreturn
1174; IS__TUNIT____-LABEL: define {{[^@]+}}@test_cmp_null_after_cast
1175; IS__TUNIT____-SAME: () #[[ATTR1]] {
1176; IS__TUNIT____-NEXT:    ret i1 true
1177;
1178; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1179; IS__CGSCC____-LABEL: define {{[^@]+}}@test_cmp_null_after_cast
1180; IS__CGSCC____-SAME: () #[[ATTR1]] {
1181; IS__CGSCC____-NEXT:    ret i1 true
1182;
1183  %c = call i1 @cmp_null_after_cast(i32 0, i8 0)
1184  ret i1 %c
1185}
1186define internal i1 @cmp_null_after_cast(i32 %a, i8 %b) {
1187; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1188; IS__CGSCC____-LABEL: define {{[^@]+}}@cmp_null_after_cast
1189; IS__CGSCC____-SAME: () #[[ATTR1]] {
1190; IS__CGSCC____-NEXT:    ret i1 undef
1191;
1192  %t = trunc i32 %a to i8
1193  %c = icmp eq i8 %t, %b
1194  ret i1 %c
1195}
1196
1197
1198declare i8* @m()
1199
1200define i32 @test(i1 %c) {
1201; CHECK-LABEL: define {{[^@]+}}@test
1202; CHECK-SAME: (i1 [[C:%.*]]) {
1203; CHECK-NEXT:    [[R1:%.*]] = call i32 @ctx_test1(i1 [[C]])
1204; CHECK-NEXT:    [[R2:%.*]] = call i32 @ctx_test2(i1 [[C]]), !range [[RNG0:![0-9]+]]
1205; CHECK-NEXT:    [[ADD:%.*]] = add i32 [[R1]], [[R2]]
1206; CHECK-NEXT:    ret i32 [[ADD]]
1207;
1208  %r1 = call i32 @ctx_test1(i1 %c)
1209  %r2 = call i32 @ctx_test2(i1 %c)
1210  %add = add i32 %r1, %r2
1211  ret i32 %add
1212}
1213
1214define internal i32 @ctx_test1(i1 %c) {
1215; CHECK-LABEL: define {{[^@]+}}@ctx_test1
1216; CHECK-SAME: (i1 [[C:%.*]]) {
1217; CHECK-NEXT:  entry:
1218; CHECK-NEXT:    br i1 [[C]], label [[THEN:%.*]], label [[JOIN:%.*]]
1219; CHECK:       then:
1220; CHECK-NEXT:    [[M:%.*]] = tail call i8* @m()
1221; CHECK-NEXT:    [[I:%.*]] = ptrtoint i8* [[M]] to i64
1222; CHECK-NEXT:    br label [[JOIN]]
1223; CHECK:       join:
1224; CHECK-NEXT:    [[PHI:%.*]] = phi i64 [ [[I]], [[THEN]] ], [ undef, [[ENTRY:%.*]] ]
1225; CHECK-NEXT:    [[RET:%.*]] = trunc i64 [[PHI]] to i32
1226; CHECK-NEXT:    ret i32 [[RET]]
1227;
1228entry:
1229  br i1 %c, label %then, label %join
1230
1231then:
1232  %m = tail call i8* @m()
1233  %i = ptrtoint i8* %m to i64
1234  br label %join
1235
1236join:
1237  %phi = phi i64 [ %i, %then ], [ undef, %entry ]
1238  %ret = trunc i64 %phi to i32
1239  ret i32 %ret
1240}
1241
1242define internal i32 @ctx_test2(i1 %c) {
1243; CHECK-LABEL: define {{[^@]+}}@ctx_test2
1244; CHECK-SAME: (i1 [[C:%.*]]) {
1245; CHECK-NEXT:  entry:
1246; CHECK-NEXT:    br i1 [[C]], label [[THEN:%.*]], label [[JOIN:%.*]]
1247; CHECK:       then:
1248; CHECK-NEXT:    [[M:%.*]] = tail call i8* @m()
1249; CHECK-NEXT:    [[I:%.*]] = ptrtoint i8* [[M]] to i32
1250; CHECK-NEXT:    br label [[JOIN]]
1251; CHECK:       join:
1252; CHECK-NEXT:    [[PHI:%.*]] = phi i32 [ [[I]], [[THEN]] ], [ undef, [[ENTRY:%.*]] ]
1253; CHECK-NEXT:    [[RET:%.*]] = lshr i32 [[PHI]], 1
1254; CHECK-NEXT:    ret i32 [[RET]]
1255;
1256entry:
1257  br i1 %c, label %then, label %join
1258
1259then:
1260  %m = tail call i8* @m()
1261  %i = ptrtoint i8* %m to i32
1262  br label %join
1263
1264join:
1265  %phi = phi i32 [ %i, %then ], [ undef, %entry ]
1266  %ret = lshr i32 %phi, 1
1267  ret i32 %ret
1268
1269  uselistorder label %join, { 1, 0 }
1270}
1271
1272;.
1273; IS__TUNIT_OPM: attributes #[[ATTR0]] = { nofree nosync nounwind willreturn }
1274; IS__TUNIT_OPM: attributes #[[ATTR1]] = { nofree nosync nounwind readnone willreturn }
1275; IS__TUNIT_OPM: attributes #[[ATTR2]] = { argmemonly nofree nosync nounwind willreturn writeonly }
1276; IS__TUNIT_OPM: attributes #[[ATTR3]] = { nofree nosync nounwind willreturn writeonly }
1277; IS__TUNIT_OPM: attributes #[[ATTR4]] = { argmemonly nofree nosync nounwind writeonly }
1278; IS__TUNIT_OPM: attributes #[[ATTR5]] = { willreturn }
1279;.
1280; IS__TUNIT_NPM: attributes #[[ATTR0]] = { nofree nosync nounwind willreturn }
1281; IS__TUNIT_NPM: attributes #[[ATTR1]] = { nofree nosync nounwind readnone willreturn }
1282; IS__TUNIT_NPM: attributes #[[ATTR2]] = { argmemonly nofree nosync nounwind willreturn writeonly }
1283; IS__TUNIT_NPM: attributes #[[ATTR3]] = { nofree nosync nounwind willreturn writeonly }
1284; IS__TUNIT_NPM: attributes #[[ATTR4]] = { willreturn }
1285;.
1286; IS__CGSCC_OPM: attributes #[[ATTR0]] = { nofree nosync nounwind willreturn }
1287; IS__CGSCC_OPM: attributes #[[ATTR1]] = { nofree norecurse nosync nounwind readnone willreturn }
1288; IS__CGSCC_OPM: attributes #[[ATTR2]] = { argmemonly nofree norecurse nosync nounwind willreturn writeonly }
1289; IS__CGSCC_OPM: attributes #[[ATTR3]] = { argmemonly nofree norecurse nosync nounwind writeonly }
1290; IS__CGSCC_OPM: attributes #[[ATTR4]] = { nofree norecurse nosync nounwind willreturn writeonly }
1291; IS__CGSCC_OPM: attributes #[[ATTR5]] = { willreturn }
1292; IS__CGSCC_OPM: attributes #[[ATTR6]] = { nounwind willreturn writeonly }
1293;.
1294; IS__CGSCC_NPM: attributes #[[ATTR0]] = { nofree nosync nounwind willreturn }
1295; IS__CGSCC_NPM: attributes #[[ATTR1]] = { nofree norecurse nosync nounwind readnone willreturn }
1296; IS__CGSCC_NPM: attributes #[[ATTR2]] = { argmemonly nofree norecurse nosync nounwind willreturn writeonly }
1297; IS__CGSCC_NPM: attributes #[[ATTR3]] = { nofree norecurse nosync nounwind willreturn writeonly }
1298; IS__CGSCC_NPM: attributes #[[ATTR4]] = { willreturn }
1299;.
1300; CHECK: [[RNG0]] = !{i32 0, i32 -2147483648}
1301;.
1302