1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-attributes
2; RUN: opt -attributor -enable-new-pm=0 -attributor-manifest-internal  -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=1 -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_CGSCC_NPM,NOT_CGSCC_OPM,NOT_TUNIT_NPM,IS__TUNIT____,IS________OPM,IS__TUNIT_OPM
3; RUN: opt -aa-pipeline=basic-aa -passes=attributor -attributor-manifest-internal  -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=1 -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_CGSCC_OPM,NOT_CGSCC_NPM,NOT_TUNIT_OPM,IS__TUNIT____,IS________NPM,IS__TUNIT_NPM
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; PR5569
7
8; IPSCCP should prove that the blocks are dead and delete them, and
9; properly handle the dangling blockaddress constants.
10
11; NOT_CGSCC_OPM: @bar.l = internal constant [2 x i8*] [i8* inttoptr (i32 1 to i8*), i8* inttoptr (i32 1 to i8*)]
12; IS__CGSCC_OPM: @bar.l = internal constant [2 x i8*] [i8* blockaddress(@bar, %lab0), i8* blockaddress(@bar, %end)]
13
14@code = global [5 x i32] [i32 0, i32 0, i32 0, i32 0, i32 1], align 4 ; <[5 x i32]*> [#uses=0]
15@bar.l = internal constant [2 x i8*] [i8* blockaddress(@bar, %lab0), i8* blockaddress(@bar, %end)] ; <[2 x i8*]*> [#uses=1]
16
17define internal void @foo(i32 %x) nounwind readnone {
18; IS__CGSCC____: Function Attrs: nounwind readnone
19; IS__CGSCC____-LABEL: define {{[^@]+}}@foo
20; IS__CGSCC____-SAME: (i32 [[X:%.*]]) [[ATTR0:#.*]] {
21; IS__CGSCC____-NEXT:  entry:
22; IS__CGSCC____-NEXT:    [[B:%.*]] = alloca i32, align 4
23; IS__CGSCC____-NEXT:    store volatile i32 -1, i32* [[B]], align 4
24; IS__CGSCC____-NEXT:    ret void
25;
26entry:
27  %b = alloca i32, align 4                        ; <i32*> [#uses=1]
28  store volatile i32 -1, i32* %b
29  ret void
30}
31
32define internal void @bar(i32* nocapture %pc) nounwind readonly {
33; IS__CGSCC_OPM: Function Attrs: nounwind readonly
34; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@bar
35; IS__CGSCC_OPM-SAME: (i32* nocapture [[PC:%.*]]) [[ATTR1:#.*]] {
36; IS__CGSCC_OPM-NEXT:  entry:
37; IS__CGSCC_OPM-NEXT:    br label [[INDIRECTGOTO:%.*]]
38; IS__CGSCC_OPM:       lab0:
39; IS__CGSCC_OPM-NEXT:    [[INDVAR_NEXT:%.*]] = add i32 [[INDVAR:%.*]], 1
40; IS__CGSCC_OPM-NEXT:    br label [[INDIRECTGOTO]]
41; IS__CGSCC_OPM:       end:
42; IS__CGSCC_OPM-NEXT:    ret void
43; IS__CGSCC_OPM:       indirectgoto:
44; IS__CGSCC_OPM-NEXT:    [[INDVAR]] = phi i32 [ [[INDVAR_NEXT]], [[LAB0:%.*]] ], [ 0, [[ENTRY:%.*]] ]
45; IS__CGSCC_OPM-NEXT:    [[PC_ADDR_0:%.*]] = getelementptr i32, i32* [[PC]], i32 [[INDVAR]]
46; IS__CGSCC_OPM-NEXT:    [[TMP1_PN:%.*]] = load i32, i32* [[PC_ADDR_0]], align 4
47; IS__CGSCC_OPM-NEXT:    [[INDIRECT_GOTO_DEST_IN:%.*]] = getelementptr inbounds [2 x i8*], [2 x i8*]* @bar.l, i32 0, i32 [[TMP1_PN]]
48; IS__CGSCC_OPM-NEXT:    [[INDIRECT_GOTO_DEST:%.*]] = load i8*, i8** [[INDIRECT_GOTO_DEST_IN]], align 8
49; IS__CGSCC_OPM-NEXT:    indirectbr i8* [[INDIRECT_GOTO_DEST]], [label [[LAB0]], label %end]
50;
51entry:
52  br label %indirectgoto
53
54lab0:                                             ; preds = %indirectgoto
55  %indvar.next = add i32 %indvar, 1               ; <i32> [#uses=1]
56  br label %indirectgoto
57
58end:                                              ; preds = %indirectgoto
59  ret void
60
61indirectgoto:                                     ; preds = %lab0, %entry
62  %indvar = phi i32 [ %indvar.next, %lab0 ], [ 0, %entry ] ; <i32> [#uses=2]
63  %pc.addr.0 = getelementptr i32, i32* %pc, i32 %indvar ; <i32*> [#uses=1]
64  %tmp1.pn = load i32, i32* %pc.addr.0                 ; <i32> [#uses=1]
65  %indirect.goto.dest.in = getelementptr inbounds [2 x i8*], [2 x i8*]* @bar.l, i32 0, i32 %tmp1.pn ; <i8**> [#uses=1]
66  %indirect.goto.dest = load i8*, i8** %indirect.goto.dest.in ; <i8*> [#uses=1]
67  indirectbr i8* %indirect.goto.dest, [label %lab0, label %end]
68}
69
70define i32 @main() nounwind readnone {
71; IS__TUNIT____: Function Attrs: nofree nosync nounwind readnone willreturn
72; IS__TUNIT____-LABEL: define {{[^@]+}}@main
73; IS__TUNIT____-SAME: () [[ATTR0:#.*]] {
74; IS__TUNIT____-NEXT:  entry:
75; IS__TUNIT____-NEXT:    ret i32 0
76;
77; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
78; IS__CGSCC____-LABEL: define {{[^@]+}}@main
79; IS__CGSCC____-SAME: () [[ATTR1:#.*]] {
80; IS__CGSCC____-NEXT:  entry:
81; IS__CGSCC____-NEXT:    ret i32 0
82;
83entry:
84  ret i32 0
85}
86