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=9 -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=9 -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:e-i64:64-f80:128-n8:16:32:64-S128"
8
9; Test cases specifically designed for "align" attribute.
10; We use FIXME's to indicate problems and missing attributes.
11
12
13; TEST 1
14;;
15;.
16; CHECK: @[[A1:[a-zA-Z0-9_$"\\.-]+]] = common global i8 0, align 8
17; CHECK: @[[A2:[a-zA-Z0-9_$"\\.-]+]] = common global i8 0, align 16
18; CHECK: @[[CND:[a-zA-Z0-9_$"\\.-]+]] = external global i1
19;.
20define i32* @test1(i32* align 8 %0) #0 {
21; IS__TUNIT____: Function Attrs: nofree noinline nosync nounwind readnone uwtable willreturn
22; IS__TUNIT____-LABEL: define {{[^@]+}}@test1
23; IS__TUNIT____-SAME: (i32* nofree readnone returned align 8 "no-capture-maybe-returned" [[TMP0:%.*]]) #[[ATTR0:[0-9]+]] {
24; IS__TUNIT____-NEXT:    ret i32* [[TMP0]]
25;
26; IS__CGSCC____: Function Attrs: nofree noinline norecurse nosync nounwind readnone uwtable willreturn
27; IS__CGSCC____-LABEL: define {{[^@]+}}@test1
28; IS__CGSCC____-SAME: (i32* nofree readnone returned align 8 "no-capture-maybe-returned" [[TMP0:%.*]]) #[[ATTR0:[0-9]+]] {
29; IS__CGSCC____-NEXT:    ret i32* [[TMP0]]
30;
31  ret i32* %0
32}
33
34; TEST 2
35define i32* @test2(i32* %0) #0 {
36; IS__TUNIT____: Function Attrs: nofree noinline nosync nounwind readnone uwtable willreturn
37; IS__TUNIT____-LABEL: define {{[^@]+}}@test2
38; IS__TUNIT____-SAME: (i32* nofree readnone returned "no-capture-maybe-returned" [[TMP0:%.*]]) #[[ATTR0]] {
39; IS__TUNIT____-NEXT:    ret i32* [[TMP0]]
40;
41; IS__CGSCC____: Function Attrs: nofree noinline norecurse nosync nounwind readnone uwtable willreturn
42; IS__CGSCC____-LABEL: define {{[^@]+}}@test2
43; IS__CGSCC____-SAME: (i32* nofree readnone returned "no-capture-maybe-returned" [[TMP0:%.*]]) #[[ATTR0]] {
44; IS__CGSCC____-NEXT:    ret i32* [[TMP0]]
45;
46  ret i32* %0
47}
48
49; TEST 3
50define i32* @test3(i32* align 8 %0, i32* align 4 %1, i1 %2) #0 {
51; IS__TUNIT____: Function Attrs: nofree noinline nosync nounwind readnone uwtable willreturn
52; IS__TUNIT____-LABEL: define {{[^@]+}}@test3
53; IS__TUNIT____-SAME: (i32* nofree readnone align 8 "no-capture-maybe-returned" [[TMP0:%.*]], i32* nofree readnone align 4 "no-capture-maybe-returned" [[TMP1:%.*]], i1 [[TMP2:%.*]]) #[[ATTR0]] {
54; IS__TUNIT____-NEXT:    [[RET:%.*]] = select i1 [[TMP2]], i32* [[TMP0]], i32* [[TMP1]]
55; IS__TUNIT____-NEXT:    ret i32* [[RET]]
56;
57; IS__CGSCC____: Function Attrs: nofree noinline norecurse nosync nounwind readnone uwtable willreturn
58; IS__CGSCC____-LABEL: define {{[^@]+}}@test3
59; IS__CGSCC____-SAME: (i32* nofree readnone align 8 "no-capture-maybe-returned" [[TMP0:%.*]], i32* nofree readnone align 4 "no-capture-maybe-returned" [[TMP1:%.*]], i1 [[TMP2:%.*]]) #[[ATTR0]] {
60; IS__CGSCC____-NEXT:    [[RET:%.*]] = select i1 [[TMP2]], i32* [[TMP0]], i32* [[TMP1]]
61; IS__CGSCC____-NEXT:    ret i32* [[RET]]
62;
63  %ret = select i1 %2, i32* %0, i32* %1
64  ret i32* %ret
65}
66
67; TEST 4
68define i32* @test4(i32* align 32 %0, i32* align 32 %1, i1 %2) #0 {
69; IS__TUNIT____: Function Attrs: nofree noinline nosync nounwind readnone uwtable willreturn
70; IS__TUNIT____-LABEL: define {{[^@]+}}@test4
71; IS__TUNIT____-SAME: (i32* nofree readnone align 32 "no-capture-maybe-returned" [[TMP0:%.*]], i32* nofree readnone align 32 "no-capture-maybe-returned" [[TMP1:%.*]], i1 [[TMP2:%.*]]) #[[ATTR0]] {
72; IS__TUNIT____-NEXT:    [[RET:%.*]] = select i1 [[TMP2]], i32* [[TMP0]], i32* [[TMP1]]
73; IS__TUNIT____-NEXT:    ret i32* [[RET]]
74;
75; IS__CGSCC____: Function Attrs: nofree noinline norecurse nosync nounwind readnone uwtable willreturn
76; IS__CGSCC____-LABEL: define {{[^@]+}}@test4
77; IS__CGSCC____-SAME: (i32* nofree readnone align 32 "no-capture-maybe-returned" [[TMP0:%.*]], i32* nofree readnone align 32 "no-capture-maybe-returned" [[TMP1:%.*]], i1 [[TMP2:%.*]]) #[[ATTR0]] {
78; IS__CGSCC____-NEXT:    [[RET:%.*]] = select i1 [[TMP2]], i32* [[TMP0]], i32* [[TMP1]]
79; IS__CGSCC____-NEXT:    ret i32* [[RET]]
80;
81  %ret = select i1 %2, i32* %0, i32* %1
82  ret i32* %ret
83}
84
85; TEST 5
86declare i32* @unknown()
87declare align 8 i32* @align8()
88
89
90define i32* @test5_1() {
91; CHECK-LABEL: define {{[^@]+}}@test5_1() {
92; CHECK-NEXT:    [[RET:%.*]] = tail call align 8 i32* @unknown()
93; CHECK-NEXT:    ret i32* [[RET]]
94;
95  %ret = tail call align 8 i32* @unknown()
96  ret i32* %ret
97}
98
99define i32* @test5_2() {
100; CHECK-LABEL: define {{[^@]+}}@test5_2() {
101; CHECK-NEXT:    [[RET:%.*]] = tail call align 8 i32* @align8()
102; CHECK-NEXT:    ret i32* [[RET]]
103;
104  %ret = tail call i32* @align8()
105  ret i32* %ret
106}
107
108; TEST 6
109; SCC
110define i32* @test6_1() #0 {
111; IS__TUNIT____: Function Attrs: nofree noinline noreturn nosync nounwind readnone uwtable
112; IS__TUNIT____-LABEL: define {{[^@]+}}@test6_1
113; IS__TUNIT____-SAME: () #[[ATTR1:[0-9]+]] {
114; IS__TUNIT____-NEXT:    [[RET:%.*]] = tail call i32* @test6_2() #[[ATTR11:[0-9]+]]
115; IS__TUNIT____-NEXT:    unreachable
116;
117; IS__CGSCC_OPM: Function Attrs: nofree noinline noreturn nosync nounwind readnone uwtable
118; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@test6_1
119; IS__CGSCC_OPM-SAME: () #[[ATTR1:[0-9]+]] {
120; IS__CGSCC_OPM-NEXT:    [[RET:%.*]] = tail call i32* @test6_2() #[[ATTR13:[0-9]+]]
121; IS__CGSCC_OPM-NEXT:    unreachable
122;
123; IS__CGSCC_NPM: Function Attrs: nofree noinline noreturn nosync nounwind readnone uwtable
124; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@test6_1
125; IS__CGSCC_NPM-SAME: () #[[ATTR1:[0-9]+]] {
126; IS__CGSCC_NPM-NEXT:    [[RET:%.*]] = tail call i32* @test6_2() #[[ATTR12:[0-9]+]]
127; IS__CGSCC_NPM-NEXT:    unreachable
128;
129  %ret = tail call i32* @test6_2()
130  ret i32* %ret
131}
132
133define i32* @test6_2() #0 {
134; IS__TUNIT____: Function Attrs: nofree noinline noreturn nosync nounwind readnone uwtable
135; IS__TUNIT____-LABEL: define {{[^@]+}}@test6_2
136; IS__TUNIT____-SAME: () #[[ATTR1]] {
137; IS__TUNIT____-NEXT:    [[RET:%.*]] = tail call i32* @test6_1() #[[ATTR11]]
138; IS__TUNIT____-NEXT:    unreachable
139;
140; IS__CGSCC_OPM: Function Attrs: nofree noinline noreturn nosync nounwind readnone uwtable
141; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@test6_2
142; IS__CGSCC_OPM-SAME: () #[[ATTR1]] {
143; IS__CGSCC_OPM-NEXT:    [[RET:%.*]] = tail call i32* @test6_1() #[[ATTR13]]
144; IS__CGSCC_OPM-NEXT:    unreachable
145;
146; IS__CGSCC_NPM: Function Attrs: nofree noinline noreturn nosync nounwind readnone uwtable
147; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@test6_2
148; IS__CGSCC_NPM-SAME: () #[[ATTR1]] {
149; IS__CGSCC_NPM-NEXT:    [[RET:%.*]] = tail call i32* @test6_1() #[[ATTR12]]
150; IS__CGSCC_NPM-NEXT:    unreachable
151;
152  %ret = tail call i32* @test6_1()
153  ret i32* %ret
154}
155
156
157; char a1 __attribute__((aligned(8)));
158; char a2 __attribute__((aligned(16)));
159;
160; char* f1(char* a ){
161;     return a?a:f2(&a1);
162; }
163; char* f2(char* a){
164;     return a?f1(a):f3(&a2);
165; }
166;
167; char* f3(char* a){
168;     return a?&a1: f1(&a2);
169; }
170
171@a1 = common global i8 0, align 8
172@a2 = common global i8 0, align 16
173
174; Function Attrs: nounwind readnone ssp uwtable
175define internal i8* @f1(i8* readnone %0) local_unnamed_addr #0 {
176; IS__TUNIT____: Function Attrs: nofree noinline nosync nounwind readnone uwtable willreturn
177; IS__TUNIT____-LABEL: define {{[^@]+}}@f1
178; IS__TUNIT____-SAME: (i8* noalias nofree nonnull readnone returned align 8 dereferenceable(1) "no-capture-maybe-returned" [[TMP0:%.*]]) local_unnamed_addr #[[ATTR0]] {
179; IS__TUNIT____-NEXT:    br label [[TMP3:%.*]]
180; IS__TUNIT____:       2:
181; IS__TUNIT____-NEXT:    unreachable
182; IS__TUNIT____:       3:
183; IS__TUNIT____-NEXT:    ret i8* [[TMP0]]
184;
185; IS__CGSCC_OPM: Function Attrs: nofree noinline nosync nounwind readnone uwtable willreturn
186; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@f1
187; IS__CGSCC_OPM-SAME: (i8* noalias nofree nonnull readnone returned align 8 dereferenceable(1) "no-capture-maybe-returned" [[TMP0:%.*]]) local_unnamed_addr #[[ATTR2:[0-9]+]] {
188; IS__CGSCC_OPM-NEXT:    br label [[TMP3:%.*]]
189; IS__CGSCC_OPM:       2:
190; IS__CGSCC_OPM-NEXT:    unreachable
191; IS__CGSCC_OPM:       3:
192; IS__CGSCC_OPM-NEXT:    ret i8* @a1
193;
194; IS__CGSCC_NPM: Function Attrs: nofree noinline norecurse nosync nounwind readnone uwtable willreturn
195; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@f1
196; IS__CGSCC_NPM-SAME: () local_unnamed_addr #[[ATTR0]] {
197; IS__CGSCC_NPM-NEXT:    br label [[TMP2:%.*]]
198; IS__CGSCC_NPM:       1:
199; IS__CGSCC_NPM-NEXT:    unreachable
200; IS__CGSCC_NPM:       2:
201; IS__CGSCC_NPM-NEXT:    ret i8* undef
202;
203  %2 = icmp eq i8* %0, null
204  br i1 %2, label %3, label %5
205
206; <label>:3:                                      ; preds = %1
207  %4 = tail call i8* @f2(i8* nonnull @a1)
208  %l = load i8, i8* %4
209  br label %5
210
211; <label>:5:                                      ; preds = %1, %3
212  %6 = phi i8* [ %4, %3 ], [ %0, %1 ]
213  ret i8* %6
214}
215
216; Function Attrs: nounwind readnone ssp uwtable
217define internal i8* @f2(i8* readnone %0) local_unnamed_addr #0 {
218; IS__CGSCC_OPM: Function Attrs: noinline nounwind uwtable
219; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@f2
220; IS__CGSCC_OPM-SAME: (i8* nonnull readnone [[TMP0:%.*]]) local_unnamed_addr #[[ATTR3:[0-9]+]] {
221; IS__CGSCC_OPM-NEXT:    br label [[TMP2:%.*]]
222; IS__CGSCC_OPM:       2:
223; IS__CGSCC_OPM-NEXT:    [[TMP3:%.*]] = tail call i8* @f1(i8* noalias nonnull readnone align 536870912 dereferenceable(4294967295) undef)
224; IS__CGSCC_OPM-NEXT:    br label [[TMP5:%.*]]
225; IS__CGSCC_OPM:       4:
226; IS__CGSCC_OPM-NEXT:    unreachable
227; IS__CGSCC_OPM:       5:
228; IS__CGSCC_OPM-NEXT:    ret i8* [[TMP3]]
229;
230; IS__CGSCC_NPM: Function Attrs: noinline nounwind uwtable
231; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@f2
232; IS__CGSCC_NPM-SAME: (i8* nonnull readnone [[TMP0:%.*]]) local_unnamed_addr #[[ATTR2:[0-9]+]] {
233; IS__CGSCC_NPM-NEXT:    br label [[TMP2:%.*]]
234; IS__CGSCC_NPM:       2:
235; IS__CGSCC_NPM-NEXT:    [[TMP3:%.*]] = tail call i8* @f1()
236; IS__CGSCC_NPM-NEXT:    br label [[TMP5:%.*]]
237; IS__CGSCC_NPM:       4:
238; IS__CGSCC_NPM-NEXT:    unreachable
239; IS__CGSCC_NPM:       5:
240; IS__CGSCC_NPM-NEXT:    ret i8* @a1
241;
242  %2 = icmp eq i8* %0, null
243  br i1 %2, label %5, label %3
244
245; <label>:3:                                      ; preds = %1
246
247  %4 = tail call i8* @f1(i8* nonnull %0)
248  br label %7
249
250; <label>:5:                                      ; preds = %1
251  %6 = tail call i8* @f3(i8* nonnull @a2)
252  br label %7
253
254; <label>:7:                                      ; preds = %5, %3
255  %8 = phi i8* [ %4, %3 ], [ %6, %5 ]
256  ret i8* %8
257}
258
259; Function Attrs: nounwind readnone ssp uwtable
260define internal i8* @f3(i8* readnone %0) local_unnamed_addr #0 {
261; IS__CGSCC_OPM: Function Attrs: noinline nounwind uwtable
262; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@f3
263; IS__CGSCC_OPM-SAME: (i8* nonnull readnone [[TMP0:%.*]]) local_unnamed_addr #[[ATTR3]] {
264; IS__CGSCC_OPM-NEXT:    br label [[TMP3:%.*]]
265; IS__CGSCC_OPM:       2:
266; IS__CGSCC_OPM-NEXT:    unreachable
267; IS__CGSCC_OPM:       3:
268; IS__CGSCC_OPM-NEXT:    ret i8* @a1
269;
270; IS__CGSCC_NPM: Function Attrs: noinline nounwind uwtable
271; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@f3
272; IS__CGSCC_NPM-SAME: (i8* nonnull readnone [[TMP0:%.*]]) local_unnamed_addr #[[ATTR2]] {
273; IS__CGSCC_NPM-NEXT:    br label [[TMP3:%.*]]
274; IS__CGSCC_NPM:       2:
275; IS__CGSCC_NPM-NEXT:    unreachable
276; IS__CGSCC_NPM:       3:
277; IS__CGSCC_NPM-NEXT:    ret i8* @a1
278;
279  %2 = icmp eq i8* %0, null
280  br i1 %2, label %3, label %5
281
282; <label>:3:                                      ; preds = %1
283  %4 = tail call i8* @f1(i8* nonnull @a2)
284  br label %5
285
286; <label>:5:                                      ; preds = %1, %3
287  %6 = phi i8* [ %4, %3 ], [ @a1, %1 ]
288  ret i8* %6
289}
290
291; TEST 7
292; Better than IR information
293define align 4 i8* @test7() #0 {
294; IS__TUNIT____: Function Attrs: nofree noinline nosync nounwind readnone uwtable willreturn
295; IS__TUNIT____-LABEL: define {{[^@]+}}@test7
296; IS__TUNIT____-SAME: () #[[ATTR0]] {
297; IS__TUNIT____-NEXT:    [[C:%.*]] = tail call i8* @f1(i8* noalias nofree noundef nonnull readnone align 8 dereferenceable(1) "no-capture-maybe-returned" @a1) #[[ATTR9:[0-9]+]]
298; IS__TUNIT____-NEXT:    ret i8* [[C]]
299;
300; IS__CGSCC____: Function Attrs: nofree noinline norecurse nosync nounwind readnone uwtable willreturn
301; IS__CGSCC____-LABEL: define {{[^@]+}}@test7
302; IS__CGSCC____-SAME: () #[[ATTR0]] {
303; IS__CGSCC____-NEXT:    ret i8* @a1
304;
305  %c = tail call i8* @f1(i8* align 8 dereferenceable(1) @a1)
306  ret i8* %c
307}
308
309; TEST 7b
310; Function Attrs: nounwind readnone ssp uwtable
311define internal i8* @f1b(i8* readnone %0) local_unnamed_addr #0 {
312; IS__CGSCC_OPM: Function Attrs: nofree noinline nosync nounwind readnone uwtable willreturn
313; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@f1b
314; IS__CGSCC_OPM-SAME: (i8* noalias nofree nonnull readnone returned align 8 dereferenceable(1) "no-capture-maybe-returned" [[TMP0:%.*]]) local_unnamed_addr #[[ATTR2]] {
315; IS__CGSCC_OPM-NEXT:    br label [[TMP3:%.*]]
316; IS__CGSCC_OPM:       2:
317; IS__CGSCC_OPM-NEXT:    unreachable
318; IS__CGSCC_OPM:       3:
319; IS__CGSCC_OPM-NEXT:    ret i8* @a1
320;
321; IS__CGSCC_NPM: Function Attrs: nofree noinline norecurse nosync nounwind readnone uwtable willreturn
322; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@f1b
323; IS__CGSCC_NPM-SAME: () local_unnamed_addr #[[ATTR0]] {
324; IS__CGSCC_NPM-NEXT:    br label [[TMP2:%.*]]
325; IS__CGSCC_NPM:       1:
326; IS__CGSCC_NPM-NEXT:    unreachable
327; IS__CGSCC_NPM:       2:
328; IS__CGSCC_NPM-NEXT:    ret i8* undef
329;
330  %2 = icmp eq i8* %0, null
331  br i1 %2, label %3, label %5
332
333; <label>:3:                                      ; preds = %1
334  %4 = tail call i8* @f2b(i8* nonnull @a1)
335  %l = load i8, i8* %4
336  store i8 %l, i8* @a1
337  br label %5
338
339; <label>:5:                                      ; preds = %1, %3
340  %6 = phi i8* [ %4, %3 ], [ %0, %1 ]
341  ret i8* %6
342}
343
344; Function Attrs: nounwind readnone ssp uwtable
345define internal i8* @f2b(i8* readnone %0) local_unnamed_addr #0 {
346;
347; IS__CGSCC_OPM: Function Attrs: noinline nounwind uwtable
348; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@f2b
349; IS__CGSCC_OPM-SAME: (i8* nonnull readnone [[TMP0:%.*]]) local_unnamed_addr #[[ATTR3]] {
350; IS__CGSCC_OPM-NEXT:    br label [[TMP2:%.*]]
351; IS__CGSCC_OPM:       2:
352; IS__CGSCC_OPM-NEXT:    [[TMP3:%.*]] = tail call i8* @f1b(i8* noalias nonnull readnone align 536870912 dereferenceable(4294967295) undef)
353; IS__CGSCC_OPM-NEXT:    br label [[TMP5:%.*]]
354; IS__CGSCC_OPM:       4:
355; IS__CGSCC_OPM-NEXT:    unreachable
356; IS__CGSCC_OPM:       5:
357; IS__CGSCC_OPM-NEXT:    ret i8* [[TMP3]]
358;
359; IS__CGSCC_NPM: Function Attrs: noinline nounwind uwtable
360; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@f2b
361; IS__CGSCC_NPM-SAME: (i8* nonnull readnone [[TMP0:%.*]]) local_unnamed_addr #[[ATTR2]] {
362; IS__CGSCC_NPM-NEXT:    br label [[TMP2:%.*]]
363; IS__CGSCC_NPM:       2:
364; IS__CGSCC_NPM-NEXT:    [[TMP3:%.*]] = tail call i8* @f1b()
365; IS__CGSCC_NPM-NEXT:    br label [[TMP5:%.*]]
366; IS__CGSCC_NPM:       4:
367; IS__CGSCC_NPM-NEXT:    unreachable
368; IS__CGSCC_NPM:       5:
369; IS__CGSCC_NPM-NEXT:    ret i8* @a1
370;
371  %2 = icmp eq i8* %0, null
372  br i1 %2, label %5, label %3
373
374; <label>:3:                                      ; preds = %1
375
376  %4 = tail call i8* @f1b(i8* nonnull %0)
377  br label %7
378
379; <label>:5:                                      ; preds = %1
380  %6 = tail call i8* @f3b(i8* nonnull @a2)
381  br label %7
382
383; <label>:7:                                      ; preds = %5, %3
384  %8 = phi i8* [ %4, %3 ], [ %6, %5 ]
385  ret i8* %8
386}
387
388; Function Attrs: nounwind readnone ssp uwtable
389define internal i8* @f3b(i8* readnone %0) local_unnamed_addr #0 {
390;
391; IS__CGSCC_OPM: Function Attrs: noinline nounwind uwtable
392; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@f3b
393; IS__CGSCC_OPM-SAME: (i8* nonnull readnone [[TMP0:%.*]]) local_unnamed_addr #[[ATTR3]] {
394; IS__CGSCC_OPM-NEXT:    br label [[TMP3:%.*]]
395; IS__CGSCC_OPM:       2:
396; IS__CGSCC_OPM-NEXT:    unreachable
397; IS__CGSCC_OPM:       3:
398; IS__CGSCC_OPM-NEXT:    ret i8* @a1
399;
400; IS__CGSCC_NPM: Function Attrs: noinline nounwind uwtable
401; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@f3b
402; IS__CGSCC_NPM-SAME: (i8* nonnull readnone [[TMP0:%.*]]) local_unnamed_addr #[[ATTR2]] {
403; IS__CGSCC_NPM-NEXT:    br label [[TMP3:%.*]]
404; IS__CGSCC_NPM:       2:
405; IS__CGSCC_NPM-NEXT:    unreachable
406; IS__CGSCC_NPM:       3:
407; IS__CGSCC_NPM-NEXT:    ret i8* @a1
408;
409  %2 = icmp eq i8* %0, null
410  br i1 %2, label %3, label %5
411
412; <label>:3:                                      ; preds = %1
413  %4 = tail call i8* @f1b(i8* nonnull @a2)
414  br label %5
415
416; <label>:5:                                      ; preds = %1, %3
417  %6 = phi i8* [ %4, %3 ], [ @a1, %1 ]
418  ret i8* %6
419}
420
421define align 4 i32* @test7b(i32* align 32 %p) #0 {
422; IS__TUNIT____: Function Attrs: nofree noinline nosync nounwind readnone uwtable willreturn
423; IS__TUNIT____-LABEL: define {{[^@]+}}@test7b
424; IS__TUNIT____-SAME: (i32* nofree readnone returned align 32 "no-capture-maybe-returned" [[P:%.*]]) #[[ATTR0]] {
425; IS__TUNIT____-NEXT:    ret i32* [[P]]
426;
427; IS__CGSCC____: Function Attrs: nofree noinline norecurse nosync nounwind readnone uwtable willreturn
428; IS__CGSCC____-LABEL: define {{[^@]+}}@test7b
429; IS__CGSCC____-SAME: (i32* nofree readnone returned align 32 "no-capture-maybe-returned" [[P:%.*]]) #[[ATTR0]] {
430; IS__CGSCC____-NEXT:    ret i32* [[P]]
431;
432  tail call i8* @f1b(i8* align 8 dereferenceable(1) @a1)
433  ret i32* %p
434}
435
436; TEST 8
437define void @test8_helper() {
438; IS__TUNIT____-LABEL: define {{[^@]+}}@test8_helper() {
439; IS__TUNIT____-NEXT:    [[PTR0:%.*]] = tail call i32* @unknown()
440; IS__TUNIT____-NEXT:    [[PTR1:%.*]] = tail call align 4 i32* @unknown()
441; IS__TUNIT____-NEXT:    [[PTR2:%.*]] = tail call align 8 i32* @unknown()
442; IS__TUNIT____-NEXT:    tail call void @test8(i32* noalias nocapture readnone align 4 [[PTR1]], i32* noalias nocapture readnone align 4 [[PTR1]], i32* noalias nocapture readnone [[PTR0]]) #[[ATTR2:[0-9]+]]
443; IS__TUNIT____-NEXT:    tail call void @test8(i32* noalias nocapture readnone align 8 [[PTR2]], i32* noalias nocapture readnone align 4 [[PTR1]], i32* noalias nocapture readnone align 4 [[PTR1]]) #[[ATTR2]]
444; IS__TUNIT____-NEXT:    tail call void @test8(i32* noalias nocapture readnone align 8 [[PTR2]], i32* noalias nocapture readnone align 4 [[PTR1]], i32* noalias nocapture readnone align 4 [[PTR1]]) #[[ATTR2]]
445; IS__TUNIT____-NEXT:    ret void
446;
447; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@test8_helper() {
448; IS__CGSCC_OPM-NEXT:    [[PTR0:%.*]] = tail call i32* @unknown()
449; IS__CGSCC_OPM-NEXT:    [[PTR1:%.*]] = tail call align 4 i32* @unknown()
450; IS__CGSCC_OPM-NEXT:    [[PTR2:%.*]] = tail call align 8 i32* @unknown()
451; IS__CGSCC_OPM-NEXT:    tail call void @test8(i32* noalias nocapture readnone align 4 [[PTR1]], i32* noalias nocapture readnone align 4 [[PTR1]], i32* noalias nocapture readnone [[PTR0]]) #[[ATTR4:[0-9]+]]
452; IS__CGSCC_OPM-NEXT:    tail call void @test8(i32* noalias nocapture readnone align 8 [[PTR2]], i32* noalias nocapture readnone align 4 [[PTR1]], i32* noalias nocapture readnone align 4 [[PTR1]]) #[[ATTR4]]
453; IS__CGSCC_OPM-NEXT:    tail call void @test8(i32* noalias nocapture readnone align 8 [[PTR2]], i32* noalias nocapture readnone align 4 [[PTR1]], i32* noalias nocapture readnone align 4 [[PTR1]]) #[[ATTR4]]
454; IS__CGSCC_OPM-NEXT:    ret void
455;
456; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@test8_helper() {
457; IS__CGSCC_NPM-NEXT:    [[PTR0:%.*]] = tail call i32* @unknown()
458; IS__CGSCC_NPM-NEXT:    [[PTR1:%.*]] = tail call align 4 i32* @unknown()
459; IS__CGSCC_NPM-NEXT:    [[PTR2:%.*]] = tail call align 8 i32* @unknown()
460; IS__CGSCC_NPM-NEXT:    tail call void @test8(i32* noalias nocapture readnone align 4 [[PTR1]], i32* noalias nocapture readnone align 4 [[PTR1]], i32* noalias nocapture readnone [[PTR0]]) #[[ATTR3:[0-9]+]]
461; IS__CGSCC_NPM-NEXT:    tail call void @test8(i32* noalias nocapture readnone align 8 [[PTR2]], i32* noalias nocapture readnone align 4 [[PTR1]], i32* noalias nocapture readnone align 4 [[PTR1]]) #[[ATTR3]]
462; IS__CGSCC_NPM-NEXT:    tail call void @test8(i32* noalias nocapture readnone align 8 [[PTR2]], i32* noalias nocapture readnone align 4 [[PTR1]], i32* noalias nocapture readnone align 4 [[PTR1]]) #[[ATTR3]]
463; IS__CGSCC_NPM-NEXT:    ret void
464;
465  %ptr0 = tail call i32* @unknown()
466  %ptr1 = tail call align 4 i32* @unknown()
467  %ptr2 = tail call align 8 i32* @unknown()
468
469  tail call void @test8(i32* %ptr1, i32* %ptr1, i32* %ptr0)
470  tail call void @test8(i32* %ptr2, i32* %ptr1, i32* %ptr1)
471  tail call void @test8(i32* %ptr2, i32* %ptr1, i32* %ptr1)
472  ret void
473}
474
475declare void @user_i32_ptr(i32* nocapture readnone) nounwind
476define internal void @test8(i32* %a, i32* %b, i32* %c) {
477; IS__TUNIT____: Function Attrs: nounwind
478; IS__TUNIT____-LABEL: define {{[^@]+}}@test8
479; IS__TUNIT____-SAME: (i32* noalias nocapture readnone align 4 [[A:%.*]], i32* noalias nocapture readnone align 4 [[B:%.*]], i32* noalias nocapture readnone [[C:%.*]]) #[[ATTR2]] {
480; IS__TUNIT____-NEXT:    call void @user_i32_ptr(i32* noalias nocapture readnone align 4 [[A]]) #[[ATTR2]]
481; IS__TUNIT____-NEXT:    call void @user_i32_ptr(i32* noalias nocapture readnone align 4 [[B]]) #[[ATTR2]]
482; IS__TUNIT____-NEXT:    call void @user_i32_ptr(i32* noalias nocapture readnone [[C]]) #[[ATTR2]]
483; IS__TUNIT____-NEXT:    ret void
484;
485; IS__CGSCC_OPM: Function Attrs: nounwind
486; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@test8
487; IS__CGSCC_OPM-SAME: (i32* noalias nocapture readnone align 4 [[A:%.*]], i32* noalias nocapture readnone align 4 [[B:%.*]], i32* noalias nocapture readnone [[C:%.*]]) #[[ATTR4]] {
488; IS__CGSCC_OPM-NEXT:    call void @user_i32_ptr(i32* noalias nocapture readnone align 4 [[A]]) #[[ATTR4]]
489; IS__CGSCC_OPM-NEXT:    call void @user_i32_ptr(i32* noalias nocapture readnone align 4 [[B]]) #[[ATTR4]]
490; IS__CGSCC_OPM-NEXT:    call void @user_i32_ptr(i32* noalias nocapture readnone [[C]]) #[[ATTR4]]
491; IS__CGSCC_OPM-NEXT:    ret void
492;
493; IS__CGSCC_NPM: Function Attrs: nounwind
494; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@test8
495; IS__CGSCC_NPM-SAME: (i32* noalias nocapture readnone align 4 [[A:%.*]], i32* noalias nocapture readnone align 4 [[B:%.*]], i32* noalias nocapture readnone [[C:%.*]]) #[[ATTR3]] {
496; IS__CGSCC_NPM-NEXT:    call void @user_i32_ptr(i32* noalias nocapture readnone align 4 [[A]]) #[[ATTR3]]
497; IS__CGSCC_NPM-NEXT:    call void @user_i32_ptr(i32* noalias nocapture readnone align 4 [[B]]) #[[ATTR3]]
498; IS__CGSCC_NPM-NEXT:    call void @user_i32_ptr(i32* noalias nocapture readnone [[C]]) #[[ATTR3]]
499; IS__CGSCC_NPM-NEXT:    ret void
500;
501  call void @user_i32_ptr(i32* %a)
502  call void @user_i32_ptr(i32* %b)
503  call void @user_i32_ptr(i32* %c)
504  ret void
505}
506
507declare void @test9_helper(i32* %A)
508define void @test9_traversal(i1 %cnd, i32* align 4 %B, i32* align 8 %C) {
509; CHECK-LABEL: define {{[^@]+}}@test9_traversal
510; CHECK-SAME: (i1 [[CND:%.*]], i32* align 4 [[B:%.*]], i32* align 8 [[C:%.*]]) {
511; CHECK-NEXT:    [[SEL:%.*]] = select i1 [[CND]], i32* [[B]], i32* [[C]]
512; CHECK-NEXT:    call void @test9_helper(i32* align 4 [[SEL]])
513; CHECK-NEXT:    ret void
514;
515  %sel = select i1 %cnd, i32* %B, i32* %C
516  call void @test9_helper(i32* %sel)
517  ret void
518}
519
520; FIXME: This will work with an upcoming patch (D66618 or similar)
521;             define align 32 i32* @test10a(i32* align 32 "no-capture-maybe-returned" %p)
522; FIXME: This will work with an upcoming patch (D66618 or similar)
523;             store i32 1, i32* %r, align 32
524; FIXME: This will work with an upcoming patch (D66618 or similar)
525;             store i32 -1, i32* %g1, align 32
526define i32* @test10a(i32* align 32 %p) {
527; IS__TUNIT____: Function Attrs: nofree nosync nounwind
528; IS__TUNIT____-LABEL: define {{[^@]+}}@test10a
529; IS__TUNIT____-SAME: (i32* nofree noundef nonnull align 32 dereferenceable(4) "no-capture-maybe-returned" [[P:%.*]]) #[[ATTR3:[0-9]+]] {
530; IS__TUNIT____-NEXT:    [[L:%.*]] = load i32, i32* [[P]], align 32
531; IS__TUNIT____-NEXT:    [[C:%.*]] = icmp eq i32 [[L]], 0
532; IS__TUNIT____-NEXT:    br i1 [[C]], label [[T:%.*]], label [[F:%.*]]
533; IS__TUNIT____:       t:
534; IS__TUNIT____-NEXT:    [[R:%.*]] = call align 32 i32* @test10a(i32* nofree noundef nonnull align 32 dereferenceable(4) "no-capture-maybe-returned" [[P]]) #[[ATTR3]]
535; IS__TUNIT____-NEXT:    store i32 1, i32* [[R]], align 32
536; IS__TUNIT____-NEXT:    [[G0:%.*]] = getelementptr i32, i32* [[P]], i32 8
537; IS__TUNIT____-NEXT:    br label [[E:%.*]]
538; IS__TUNIT____:       f:
539; IS__TUNIT____-NEXT:    [[G1:%.*]] = getelementptr i32, i32* [[P]], i32 8
540; IS__TUNIT____-NEXT:    store i32 -1, i32* [[G1]], align 32
541; IS__TUNIT____-NEXT:    br label [[E]]
542; IS__TUNIT____:       e:
543; IS__TUNIT____-NEXT:    [[PHI:%.*]] = phi i32* [ [[G0]], [[T]] ], [ [[G1]], [[F]] ]
544; IS__TUNIT____-NEXT:    ret i32* [[PHI]]
545;
546; IS__CGSCC_OPM: Function Attrs: nofree nosync nounwind
547; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@test10a
548; IS__CGSCC_OPM-SAME: (i32* nofree noundef nonnull align 32 dereferenceable(4) "no-capture-maybe-returned" [[P:%.*]]) #[[ATTR5:[0-9]+]] {
549; IS__CGSCC_OPM-NEXT:    [[L:%.*]] = load i32, i32* [[P]], align 32
550; IS__CGSCC_OPM-NEXT:    [[C:%.*]] = icmp eq i32 [[L]], 0
551; IS__CGSCC_OPM-NEXT:    br i1 [[C]], label [[T:%.*]], label [[F:%.*]]
552; IS__CGSCC_OPM:       t:
553; IS__CGSCC_OPM-NEXT:    [[R:%.*]] = call align 32 i32* @test10a(i32* nofree noundef nonnull align 32 dereferenceable(4) "no-capture-maybe-returned" [[P]]) #[[ATTR5]]
554; IS__CGSCC_OPM-NEXT:    store i32 1, i32* [[R]], align 32
555; IS__CGSCC_OPM-NEXT:    [[G0:%.*]] = getelementptr i32, i32* [[P]], i32 8
556; IS__CGSCC_OPM-NEXT:    br label [[E:%.*]]
557; IS__CGSCC_OPM:       f:
558; IS__CGSCC_OPM-NEXT:    [[G1:%.*]] = getelementptr i32, i32* [[P]], i32 8
559; IS__CGSCC_OPM-NEXT:    store i32 -1, i32* [[G1]], align 32
560; IS__CGSCC_OPM-NEXT:    br label [[E]]
561; IS__CGSCC_OPM:       e:
562; IS__CGSCC_OPM-NEXT:    [[PHI:%.*]] = phi i32* [ [[G0]], [[T]] ], [ [[G1]], [[F]] ]
563; IS__CGSCC_OPM-NEXT:    ret i32* [[PHI]]
564;
565; IS__CGSCC_NPM: Function Attrs: nofree nosync nounwind
566; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@test10a
567; IS__CGSCC_NPM-SAME: (i32* nofree noundef nonnull align 32 dereferenceable(4) "no-capture-maybe-returned" [[P:%.*]]) #[[ATTR4:[0-9]+]] {
568; IS__CGSCC_NPM-NEXT:    [[L:%.*]] = load i32, i32* [[P]], align 32
569; IS__CGSCC_NPM-NEXT:    [[C:%.*]] = icmp eq i32 [[L]], 0
570; IS__CGSCC_NPM-NEXT:    br i1 [[C]], label [[T:%.*]], label [[F:%.*]]
571; IS__CGSCC_NPM:       t:
572; IS__CGSCC_NPM-NEXT:    [[R:%.*]] = call align 32 i32* @test10a(i32* nofree noundef nonnull align 32 dereferenceable(4) "no-capture-maybe-returned" [[P]]) #[[ATTR4]]
573; IS__CGSCC_NPM-NEXT:    store i32 1, i32* [[R]], align 32
574; IS__CGSCC_NPM-NEXT:    [[G0:%.*]] = getelementptr i32, i32* [[P]], i32 8
575; IS__CGSCC_NPM-NEXT:    br label [[E:%.*]]
576; IS__CGSCC_NPM:       f:
577; IS__CGSCC_NPM-NEXT:    [[G1:%.*]] = getelementptr i32, i32* [[P]], i32 8
578; IS__CGSCC_NPM-NEXT:    store i32 -1, i32* [[G1]], align 32
579; IS__CGSCC_NPM-NEXT:    br label [[E]]
580; IS__CGSCC_NPM:       e:
581; IS__CGSCC_NPM-NEXT:    [[PHI:%.*]] = phi i32* [ [[G0]], [[T]] ], [ [[G1]], [[F]] ]
582; IS__CGSCC_NPM-NEXT:    ret i32* [[PHI]]
583;
584  %l = load i32, i32* %p
585  %c = icmp eq i32 %l, 0
586  br i1 %c, label %t, label %f
587t:
588  %r = call i32* @test10a(i32* %p)
589  store i32 1, i32* %r
590  %g0 = getelementptr i32, i32* %p, i32 8
591  br label %e
592f:
593  %g1 = getelementptr i32, i32* %p, i32 8
594  store i32 -1, i32* %g1
595  br label %e
596e:
597  %phi = phi i32* [%g0, %t], [%g1, %f]
598  ret i32* %phi
599}
600
601; FIXME: This will work with an upcoming patch (D66618 or similar)
602;             define align 32 i32* @test10b(i32* align 32 "no-capture-maybe-returned" %p)
603; FIXME: This will work with an upcoming patch (D66618 or similar)
604;             store i32 1, i32* %r, align 32
605; FIXME: This will work with an upcoming patch (D66618 or similar)
606;             store i32 -1, i32* %g1, align 32
607define i32* @test10b(i32* align 32 %p) {
608; IS__TUNIT____: Function Attrs: nofree nosync nounwind
609; IS__TUNIT____-LABEL: define {{[^@]+}}@test10b
610; IS__TUNIT____-SAME: (i32* nofree noundef nonnull align 32 dereferenceable(4) "no-capture-maybe-returned" [[P:%.*]]) #[[ATTR3]] {
611; IS__TUNIT____-NEXT:    [[L:%.*]] = load i32, i32* [[P]], align 32
612; IS__TUNIT____-NEXT:    [[C:%.*]] = icmp eq i32 [[L]], 0
613; IS__TUNIT____-NEXT:    br i1 [[C]], label [[T:%.*]], label [[F:%.*]]
614; IS__TUNIT____:       t:
615; IS__TUNIT____-NEXT:    [[R:%.*]] = call align 32 i32* @test10b(i32* nofree noundef nonnull align 32 dereferenceable(4) "no-capture-maybe-returned" [[P]]) #[[ATTR3]]
616; IS__TUNIT____-NEXT:    store i32 1, i32* [[R]], align 32
617; IS__TUNIT____-NEXT:    [[G0:%.*]] = getelementptr i32, i32* [[P]], i32 8
618; IS__TUNIT____-NEXT:    br label [[E:%.*]]
619; IS__TUNIT____:       f:
620; IS__TUNIT____-NEXT:    [[G1:%.*]] = getelementptr i32, i32* [[P]], i32 -8
621; IS__TUNIT____-NEXT:    store i32 -1, i32* [[G1]], align 32
622; IS__TUNIT____-NEXT:    br label [[E]]
623; IS__TUNIT____:       e:
624; IS__TUNIT____-NEXT:    [[PHI:%.*]] = phi i32* [ [[G0]], [[T]] ], [ [[G1]], [[F]] ]
625; IS__TUNIT____-NEXT:    ret i32* [[PHI]]
626;
627; IS__CGSCC_OPM: Function Attrs: nofree nosync nounwind
628; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@test10b
629; IS__CGSCC_OPM-SAME: (i32* nofree noundef nonnull align 32 dereferenceable(4) "no-capture-maybe-returned" [[P:%.*]]) #[[ATTR5]] {
630; IS__CGSCC_OPM-NEXT:    [[L:%.*]] = load i32, i32* [[P]], align 32
631; IS__CGSCC_OPM-NEXT:    [[C:%.*]] = icmp eq i32 [[L]], 0
632; IS__CGSCC_OPM-NEXT:    br i1 [[C]], label [[T:%.*]], label [[F:%.*]]
633; IS__CGSCC_OPM:       t:
634; IS__CGSCC_OPM-NEXT:    [[R:%.*]] = call align 32 i32* @test10b(i32* nofree noundef nonnull align 32 dereferenceable(4) "no-capture-maybe-returned" [[P]]) #[[ATTR5]]
635; IS__CGSCC_OPM-NEXT:    store i32 1, i32* [[R]], align 32
636; IS__CGSCC_OPM-NEXT:    [[G0:%.*]] = getelementptr i32, i32* [[P]], i32 8
637; IS__CGSCC_OPM-NEXT:    br label [[E:%.*]]
638; IS__CGSCC_OPM:       f:
639; IS__CGSCC_OPM-NEXT:    [[G1:%.*]] = getelementptr i32, i32* [[P]], i32 -8
640; IS__CGSCC_OPM-NEXT:    store i32 -1, i32* [[G1]], align 32
641; IS__CGSCC_OPM-NEXT:    br label [[E]]
642; IS__CGSCC_OPM:       e:
643; IS__CGSCC_OPM-NEXT:    [[PHI:%.*]] = phi i32* [ [[G0]], [[T]] ], [ [[G1]], [[F]] ]
644; IS__CGSCC_OPM-NEXT:    ret i32* [[PHI]]
645;
646; IS__CGSCC_NPM: Function Attrs: nofree nosync nounwind
647; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@test10b
648; IS__CGSCC_NPM-SAME: (i32* nofree noundef nonnull align 32 dereferenceable(4) "no-capture-maybe-returned" [[P:%.*]]) #[[ATTR4]] {
649; IS__CGSCC_NPM-NEXT:    [[L:%.*]] = load i32, i32* [[P]], align 32
650; IS__CGSCC_NPM-NEXT:    [[C:%.*]] = icmp eq i32 [[L]], 0
651; IS__CGSCC_NPM-NEXT:    br i1 [[C]], label [[T:%.*]], label [[F:%.*]]
652; IS__CGSCC_NPM:       t:
653; IS__CGSCC_NPM-NEXT:    [[R:%.*]] = call align 32 i32* @test10b(i32* nofree noundef nonnull align 32 dereferenceable(4) "no-capture-maybe-returned" [[P]]) #[[ATTR4]]
654; IS__CGSCC_NPM-NEXT:    store i32 1, i32* [[R]], align 32
655; IS__CGSCC_NPM-NEXT:    [[G0:%.*]] = getelementptr i32, i32* [[P]], i32 8
656; IS__CGSCC_NPM-NEXT:    br label [[E:%.*]]
657; IS__CGSCC_NPM:       f:
658; IS__CGSCC_NPM-NEXT:    [[G1:%.*]] = getelementptr i32, i32* [[P]], i32 -8
659; IS__CGSCC_NPM-NEXT:    store i32 -1, i32* [[G1]], align 32
660; IS__CGSCC_NPM-NEXT:    br label [[E]]
661; IS__CGSCC_NPM:       e:
662; IS__CGSCC_NPM-NEXT:    [[PHI:%.*]] = phi i32* [ [[G0]], [[T]] ], [ [[G1]], [[F]] ]
663; IS__CGSCC_NPM-NEXT:    ret i32* [[PHI]]
664;
665  %l = load i32, i32* %p
666  %c = icmp eq i32 %l, 0
667  br i1 %c, label %t, label %f
668t:
669  %r = call i32* @test10b(i32* %p)
670  store i32 1, i32* %r
671  %g0 = getelementptr i32, i32* %p, i32 8
672  br label %e
673f:
674  %g1 = getelementptr i32, i32* %p, i32 -8
675  store i32 -1, i32* %g1
676  br label %e
677e:
678  %phi = phi i32* [%g0, %t], [%g1, %f]
679  ret i32* %phi
680}
681
682
683define i64 @test11(i32* %p) {
684; IS__TUNIT____: Function Attrs: argmemonly nofree nosync nounwind readonly willreturn
685; IS__TUNIT____-LABEL: define {{[^@]+}}@test11
686; IS__TUNIT____-SAME: (i32* nocapture nofree nonnull readonly align 8 dereferenceable(8) [[P:%.*]]) #[[ATTR4:[0-9]+]] {
687; IS__TUNIT____-NEXT:    [[P_CAST:%.*]] = bitcast i32* [[P]] to i64*
688; IS__TUNIT____-NEXT:    [[RET:%.*]] = load i64, i64* [[P_CAST]], align 8
689; IS__TUNIT____-NEXT:    ret i64 [[RET]]
690;
691; IS__CGSCC_OPM: Function Attrs: argmemonly nofree norecurse nosync nounwind readonly willreturn
692; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@test11
693; IS__CGSCC_OPM-SAME: (i32* nocapture nofree nonnull readonly align 8 dereferenceable(8) [[P:%.*]]) #[[ATTR6:[0-9]+]] {
694; IS__CGSCC_OPM-NEXT:    [[P_CAST:%.*]] = bitcast i32* [[P]] to i64*
695; IS__CGSCC_OPM-NEXT:    [[RET:%.*]] = load i64, i64* [[P_CAST]], align 8
696; IS__CGSCC_OPM-NEXT:    ret i64 [[RET]]
697;
698; IS__CGSCC_NPM: Function Attrs: argmemonly nofree norecurse nosync nounwind readonly willreturn
699; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@test11
700; IS__CGSCC_NPM-SAME: (i32* nocapture nofree nonnull readonly align 8 dereferenceable(8) [[P:%.*]]) #[[ATTR5:[0-9]+]] {
701; IS__CGSCC_NPM-NEXT:    [[P_CAST:%.*]] = bitcast i32* [[P]] to i64*
702; IS__CGSCC_NPM-NEXT:    [[RET:%.*]] = load i64, i64* [[P_CAST]], align 8
703; IS__CGSCC_NPM-NEXT:    ret i64 [[RET]]
704;
705  %p-cast = bitcast i32* %p to i64*
706  %ret = load i64, i64* %p-cast, align 8
707  ret i64 %ret
708}
709
710; TEST 12
711; Test for deduction using must-be-executed-context and GEP instruction
712
713; FXIME: %p should have nonnull
714define i64 @test12-1(i32* align 4 %p) {
715; IS__TUNIT____: Function Attrs: argmemonly nofree nosync nounwind readonly willreturn
716; IS__TUNIT____-LABEL: define {{[^@]+}}@test12-1
717; IS__TUNIT____-SAME: (i32* nocapture nofree readonly align 16 [[P:%.*]]) #[[ATTR4]] {
718; IS__TUNIT____-NEXT:    [[P_CAST:%.*]] = bitcast i32* [[P]] to i64*
719; IS__TUNIT____-NEXT:    [[ARRAYIDX0:%.*]] = getelementptr i64, i64* [[P_CAST]], i64 1
720; IS__TUNIT____-NEXT:    [[ARRAYIDX1:%.*]] = getelementptr i64, i64* [[ARRAYIDX0]], i64 3
721; IS__TUNIT____-NEXT:    [[RET:%.*]] = load i64, i64* [[ARRAYIDX1]], align 16
722; IS__TUNIT____-NEXT:    ret i64 [[RET]]
723;
724; IS__CGSCC_OPM: Function Attrs: argmemonly nofree norecurse nosync nounwind readonly willreturn
725; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@test12-1
726; IS__CGSCC_OPM-SAME: (i32* nocapture nofree readonly align 16 [[P:%.*]]) #[[ATTR6]] {
727; IS__CGSCC_OPM-NEXT:    [[P_CAST:%.*]] = bitcast i32* [[P]] to i64*
728; IS__CGSCC_OPM-NEXT:    [[ARRAYIDX0:%.*]] = getelementptr i64, i64* [[P_CAST]], i64 1
729; IS__CGSCC_OPM-NEXT:    [[ARRAYIDX1:%.*]] = getelementptr i64, i64* [[ARRAYIDX0]], i64 3
730; IS__CGSCC_OPM-NEXT:    [[RET:%.*]] = load i64, i64* [[ARRAYIDX1]], align 16
731; IS__CGSCC_OPM-NEXT:    ret i64 [[RET]]
732;
733; IS__CGSCC_NPM: Function Attrs: argmemonly nofree norecurse nosync nounwind readonly willreturn
734; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@test12-1
735; IS__CGSCC_NPM-SAME: (i32* nocapture nofree readonly align 16 [[P:%.*]]) #[[ATTR5]] {
736; IS__CGSCC_NPM-NEXT:    [[P_CAST:%.*]] = bitcast i32* [[P]] to i64*
737; IS__CGSCC_NPM-NEXT:    [[ARRAYIDX0:%.*]] = getelementptr i64, i64* [[P_CAST]], i64 1
738; IS__CGSCC_NPM-NEXT:    [[ARRAYIDX1:%.*]] = getelementptr i64, i64* [[ARRAYIDX0]], i64 3
739; IS__CGSCC_NPM-NEXT:    [[RET:%.*]] = load i64, i64* [[ARRAYIDX1]], align 16
740; IS__CGSCC_NPM-NEXT:    ret i64 [[RET]]
741;
742  %p-cast = bitcast i32* %p to i64*
743  %arrayidx0 = getelementptr i64, i64* %p-cast, i64 1
744  %arrayidx1 = getelementptr i64, i64* %arrayidx0, i64 3
745  %ret = load i64, i64* %arrayidx1, align 16
746  ret i64 %ret
747}
748
749define i64 @test12-2(i32* align 4 %p) {
750; IS__TUNIT____: Function Attrs: argmemonly nofree nosync nounwind readonly willreturn
751; IS__TUNIT____-LABEL: define {{[^@]+}}@test12-2
752; IS__TUNIT____-SAME: (i32* nocapture nofree nonnull readonly align 16 dereferenceable(8) [[P:%.*]]) #[[ATTR4]] {
753; IS__TUNIT____-NEXT:    [[P_CAST:%.*]] = bitcast i32* [[P]] to i64*
754; IS__TUNIT____-NEXT:    [[ARRAYIDX0:%.*]] = getelementptr i64, i64* [[P_CAST]], i64 0
755; IS__TUNIT____-NEXT:    [[RET:%.*]] = load i64, i64* [[ARRAYIDX0]], align 16
756; IS__TUNIT____-NEXT:    ret i64 [[RET]]
757;
758; IS__CGSCC_OPM: Function Attrs: argmemonly nofree norecurse nosync nounwind readonly willreturn
759; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@test12-2
760; IS__CGSCC_OPM-SAME: (i32* nocapture nofree nonnull readonly align 16 dereferenceable(8) [[P:%.*]]) #[[ATTR6]] {
761; IS__CGSCC_OPM-NEXT:    [[P_CAST:%.*]] = bitcast i32* [[P]] to i64*
762; IS__CGSCC_OPM-NEXT:    [[ARRAYIDX0:%.*]] = getelementptr i64, i64* [[P_CAST]], i64 0
763; IS__CGSCC_OPM-NEXT:    [[RET:%.*]] = load i64, i64* [[ARRAYIDX0]], align 16
764; IS__CGSCC_OPM-NEXT:    ret i64 [[RET]]
765;
766; IS__CGSCC_NPM: Function Attrs: argmemonly nofree norecurse nosync nounwind readonly willreturn
767; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@test12-2
768; IS__CGSCC_NPM-SAME: (i32* nocapture nofree nonnull readonly align 16 dereferenceable(8) [[P:%.*]]) #[[ATTR5]] {
769; IS__CGSCC_NPM-NEXT:    [[P_CAST:%.*]] = bitcast i32* [[P]] to i64*
770; IS__CGSCC_NPM-NEXT:    [[ARRAYIDX0:%.*]] = getelementptr i64, i64* [[P_CAST]], i64 0
771; IS__CGSCC_NPM-NEXT:    [[RET:%.*]] = load i64, i64* [[ARRAYIDX0]], align 16
772; IS__CGSCC_NPM-NEXT:    ret i64 [[RET]]
773;
774  %p-cast = bitcast i32* %p to i64*
775  %arrayidx0 = getelementptr i64, i64* %p-cast, i64 0
776  %ret = load i64, i64* %arrayidx0, align 16
777  ret i64 %ret
778}
779
780; FXIME: %p should have nonnull
781define void @test12-3(i32* align 4 %p) {
782; IS__TUNIT____: Function Attrs: argmemonly nofree nosync nounwind willreturn writeonly
783; IS__TUNIT____-LABEL: define {{[^@]+}}@test12-3
784; IS__TUNIT____-SAME: (i32* nocapture nofree writeonly align 16 [[P:%.*]]) #[[ATTR5:[0-9]+]] {
785; IS__TUNIT____-NEXT:    [[P_CAST:%.*]] = bitcast i32* [[P]] to i64*
786; IS__TUNIT____-NEXT:    [[ARRAYIDX0:%.*]] = getelementptr i64, i64* [[P_CAST]], i64 1
787; IS__TUNIT____-NEXT:    [[ARRAYIDX1:%.*]] = getelementptr i64, i64* [[ARRAYIDX0]], i64 3
788; IS__TUNIT____-NEXT:    store i64 0, i64* [[ARRAYIDX1]], align 16
789; IS__TUNIT____-NEXT:    ret void
790;
791; IS__CGSCC_OPM: Function Attrs: argmemonly nofree norecurse nosync nounwind willreturn writeonly
792; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@test12-3
793; IS__CGSCC_OPM-SAME: (i32* nocapture nofree writeonly align 16 [[P:%.*]]) #[[ATTR7:[0-9]+]] {
794; IS__CGSCC_OPM-NEXT:    [[P_CAST:%.*]] = bitcast i32* [[P]] to i64*
795; IS__CGSCC_OPM-NEXT:    [[ARRAYIDX0:%.*]] = getelementptr i64, i64* [[P_CAST]], i64 1
796; IS__CGSCC_OPM-NEXT:    [[ARRAYIDX1:%.*]] = getelementptr i64, i64* [[ARRAYIDX0]], i64 3
797; IS__CGSCC_OPM-NEXT:    store i64 0, i64* [[ARRAYIDX1]], align 16
798; IS__CGSCC_OPM-NEXT:    ret void
799;
800; IS__CGSCC_NPM: Function Attrs: argmemonly nofree norecurse nosync nounwind willreturn writeonly
801; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@test12-3
802; IS__CGSCC_NPM-SAME: (i32* nocapture nofree writeonly align 16 [[P:%.*]]) #[[ATTR6:[0-9]+]] {
803; IS__CGSCC_NPM-NEXT:    [[P_CAST:%.*]] = bitcast i32* [[P]] to i64*
804; IS__CGSCC_NPM-NEXT:    [[ARRAYIDX0:%.*]] = getelementptr i64, i64* [[P_CAST]], i64 1
805; IS__CGSCC_NPM-NEXT:    [[ARRAYIDX1:%.*]] = getelementptr i64, i64* [[ARRAYIDX0]], i64 3
806; IS__CGSCC_NPM-NEXT:    store i64 0, i64* [[ARRAYIDX1]], align 16
807; IS__CGSCC_NPM-NEXT:    ret void
808;
809  %p-cast = bitcast i32* %p to i64*
810  %arrayidx0 = getelementptr i64, i64* %p-cast, i64 1
811  %arrayidx1 = getelementptr i64, i64* %arrayidx0, i64 3
812  store i64 0, i64* %arrayidx1, align 16
813  ret void
814}
815
816define void @test12-4(i32* align 4 %p) {
817; IS__TUNIT____: Function Attrs: argmemonly nofree nosync nounwind willreturn writeonly
818; IS__TUNIT____-LABEL: define {{[^@]+}}@test12-4
819; IS__TUNIT____-SAME: (i32* nocapture nofree nonnull writeonly align 16 dereferenceable(8) [[P:%.*]]) #[[ATTR5]] {
820; IS__TUNIT____-NEXT:    [[P_CAST:%.*]] = bitcast i32* [[P]] to i64*
821; IS__TUNIT____-NEXT:    [[ARRAYIDX0:%.*]] = getelementptr i64, i64* [[P_CAST]], i64 0
822; IS__TUNIT____-NEXT:    store i64 0, i64* [[ARRAYIDX0]], align 16
823; IS__TUNIT____-NEXT:    ret void
824;
825; IS__CGSCC_OPM: Function Attrs: argmemonly nofree norecurse nosync nounwind willreturn writeonly
826; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@test12-4
827; IS__CGSCC_OPM-SAME: (i32* nocapture nofree nonnull writeonly align 16 dereferenceable(8) [[P:%.*]]) #[[ATTR7]] {
828; IS__CGSCC_OPM-NEXT:    [[P_CAST:%.*]] = bitcast i32* [[P]] to i64*
829; IS__CGSCC_OPM-NEXT:    [[ARRAYIDX0:%.*]] = getelementptr i64, i64* [[P_CAST]], i64 0
830; IS__CGSCC_OPM-NEXT:    store i64 0, i64* [[ARRAYIDX0]], align 16
831; IS__CGSCC_OPM-NEXT:    ret void
832;
833; IS__CGSCC_NPM: Function Attrs: argmemonly nofree norecurse nosync nounwind willreturn writeonly
834; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@test12-4
835; IS__CGSCC_NPM-SAME: (i32* nocapture nofree nonnull writeonly align 16 dereferenceable(8) [[P:%.*]]) #[[ATTR6]] {
836; IS__CGSCC_NPM-NEXT:    [[P_CAST:%.*]] = bitcast i32* [[P]] to i64*
837; IS__CGSCC_NPM-NEXT:    [[ARRAYIDX0:%.*]] = getelementptr i64, i64* [[P_CAST]], i64 0
838; IS__CGSCC_NPM-NEXT:    store i64 0, i64* [[ARRAYIDX0]], align 16
839; IS__CGSCC_NPM-NEXT:    ret void
840;
841  %p-cast = bitcast i32* %p to i64*
842  %arrayidx0 = getelementptr i64, i64* %p-cast, i64 0
843  store i64 0, i64* %arrayidx0, align 16
844  ret void
845}
846
847declare void @use(i64*) willreturn nounwind
848
849define void @test12-5(i32* align 4 %p) {
850; IS__TUNIT____: Function Attrs: nounwind willreturn
851; IS__TUNIT____-LABEL: define {{[^@]+}}@test12-5
852; IS__TUNIT____-SAME: (i32* align 16 [[P:%.*]]) #[[ATTR6:[0-9]+]] {
853; IS__TUNIT____-NEXT:    [[P_CAST:%.*]] = bitcast i32* [[P]] to i64*
854; IS__TUNIT____-NEXT:    [[ARRAYIDX0:%.*]] = getelementptr i64, i64* [[P_CAST]], i64 1
855; IS__TUNIT____-NEXT:    [[ARRAYIDX1:%.*]] = getelementptr i64, i64* [[ARRAYIDX0]], i64 3
856; IS__TUNIT____-NEXT:    tail call void @use(i64* align 16 [[ARRAYIDX1]]) #[[ATTR6]]
857; IS__TUNIT____-NEXT:    ret void
858;
859; IS__CGSCC_OPM: Function Attrs: nounwind willreturn
860; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@test12-5
861; IS__CGSCC_OPM-SAME: (i32* align 16 [[P:%.*]]) #[[ATTR8:[0-9]+]] {
862; IS__CGSCC_OPM-NEXT:    [[P_CAST:%.*]] = bitcast i32* [[P]] to i64*
863; IS__CGSCC_OPM-NEXT:    [[ARRAYIDX0:%.*]] = getelementptr i64, i64* [[P_CAST]], i64 1
864; IS__CGSCC_OPM-NEXT:    [[ARRAYIDX1:%.*]] = getelementptr i64, i64* [[ARRAYIDX0]], i64 3
865; IS__CGSCC_OPM-NEXT:    tail call void @use(i64* align 16 [[ARRAYIDX1]]) #[[ATTR8]]
866; IS__CGSCC_OPM-NEXT:    ret void
867;
868; IS__CGSCC_NPM: Function Attrs: nounwind willreturn
869; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@test12-5
870; IS__CGSCC_NPM-SAME: (i32* align 16 [[P:%.*]]) #[[ATTR7:[0-9]+]] {
871; IS__CGSCC_NPM-NEXT:    [[P_CAST:%.*]] = bitcast i32* [[P]] to i64*
872; IS__CGSCC_NPM-NEXT:    [[ARRAYIDX0:%.*]] = getelementptr i64, i64* [[P_CAST]], i64 1
873; IS__CGSCC_NPM-NEXT:    [[ARRAYIDX1:%.*]] = getelementptr i64, i64* [[ARRAYIDX0]], i64 3
874; IS__CGSCC_NPM-NEXT:    tail call void @use(i64* align 16 [[ARRAYIDX1]]) #[[ATTR7]]
875; IS__CGSCC_NPM-NEXT:    ret void
876;
877  %p-cast = bitcast i32* %p to i64*
878  %arrayidx0 = getelementptr i64, i64* %p-cast, i64 1
879  %arrayidx1 = getelementptr i64, i64* %arrayidx0, i64 3
880  tail call void @use(i64* align 16 %arrayidx1)
881  ret void
882}
883
884define void @test12-6(i32* align 4 %p) {
885; IS__TUNIT____: Function Attrs: nounwind willreturn
886; IS__TUNIT____-LABEL: define {{[^@]+}}@test12-6
887; IS__TUNIT____-SAME: (i32* align 16 [[P:%.*]]) #[[ATTR6]] {
888; IS__TUNIT____-NEXT:    [[P_CAST:%.*]] = bitcast i32* [[P]] to i64*
889; IS__TUNIT____-NEXT:    [[ARRAYIDX0:%.*]] = getelementptr i64, i64* [[P_CAST]], i64 0
890; IS__TUNIT____-NEXT:    tail call void @use(i64* align 16 [[ARRAYIDX0]]) #[[ATTR6]]
891; IS__TUNIT____-NEXT:    ret void
892;
893; IS__CGSCC_OPM: Function Attrs: nounwind willreturn
894; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@test12-6
895; IS__CGSCC_OPM-SAME: (i32* align 16 [[P:%.*]]) #[[ATTR8]] {
896; IS__CGSCC_OPM-NEXT:    [[P_CAST:%.*]] = bitcast i32* [[P]] to i64*
897; IS__CGSCC_OPM-NEXT:    [[ARRAYIDX0:%.*]] = getelementptr i64, i64* [[P_CAST]], i64 0
898; IS__CGSCC_OPM-NEXT:    tail call void @use(i64* align 16 [[ARRAYIDX0]]) #[[ATTR8]]
899; IS__CGSCC_OPM-NEXT:    ret void
900;
901; IS__CGSCC_NPM: Function Attrs: nounwind willreturn
902; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@test12-6
903; IS__CGSCC_NPM-SAME: (i32* align 16 [[P:%.*]]) #[[ATTR7]] {
904; IS__CGSCC_NPM-NEXT:    [[P_CAST:%.*]] = bitcast i32* [[P]] to i64*
905; IS__CGSCC_NPM-NEXT:    [[ARRAYIDX0:%.*]] = getelementptr i64, i64* [[P_CAST]], i64 0
906; IS__CGSCC_NPM-NEXT:    tail call void @use(i64* align 16 [[ARRAYIDX0]]) #[[ATTR7]]
907; IS__CGSCC_NPM-NEXT:    ret void
908;
909  %p-cast = bitcast i32* %p to i64*
910  %arrayidx0 = getelementptr i64, i64* %p-cast, i64 0
911  tail call void @use(i64* align 16 %arrayidx0)
912  ret void
913}
914
915define void @test13(i1 %c, i32* align 32 %dst) #0 {
916; IS__TUNIT____: Function Attrs: argmemonly nofree noinline nosync nounwind uwtable willreturn writeonly
917; IS__TUNIT____-LABEL: define {{[^@]+}}@test13
918; IS__TUNIT____-SAME: (i1 [[C:%.*]], i32* nocapture nofree writeonly align 32 [[DST:%.*]]) #[[ATTR7:[0-9]+]] {
919; IS__TUNIT____-NEXT:    br i1 [[C]], label [[TRUEBB:%.*]], label [[FALSEBB:%.*]]
920; IS__TUNIT____:       truebb:
921; IS__TUNIT____-NEXT:    br label [[END:%.*]]
922; IS__TUNIT____:       falsebb:
923; IS__TUNIT____-NEXT:    br label [[END]]
924; IS__TUNIT____:       end:
925; IS__TUNIT____-NEXT:    [[PTR:%.*]] = phi i32* [ [[DST]], [[TRUEBB]] ], [ null, [[FALSEBB]] ]
926; IS__TUNIT____-NEXT:    store i32 0, i32* [[PTR]], align 32
927; IS__TUNIT____-NEXT:    ret void
928;
929; IS__CGSCC_OPM: Function Attrs: argmemonly nofree noinline norecurse nosync nounwind uwtable willreturn writeonly
930; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@test13
931; IS__CGSCC_OPM-SAME: (i1 [[C:%.*]], i32* nocapture nofree writeonly align 32 [[DST:%.*]]) #[[ATTR9:[0-9]+]] {
932; IS__CGSCC_OPM-NEXT:    br i1 [[C]], label [[TRUEBB:%.*]], label [[FALSEBB:%.*]]
933; IS__CGSCC_OPM:       truebb:
934; IS__CGSCC_OPM-NEXT:    br label [[END:%.*]]
935; IS__CGSCC_OPM:       falsebb:
936; IS__CGSCC_OPM-NEXT:    br label [[END]]
937; IS__CGSCC_OPM:       end:
938; IS__CGSCC_OPM-NEXT:    [[PTR:%.*]] = phi i32* [ [[DST]], [[TRUEBB]] ], [ null, [[FALSEBB]] ]
939; IS__CGSCC_OPM-NEXT:    store i32 0, i32* [[PTR]], align 32
940; IS__CGSCC_OPM-NEXT:    ret void
941;
942; IS__CGSCC_NPM: Function Attrs: argmemonly nofree noinline norecurse nosync nounwind uwtable willreturn writeonly
943; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@test13
944; IS__CGSCC_NPM-SAME: (i1 [[C:%.*]], i32* nocapture nofree writeonly align 32 [[DST:%.*]]) #[[ATTR8:[0-9]+]] {
945; IS__CGSCC_NPM-NEXT:    br i1 [[C]], label [[TRUEBB:%.*]], label [[FALSEBB:%.*]]
946; IS__CGSCC_NPM:       truebb:
947; IS__CGSCC_NPM-NEXT:    br label [[END:%.*]]
948; IS__CGSCC_NPM:       falsebb:
949; IS__CGSCC_NPM-NEXT:    br label [[END]]
950; IS__CGSCC_NPM:       end:
951; IS__CGSCC_NPM-NEXT:    [[PTR:%.*]] = phi i32* [ [[DST]], [[TRUEBB]] ], [ null, [[FALSEBB]] ]
952; IS__CGSCC_NPM-NEXT:    store i32 0, i32* [[PTR]], align 32
953; IS__CGSCC_NPM-NEXT:    ret void
954;
955  br i1 %c, label %truebb, label %falsebb
956truebb:
957  br label %end
958falsebb:
959  br label %end
960end:
961  %ptr = phi i32* [ %dst, %truebb ], [ null, %falsebb ]
962  store i32 0, i32* %ptr
963  ret void
964}
965
966define void @test13-1(i1 %c, i32* align 32 %dst) {
967; IS__TUNIT____: Function Attrs: nofree nosync nounwind willreturn writeonly
968; IS__TUNIT____-LABEL: define {{[^@]+}}@test13-1
969; IS__TUNIT____-SAME: (i1 [[C:%.*]], i32* nocapture nofree writeonly align 32 [[DST:%.*]]) #[[ATTR8:[0-9]+]] {
970; IS__TUNIT____-NEXT:    br i1 [[C]], label [[TRUEBB:%.*]], label [[FALSEBB:%.*]]
971; IS__TUNIT____:       truebb:
972; IS__TUNIT____-NEXT:    br label [[END:%.*]]
973; IS__TUNIT____:       falsebb:
974; IS__TUNIT____-NEXT:    br label [[END]]
975; IS__TUNIT____:       end:
976; IS__TUNIT____-NEXT:    [[PTR:%.*]] = phi i32* [ [[DST]], [[TRUEBB]] ], [ inttoptr (i64 48 to i32*), [[FALSEBB]] ]
977; IS__TUNIT____-NEXT:    store i32 0, i32* [[PTR]], align 16
978; IS__TUNIT____-NEXT:    ret void
979;
980; IS__CGSCC_OPM: Function Attrs: nofree norecurse nosync nounwind willreturn writeonly
981; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@test13-1
982; IS__CGSCC_OPM-SAME: (i1 [[C:%.*]], i32* nocapture nofree writeonly align 32 [[DST:%.*]]) #[[ATTR10:[0-9]+]] {
983; IS__CGSCC_OPM-NEXT:    br i1 [[C]], label [[TRUEBB:%.*]], label [[FALSEBB:%.*]]
984; IS__CGSCC_OPM:       truebb:
985; IS__CGSCC_OPM-NEXT:    br label [[END:%.*]]
986; IS__CGSCC_OPM:       falsebb:
987; IS__CGSCC_OPM-NEXT:    br label [[END]]
988; IS__CGSCC_OPM:       end:
989; IS__CGSCC_OPM-NEXT:    [[PTR:%.*]] = phi i32* [ [[DST]], [[TRUEBB]] ], [ inttoptr (i64 48 to i32*), [[FALSEBB]] ]
990; IS__CGSCC_OPM-NEXT:    store i32 0, i32* [[PTR]], align 16
991; IS__CGSCC_OPM-NEXT:    ret void
992;
993; IS__CGSCC_NPM: Function Attrs: nofree norecurse nosync nounwind willreturn writeonly
994; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@test13-1
995; IS__CGSCC_NPM-SAME: (i1 [[C:%.*]], i32* nocapture nofree writeonly align 32 [[DST:%.*]]) #[[ATTR9:[0-9]+]] {
996; IS__CGSCC_NPM-NEXT:    br i1 [[C]], label [[TRUEBB:%.*]], label [[FALSEBB:%.*]]
997; IS__CGSCC_NPM:       truebb:
998; IS__CGSCC_NPM-NEXT:    br label [[END:%.*]]
999; IS__CGSCC_NPM:       falsebb:
1000; IS__CGSCC_NPM-NEXT:    br label [[END]]
1001; IS__CGSCC_NPM:       end:
1002; IS__CGSCC_NPM-NEXT:    [[PTR:%.*]] = phi i32* [ [[DST]], [[TRUEBB]] ], [ inttoptr (i64 48 to i32*), [[FALSEBB]] ]
1003; IS__CGSCC_NPM-NEXT:    store i32 0, i32* [[PTR]], align 16
1004; IS__CGSCC_NPM-NEXT:    ret void
1005;
1006  br i1 %c, label %truebb, label %falsebb
1007truebb:
1008  br label %end
1009falsebb:
1010  br label %end
1011end:
1012  %ptr = phi i32* [ %dst, %truebb ], [ inttoptr (i64 48 to i32*), %falsebb ]
1013  store i32 0, i32* %ptr
1014  ret void
1015}
1016
1017define void @test13-2(i1 %c, i32* align 32 %dst) {
1018; IS__TUNIT____: Function Attrs: nofree nosync nounwind willreturn writeonly
1019; IS__TUNIT____-LABEL: define {{[^@]+}}@test13-2
1020; IS__TUNIT____-SAME: (i1 [[C:%.*]], i32* nocapture nofree writeonly align 32 [[DST:%.*]]) #[[ATTR8]] {
1021; IS__TUNIT____-NEXT:    br i1 [[C]], label [[TRUEBB:%.*]], label [[FALSEBB:%.*]]
1022; IS__TUNIT____:       truebb:
1023; IS__TUNIT____-NEXT:    br label [[END:%.*]]
1024; IS__TUNIT____:       falsebb:
1025; IS__TUNIT____-NEXT:    br label [[END]]
1026; IS__TUNIT____:       end:
1027; IS__TUNIT____-NEXT:    [[PTR:%.*]] = phi i32* [ [[DST]], [[TRUEBB]] ], [ inttoptr (i64 160 to i32*), [[FALSEBB]] ]
1028; IS__TUNIT____-NEXT:    store i32 0, i32* [[PTR]], align 32
1029; IS__TUNIT____-NEXT:    ret void
1030;
1031; IS__CGSCC_OPM: Function Attrs: nofree norecurse nosync nounwind willreturn writeonly
1032; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@test13-2
1033; IS__CGSCC_OPM-SAME: (i1 [[C:%.*]], i32* nocapture nofree writeonly align 32 [[DST:%.*]]) #[[ATTR10]] {
1034; IS__CGSCC_OPM-NEXT:    br i1 [[C]], label [[TRUEBB:%.*]], label [[FALSEBB:%.*]]
1035; IS__CGSCC_OPM:       truebb:
1036; IS__CGSCC_OPM-NEXT:    br label [[END:%.*]]
1037; IS__CGSCC_OPM:       falsebb:
1038; IS__CGSCC_OPM-NEXT:    br label [[END]]
1039; IS__CGSCC_OPM:       end:
1040; IS__CGSCC_OPM-NEXT:    [[PTR:%.*]] = phi i32* [ [[DST]], [[TRUEBB]] ], [ inttoptr (i64 160 to i32*), [[FALSEBB]] ]
1041; IS__CGSCC_OPM-NEXT:    store i32 0, i32* [[PTR]], align 32
1042; IS__CGSCC_OPM-NEXT:    ret void
1043;
1044; IS__CGSCC_NPM: Function Attrs: nofree norecurse nosync nounwind willreturn writeonly
1045; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@test13-2
1046; IS__CGSCC_NPM-SAME: (i1 [[C:%.*]], i32* nocapture nofree writeonly align 32 [[DST:%.*]]) #[[ATTR9]] {
1047; IS__CGSCC_NPM-NEXT:    br i1 [[C]], label [[TRUEBB:%.*]], label [[FALSEBB:%.*]]
1048; IS__CGSCC_NPM:       truebb:
1049; IS__CGSCC_NPM-NEXT:    br label [[END:%.*]]
1050; IS__CGSCC_NPM:       falsebb:
1051; IS__CGSCC_NPM-NEXT:    br label [[END]]
1052; IS__CGSCC_NPM:       end:
1053; IS__CGSCC_NPM-NEXT:    [[PTR:%.*]] = phi i32* [ [[DST]], [[TRUEBB]] ], [ inttoptr (i64 160 to i32*), [[FALSEBB]] ]
1054; IS__CGSCC_NPM-NEXT:    store i32 0, i32* [[PTR]], align 32
1055; IS__CGSCC_NPM-NEXT:    ret void
1056;
1057  br i1 %c, label %truebb, label %falsebb
1058truebb:
1059  br label %end
1060falsebb:
1061  br label %end
1062end:
1063  %ptr = phi i32* [ %dst, %truebb ], [ inttoptr (i64 160 to i32*), %falsebb ]
1064  store i32 0, i32* %ptr
1065  ret void
1066}
1067
1068define void @test13-3(i1 %c, i32* align 32 %dst) {
1069; IS__TUNIT____: Function Attrs: nofree nosync nounwind willreturn writeonly
1070; IS__TUNIT____-LABEL: define {{[^@]+}}@test13-3
1071; IS__TUNIT____-SAME: (i1 [[C:%.*]], i32* nocapture nofree writeonly align 32 [[DST:%.*]]) #[[ATTR8]] {
1072; IS__TUNIT____-NEXT:    br i1 [[C]], label [[TRUEBB:%.*]], label [[FALSEBB:%.*]]
1073; IS__TUNIT____:       truebb:
1074; IS__TUNIT____-NEXT:    br label [[END:%.*]]
1075; IS__TUNIT____:       falsebb:
1076; IS__TUNIT____-NEXT:    br label [[END]]
1077; IS__TUNIT____:       end:
1078; IS__TUNIT____-NEXT:    [[PTR:%.*]] = phi i32* [ [[DST]], [[TRUEBB]] ], [ inttoptr (i64 128 to i32*), [[FALSEBB]] ]
1079; IS__TUNIT____-NEXT:    store i32 0, i32* [[PTR]], align 32
1080; IS__TUNIT____-NEXT:    ret void
1081;
1082; IS__CGSCC_OPM: Function Attrs: nofree norecurse nosync nounwind willreturn writeonly
1083; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@test13-3
1084; IS__CGSCC_OPM-SAME: (i1 [[C:%.*]], i32* nocapture nofree writeonly align 32 [[DST:%.*]]) #[[ATTR10]] {
1085; IS__CGSCC_OPM-NEXT:    br i1 [[C]], label [[TRUEBB:%.*]], label [[FALSEBB:%.*]]
1086; IS__CGSCC_OPM:       truebb:
1087; IS__CGSCC_OPM-NEXT:    br label [[END:%.*]]
1088; IS__CGSCC_OPM:       falsebb:
1089; IS__CGSCC_OPM-NEXT:    br label [[END]]
1090; IS__CGSCC_OPM:       end:
1091; IS__CGSCC_OPM-NEXT:    [[PTR:%.*]] = phi i32* [ [[DST]], [[TRUEBB]] ], [ inttoptr (i64 128 to i32*), [[FALSEBB]] ]
1092; IS__CGSCC_OPM-NEXT:    store i32 0, i32* [[PTR]], align 32
1093; IS__CGSCC_OPM-NEXT:    ret void
1094;
1095; IS__CGSCC_NPM: Function Attrs: nofree norecurse nosync nounwind willreturn writeonly
1096; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@test13-3
1097; IS__CGSCC_NPM-SAME: (i1 [[C:%.*]], i32* nocapture nofree writeonly align 32 [[DST:%.*]]) #[[ATTR9]] {
1098; IS__CGSCC_NPM-NEXT:    br i1 [[C]], label [[TRUEBB:%.*]], label [[FALSEBB:%.*]]
1099; IS__CGSCC_NPM:       truebb:
1100; IS__CGSCC_NPM-NEXT:    br label [[END:%.*]]
1101; IS__CGSCC_NPM:       falsebb:
1102; IS__CGSCC_NPM-NEXT:    br label [[END]]
1103; IS__CGSCC_NPM:       end:
1104; IS__CGSCC_NPM-NEXT:    [[PTR:%.*]] = phi i32* [ [[DST]], [[TRUEBB]] ], [ inttoptr (i64 128 to i32*), [[FALSEBB]] ]
1105; IS__CGSCC_NPM-NEXT:    store i32 0, i32* [[PTR]], align 32
1106; IS__CGSCC_NPM-NEXT:    ret void
1107;
1108  br i1 %c, label %truebb, label %falsebb
1109truebb:
1110  br label %end
1111falsebb:
1112  br label %end
1113end:
1114  %ptr = phi i32* [ %dst, %truebb ], [ inttoptr (i64 128 to i32*), %falsebb ]
1115  store i32 0, i32* %ptr
1116  ret void
1117}
1118
1119; Don't crash on ptr2int/int2ptr uses.
1120define i64 @ptr2int(i32* %p) {
1121; IS__TUNIT____: Function Attrs: nofree nosync nounwind readnone willreturn
1122; IS__TUNIT____-LABEL: define {{[^@]+}}@ptr2int
1123; IS__TUNIT____-SAME: (i32* nofree readnone [[P:%.*]]) #[[ATTR9]] {
1124; IS__TUNIT____-NEXT:    [[P2I:%.*]] = ptrtoint i32* [[P]] to i64
1125; IS__TUNIT____-NEXT:    ret i64 [[P2I]]
1126;
1127; IS__CGSCC_OPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1128; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@ptr2int
1129; IS__CGSCC_OPM-SAME: (i32* nofree readnone [[P:%.*]]) #[[ATTR11:[0-9]+]] {
1130; IS__CGSCC_OPM-NEXT:    [[P2I:%.*]] = ptrtoint i32* [[P]] to i64
1131; IS__CGSCC_OPM-NEXT:    ret i64 [[P2I]]
1132;
1133; IS__CGSCC_NPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1134; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@ptr2int
1135; IS__CGSCC_NPM-SAME: (i32* nofree readnone [[P:%.*]]) #[[ATTR10:[0-9]+]] {
1136; IS__CGSCC_NPM-NEXT:    [[P2I:%.*]] = ptrtoint i32* [[P]] to i64
1137; IS__CGSCC_NPM-NEXT:    ret i64 [[P2I]]
1138;
1139  %p2i = ptrtoint i32* %p to i64
1140  ret i64 %p2i
1141}
1142define i64* @int2ptr(i64 %i) {
1143; IS__TUNIT____: Function Attrs: nofree nosync nounwind readnone willreturn
1144; IS__TUNIT____-LABEL: define {{[^@]+}}@int2ptr
1145; IS__TUNIT____-SAME: (i64 [[I:%.*]]) #[[ATTR9]] {
1146; IS__TUNIT____-NEXT:    [[I2P:%.*]] = inttoptr i64 [[I]] to i64*
1147; IS__TUNIT____-NEXT:    ret i64* [[I2P]]
1148;
1149; IS__CGSCC_OPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1150; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@int2ptr
1151; IS__CGSCC_OPM-SAME: (i64 [[I:%.*]]) #[[ATTR11]] {
1152; IS__CGSCC_OPM-NEXT:    [[I2P:%.*]] = inttoptr i64 [[I]] to i64*
1153; IS__CGSCC_OPM-NEXT:    ret i64* [[I2P]]
1154;
1155; IS__CGSCC_NPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1156; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@int2ptr
1157; IS__CGSCC_NPM-SAME: (i64 [[I:%.*]]) #[[ATTR10]] {
1158; IS__CGSCC_NPM-NEXT:    [[I2P:%.*]] = inttoptr i64 [[I]] to i64*
1159; IS__CGSCC_NPM-NEXT:    ret i64* [[I2P]]
1160;
1161  %i2p = inttoptr i64 %i to i64*
1162  ret i64* %i2p
1163}
1164
1165; Use the store alignment only for the pointer operand.
1166define void @aligned_store(i8* %Value, i8** %Ptr) {
1167; IS__TUNIT____: Function Attrs: argmemonly nofree nosync nounwind willreturn writeonly
1168; IS__TUNIT____-LABEL: define {{[^@]+}}@aligned_store
1169; IS__TUNIT____-SAME: (i8* nofree writeonly [[VALUE:%.*]], i8** nocapture nofree noundef nonnull writeonly align 32 dereferenceable(8) [[PTR:%.*]]) #[[ATTR5]] {
1170; IS__TUNIT____-NEXT:    store i8* [[VALUE]], i8** [[PTR]], align 32
1171; IS__TUNIT____-NEXT:    ret void
1172;
1173; IS__CGSCC_OPM: Function Attrs: argmemonly nofree norecurse nosync nounwind willreturn writeonly
1174; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@aligned_store
1175; IS__CGSCC_OPM-SAME: (i8* nofree writeonly [[VALUE:%.*]], i8** nocapture nofree noundef nonnull writeonly align 32 dereferenceable(8) [[PTR:%.*]]) #[[ATTR7]] {
1176; IS__CGSCC_OPM-NEXT:    store i8* [[VALUE]], i8** [[PTR]], align 32
1177; IS__CGSCC_OPM-NEXT:    ret void
1178;
1179; IS__CGSCC_NPM: Function Attrs: argmemonly nofree norecurse nosync nounwind willreturn writeonly
1180; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@aligned_store
1181; IS__CGSCC_NPM-SAME: (i8* nofree writeonly [[VALUE:%.*]], i8** nocapture nofree noundef nonnull writeonly align 32 dereferenceable(8) [[PTR:%.*]]) #[[ATTR6]] {
1182; IS__CGSCC_NPM-NEXT:    store i8* [[VALUE]], i8** [[PTR]], align 32
1183; IS__CGSCC_NPM-NEXT:    ret void
1184;
1185  store i8* %Value, i8** %Ptr, align 32
1186  ret void
1187}
1188
1189declare i8* @some_func(i8*)
1190define void @align_call_op_not_store(i8* align 2048 %arg) {
1191; CHECK-LABEL: define {{[^@]+}}@align_call_op_not_store
1192; CHECK-SAME: (i8* align 2048 [[ARG:%.*]]) {
1193; CHECK-NEXT:    [[UNKNOWN:%.*]] = call i8* @some_func(i8* align 2048 [[ARG]])
1194; CHECK-NEXT:    store i8 0, i8* [[UNKNOWN]], align 1
1195; CHECK-NEXT:    ret void
1196;
1197  %unknown = call i8* @some_func(i8* %arg)
1198  store i8 0, i8* %unknown
1199  ret void
1200}
1201define void @align_store_after_bc(i32* align 2048 %arg) {
1202;
1203; IS__TUNIT____: Function Attrs: argmemonly nofree nosync nounwind willreturn writeonly
1204; IS__TUNIT____-LABEL: define {{[^@]+}}@align_store_after_bc
1205; IS__TUNIT____-SAME: (i32* nocapture nofree nonnull writeonly align 2048 dereferenceable(1) [[ARG:%.*]]) #[[ATTR5]] {
1206; IS__TUNIT____-NEXT:    [[BC:%.*]] = bitcast i32* [[ARG]] to i8*
1207; IS__TUNIT____-NEXT:    store i8 0, i8* [[BC]], align 2048
1208; IS__TUNIT____-NEXT:    ret void
1209;
1210; IS__CGSCC_OPM: Function Attrs: argmemonly nofree norecurse nosync nounwind willreturn writeonly
1211; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@align_store_after_bc
1212; IS__CGSCC_OPM-SAME: (i32* nocapture nofree nonnull writeonly align 2048 dereferenceable(1) [[ARG:%.*]]) #[[ATTR7]] {
1213; IS__CGSCC_OPM-NEXT:    [[BC:%.*]] = bitcast i32* [[ARG]] to i8*
1214; IS__CGSCC_OPM-NEXT:    store i8 0, i8* [[BC]], align 2048
1215; IS__CGSCC_OPM-NEXT:    ret void
1216;
1217; IS__CGSCC_NPM: Function Attrs: argmemonly nofree norecurse nosync nounwind willreturn writeonly
1218; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@align_store_after_bc
1219; IS__CGSCC_NPM-SAME: (i32* nocapture nofree nonnull writeonly align 2048 dereferenceable(1) [[ARG:%.*]]) #[[ATTR6]] {
1220; IS__CGSCC_NPM-NEXT:    [[BC:%.*]] = bitcast i32* [[ARG]] to i8*
1221; IS__CGSCC_NPM-NEXT:    store i8 0, i8* [[BC]], align 2048
1222; IS__CGSCC_NPM-NEXT:    ret void
1223;
1224  %bc = bitcast i32* %arg to i8*
1225  store i8 0, i8* %bc
1226  ret void
1227}
1228
1229; Make sure we do not annotate the callee of a must-tail call with an alignment
1230; we cannot also put on the caller.
1231@cnd = external global i1
1232define i32 @musttail_callee_1(i32* %p) {
1233; IS__TUNIT____: Function Attrs: argmemonly nofree nosync nounwind readonly willreturn
1234; IS__TUNIT____-LABEL: define {{[^@]+}}@musttail_callee_1
1235; IS__TUNIT____-SAME: (i32* nocapture nofree noundef nonnull readonly dereferenceable(4) [[P:%.*]]) #[[ATTR4]] {
1236; IS__TUNIT____-NEXT:    [[V:%.*]] = load i32, i32* [[P]], align 32
1237; IS__TUNIT____-NEXT:    ret i32 [[V]]
1238;
1239; IS__CGSCC_OPM: Function Attrs: argmemonly nofree norecurse nosync nounwind readonly willreturn
1240; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@musttail_callee_1
1241; IS__CGSCC_OPM-SAME: (i32* nocapture nofree noundef nonnull readonly dereferenceable(4) [[P:%.*]]) #[[ATTR6]] {
1242; IS__CGSCC_OPM-NEXT:    [[V:%.*]] = load i32, i32* [[P]], align 32
1243; IS__CGSCC_OPM-NEXT:    ret i32 [[V]]
1244;
1245; IS__CGSCC_NPM: Function Attrs: argmemonly nofree norecurse nosync nounwind readonly willreturn
1246; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@musttail_callee_1
1247; IS__CGSCC_NPM-SAME: (i32* nocapture nofree noundef nonnull readonly dereferenceable(4) [[P:%.*]]) #[[ATTR5]] {
1248; IS__CGSCC_NPM-NEXT:    [[V:%.*]] = load i32, i32* [[P]], align 32
1249; IS__CGSCC_NPM-NEXT:    ret i32 [[V]]
1250;
1251  %v = load i32, i32* %p, align 32
1252  ret i32 %v
1253}
1254define i32 @musttail_caller_1(i32* %p) {
1255; IS__TUNIT____: Function Attrs: nofree nosync nounwind readonly willreturn
1256; IS__TUNIT____-LABEL: define {{[^@]+}}@musttail_caller_1
1257; IS__TUNIT____-SAME: (i32* nocapture nofree readonly [[P:%.*]]) #[[ATTR10:[0-9]+]] {
1258; IS__TUNIT____-NEXT:    [[C:%.*]] = load i1, i1* @cnd, align 1
1259; IS__TUNIT____-NEXT:    br i1 [[C]], label [[MT:%.*]], label [[EXIT:%.*]]
1260; IS__TUNIT____:       mt:
1261; IS__TUNIT____-NEXT:    [[V:%.*]] = musttail call i32 @musttail_callee_1(i32* nocapture nofree readonly [[P]]) #[[ATTR10]]
1262; IS__TUNIT____-NEXT:    ret i32 [[V]]
1263; IS__TUNIT____:       exit:
1264; IS__TUNIT____-NEXT:    ret i32 0
1265;
1266; IS__CGSCC_OPM: Function Attrs: nofree norecurse nosync nounwind readonly willreturn
1267; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@musttail_caller_1
1268; IS__CGSCC_OPM-SAME: (i32* nocapture nofree readonly [[P:%.*]]) #[[ATTR12:[0-9]+]] {
1269; IS__CGSCC_OPM-NEXT:    [[C:%.*]] = load i1, i1* @cnd, align 1
1270; IS__CGSCC_OPM-NEXT:    br i1 [[C]], label [[MT:%.*]], label [[EXIT:%.*]]
1271; IS__CGSCC_OPM:       mt:
1272; IS__CGSCC_OPM-NEXT:    [[V:%.*]] = musttail call i32 @musttail_callee_1(i32* nocapture nofree noundef nonnull readonly dereferenceable(4) [[P]]) #[[ATTR14:[0-9]+]]
1273; IS__CGSCC_OPM-NEXT:    ret i32 [[V]]
1274; IS__CGSCC_OPM:       exit:
1275; IS__CGSCC_OPM-NEXT:    ret i32 0
1276;
1277; IS__CGSCC_NPM: Function Attrs: nofree norecurse nosync nounwind readonly willreturn
1278; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@musttail_caller_1
1279; IS__CGSCC_NPM-SAME: (i32* nocapture nofree readonly [[P:%.*]]) #[[ATTR11:[0-9]+]] {
1280; IS__CGSCC_NPM-NEXT:    [[C:%.*]] = load i1, i1* @cnd, align 1
1281; IS__CGSCC_NPM-NEXT:    br i1 [[C]], label [[MT:%.*]], label [[EXIT:%.*]]
1282; IS__CGSCC_NPM:       mt:
1283; IS__CGSCC_NPM-NEXT:    [[V:%.*]] = musttail call i32 @musttail_callee_1(i32* nocapture nofree noundef nonnull readonly dereferenceable(4) [[P]]) #[[ATTR13:[0-9]+]]
1284; IS__CGSCC_NPM-NEXT:    ret i32 [[V]]
1285; IS__CGSCC_NPM:       exit:
1286; IS__CGSCC_NPM-NEXT:    ret i32 0
1287;
1288  %c = load i1, i1* @cnd
1289  br i1 %c, label %mt, label %exit
1290mt:
1291  %v = musttail call i32 @musttail_callee_1(i32* %p)
1292  ret i32 %v
1293exit:
1294  ret i32 0
1295}
1296
1297define i32* @checkAndAdvance(i32* align(16) %p) {
1298; IS__TUNIT____: Function Attrs: nounwind
1299; IS__TUNIT____-LABEL: define {{[^@]+}}@checkAndAdvance
1300; IS__TUNIT____-SAME: (i32* noundef nonnull readonly align 16 dereferenceable(4) "no-capture-maybe-returned" [[P:%.*]]) #[[ATTR2]] {
1301; IS__TUNIT____-NEXT:  entry:
1302; IS__TUNIT____-NEXT:    [[TMP0:%.*]] = load i32, i32* [[P]], align 16
1303; IS__TUNIT____-NEXT:    [[CMP:%.*]] = icmp eq i32 [[TMP0]], 0
1304; IS__TUNIT____-NEXT:    br i1 [[CMP]], label [[IF_THEN:%.*]], label [[RETURN:%.*]]
1305; IS__TUNIT____:       if.then:
1306; IS__TUNIT____-NEXT:    [[ADD_PTR:%.*]] = getelementptr inbounds i32, i32* [[P]], i64 4
1307; IS__TUNIT____-NEXT:    [[CALL:%.*]] = call nonnull align 16 i32* @checkAndAdvance(i32* nonnull readonly align 16 "no-capture-maybe-returned" [[ADD_PTR]]) #[[ATTR2]]
1308; IS__TUNIT____-NEXT:    br label [[RETURN]]
1309; IS__TUNIT____:       return:
1310; IS__TUNIT____-NEXT:    [[RETVAL_0:%.*]] = phi i32* [ [[CALL]], [[IF_THEN]] ], [ [[P]], [[ENTRY:%.*]] ]
1311; IS__TUNIT____-NEXT:    call void @user_i32_ptr(i32* noalias nocapture nonnull readnone align 16 [[RETVAL_0]]) #[[ATTR2]]
1312; IS__TUNIT____-NEXT:    ret i32* [[RETVAL_0]]
1313;
1314; IS__CGSCC_OPM: Function Attrs: nounwind
1315; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@checkAndAdvance
1316; IS__CGSCC_OPM-SAME: (i32* noundef nonnull readonly align 16 dereferenceable(4) "no-capture-maybe-returned" [[P:%.*]]) #[[ATTR4]] {
1317; IS__CGSCC_OPM-NEXT:  entry:
1318; IS__CGSCC_OPM-NEXT:    [[TMP0:%.*]] = load i32, i32* [[P]], align 16
1319; IS__CGSCC_OPM-NEXT:    [[CMP:%.*]] = icmp eq i32 [[TMP0]], 0
1320; IS__CGSCC_OPM-NEXT:    br i1 [[CMP]], label [[IF_THEN:%.*]], label [[RETURN:%.*]]
1321; IS__CGSCC_OPM:       if.then:
1322; IS__CGSCC_OPM-NEXT:    [[ADD_PTR:%.*]] = getelementptr inbounds i32, i32* [[P]], i64 4
1323; IS__CGSCC_OPM-NEXT:    [[CALL:%.*]] = call nonnull align 16 i32* @checkAndAdvance(i32* nonnull readonly align 16 "no-capture-maybe-returned" [[ADD_PTR]]) #[[ATTR4]]
1324; IS__CGSCC_OPM-NEXT:    br label [[RETURN]]
1325; IS__CGSCC_OPM:       return:
1326; IS__CGSCC_OPM-NEXT:    [[RETVAL_0:%.*]] = phi i32* [ [[CALL]], [[IF_THEN]] ], [ [[P]], [[ENTRY:%.*]] ]
1327; IS__CGSCC_OPM-NEXT:    call void @user_i32_ptr(i32* noalias nocapture nonnull readnone align 16 [[RETVAL_0]]) #[[ATTR4]]
1328; IS__CGSCC_OPM-NEXT:    ret i32* [[RETVAL_0]]
1329;
1330; IS__CGSCC_NPM: Function Attrs: nounwind
1331; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@checkAndAdvance
1332; IS__CGSCC_NPM-SAME: (i32* noundef nonnull readonly align 16 dereferenceable(4) "no-capture-maybe-returned" [[P:%.*]]) #[[ATTR3]] {
1333; IS__CGSCC_NPM-NEXT:  entry:
1334; IS__CGSCC_NPM-NEXT:    [[TMP0:%.*]] = load i32, i32* [[P]], align 16
1335; IS__CGSCC_NPM-NEXT:    [[CMP:%.*]] = icmp eq i32 [[TMP0]], 0
1336; IS__CGSCC_NPM-NEXT:    br i1 [[CMP]], label [[IF_THEN:%.*]], label [[RETURN:%.*]]
1337; IS__CGSCC_NPM:       if.then:
1338; IS__CGSCC_NPM-NEXT:    [[ADD_PTR:%.*]] = getelementptr inbounds i32, i32* [[P]], i64 4
1339; IS__CGSCC_NPM-NEXT:    [[CALL:%.*]] = call nonnull align 16 i32* @checkAndAdvance(i32* nonnull readonly align 16 "no-capture-maybe-returned" [[ADD_PTR]]) #[[ATTR3]]
1340; IS__CGSCC_NPM-NEXT:    br label [[RETURN]]
1341; IS__CGSCC_NPM:       return:
1342; IS__CGSCC_NPM-NEXT:    [[RETVAL_0:%.*]] = phi i32* [ [[CALL]], [[IF_THEN]] ], [ [[P]], [[ENTRY:%.*]] ]
1343; IS__CGSCC_NPM-NEXT:    call void @user_i32_ptr(i32* noalias nocapture nonnull readnone align 16 [[RETVAL_0]]) #[[ATTR3]]
1344; IS__CGSCC_NPM-NEXT:    ret i32* [[RETVAL_0]]
1345;
1346entry:
1347  %0 = load i32, i32* %p, align 4
1348  %cmp = icmp eq i32 %0, 0
1349  br i1 %cmp, label %if.then, label %return
1350
1351if.then:                                          ; preds = %entry
1352  %add.ptr = getelementptr inbounds i32, i32* %p, i64 4
1353  %call = call i32* @checkAndAdvance(i32* nonnull %add.ptr)
1354  br label %return
1355
1356return:                                           ; preds = %entry, %if.then
1357  %retval.0 = phi i32* [ %call, %if.then ], [ %p, %entry ]
1358  call void @user_i32_ptr(i32* %retval.0)
1359  ret i32* %retval.0
1360}
1361
1362; FIXME: align 4 should not be propagated to the caller's p unless there is noundef
1363define void @align4_caller(i8* %p) {
1364; CHECK-LABEL: define {{[^@]+}}@align4_caller
1365; CHECK-SAME: (i8* align 4 [[P:%.*]]) {
1366; CHECK-NEXT:    call void @align4_callee(i8* align 4 [[P]])
1367; CHECK-NEXT:    ret void
1368;
1369  call void @align4_callee(i8* %p)
1370  ret void
1371}
1372
1373declare void @align4_callee(i8* align(4) %p)
1374
1375
1376attributes #0 = { nounwind uwtable noinline }
1377attributes #1 = { uwtable noinline }
1378attributes #2 = { null_pointer_is_valid }
1379;.
1380; IS__TUNIT____: attributes #[[ATTR0]] = { nofree noinline nosync nounwind readnone uwtable willreturn }
1381; IS__TUNIT____: attributes #[[ATTR1]] = { nofree noinline noreturn nosync nounwind readnone uwtable }
1382; IS__TUNIT____: attributes #[[ATTR2]] = { nounwind }
1383; IS__TUNIT____: attributes #[[ATTR3]] = { nofree nosync nounwind }
1384; IS__TUNIT____: attributes #[[ATTR4]] = { argmemonly nofree nosync nounwind readonly willreturn }
1385; IS__TUNIT____: attributes #[[ATTR5]] = { argmemonly nofree nosync nounwind willreturn writeonly }
1386; IS__TUNIT____: attributes #[[ATTR6]] = { nounwind willreturn }
1387; IS__TUNIT____: attributes #[[ATTR7]] = { argmemonly nofree noinline nosync nounwind uwtable willreturn writeonly }
1388; IS__TUNIT____: attributes #[[ATTR8]] = { nofree nosync nounwind willreturn writeonly }
1389; IS__TUNIT____: attributes #[[ATTR9]] = { nofree nosync nounwind readnone willreturn }
1390; IS__TUNIT____: attributes #[[ATTR10]] = { nofree nosync nounwind readonly willreturn }
1391; IS__TUNIT____: attributes #[[ATTR11]] = { nofree noreturn nosync nounwind readnone }
1392;.
1393; IS__CGSCC_OPM: attributes #[[ATTR0]] = { nofree noinline norecurse nosync nounwind readnone uwtable willreturn }
1394; IS__CGSCC_OPM: attributes #[[ATTR1]] = { nofree noinline noreturn nosync nounwind readnone uwtable }
1395; IS__CGSCC_OPM: attributes #[[ATTR2]] = { nofree noinline nosync nounwind readnone uwtable willreturn }
1396; IS__CGSCC_OPM: attributes #[[ATTR3]] = { noinline nounwind uwtable }
1397; IS__CGSCC_OPM: attributes #[[ATTR4]] = { nounwind }
1398; IS__CGSCC_OPM: attributes #[[ATTR5]] = { nofree nosync nounwind }
1399; IS__CGSCC_OPM: attributes #[[ATTR6]] = { argmemonly nofree norecurse nosync nounwind readonly willreturn }
1400; IS__CGSCC_OPM: attributes #[[ATTR7]] = { argmemonly nofree norecurse nosync nounwind willreturn writeonly }
1401; IS__CGSCC_OPM: attributes #[[ATTR8]] = { nounwind willreturn }
1402; IS__CGSCC_OPM: attributes #[[ATTR9]] = { argmemonly nofree noinline norecurse nosync nounwind uwtable willreturn writeonly }
1403; IS__CGSCC_OPM: attributes #[[ATTR10]] = { nofree norecurse nosync nounwind willreturn writeonly }
1404; IS__CGSCC_OPM: attributes #[[ATTR11]] = { nofree norecurse nosync nounwind readnone willreturn }
1405; IS__CGSCC_OPM: attributes #[[ATTR12]] = { nofree norecurse nosync nounwind readonly willreturn }
1406; IS__CGSCC_OPM: attributes #[[ATTR13]] = { nofree noreturn nosync nounwind readnone }
1407; IS__CGSCC_OPM: attributes #[[ATTR14]] = { readonly willreturn }
1408;.
1409; IS__CGSCC_NPM: attributes #[[ATTR0]] = { nofree noinline norecurse nosync nounwind readnone uwtable willreturn }
1410; IS__CGSCC_NPM: attributes #[[ATTR1]] = { nofree noinline noreturn nosync nounwind readnone uwtable }
1411; IS__CGSCC_NPM: attributes #[[ATTR2]] = { noinline nounwind uwtable }
1412; IS__CGSCC_NPM: attributes #[[ATTR3]] = { nounwind }
1413; IS__CGSCC_NPM: attributes #[[ATTR4]] = { nofree nosync nounwind }
1414; IS__CGSCC_NPM: attributes #[[ATTR5]] = { argmemonly nofree norecurse nosync nounwind readonly willreturn }
1415; IS__CGSCC_NPM: attributes #[[ATTR6]] = { argmemonly nofree norecurse nosync nounwind willreturn writeonly }
1416; IS__CGSCC_NPM: attributes #[[ATTR7]] = { nounwind willreturn }
1417; IS__CGSCC_NPM: attributes #[[ATTR8]] = { argmemonly nofree noinline norecurse nosync nounwind uwtable willreturn writeonly }
1418; IS__CGSCC_NPM: attributes #[[ATTR9]] = { nofree norecurse nosync nounwind willreturn writeonly }
1419; IS__CGSCC_NPM: attributes #[[ATTR10]] = { nofree norecurse nosync nounwind readnone willreturn }
1420; IS__CGSCC_NPM: attributes #[[ATTR11]] = { nofree norecurse nosync nounwind readonly willreturn }
1421; IS__CGSCC_NPM: attributes #[[ATTR12]] = { nofree noreturn nosync nounwind readnone }
1422; IS__CGSCC_NPM: attributes #[[ATTR13]] = { readonly willreturn }
1423;.
1424