1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-attributes --check-globals
2 ; RUN: opt -aa-pipeline=basic-aa -passes=attributor -attributor-manifest-internal -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,TUNIT
3 ; RUN: opt -aa-pipeline=basic-aa -passes=attributor-cgscc -attributor-manifest-internal -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,CGSCC
6 ; IPSCCP should prove that the blocks are dead and delete them, and
7 ; properly handle the dangling blockaddress constants.
9 @code = global [5 x i32] [i32 0, i32 0, i32 0, i32 0, i32 1], align 4 ; <ptr> [#uses=0]
10 @bar.l = internal constant [2 x ptr] [ptr blockaddress(@bar, %lab0), ptr blockaddress(@bar, %end)] ; <ptr> [#uses=1]
13 ; TUNIT: @code = global [5 x i32] [i32 0, i32 0, i32 0, i32 0, i32 1], align 4
14 ; TUNIT: @bar.l = internal constant [2 x ptr] [ptr inttoptr (i32 1 to ptr), ptr inttoptr (i32 1 to ptr)]
16 ; CGSCC: @code = global [5 x i32] [i32 0, i32 0, i32 0, i32 0, i32 1], align 4
17 ; CGSCC: @bar.l = internal constant [2 x ptr] [ptr blockaddress(@bar, %lab0), ptr blockaddress(@bar, %end)]
19 define internal void @foo(i32 %x) nounwind readnone {
20 ; CGSCC: Function Attrs: nounwind memory(none)
21 ; CGSCC-LABEL: define {{[^@]+}}@foo
22 ; CGSCC-SAME: (i32 [[X:%.*]]) #[[ATTR0:[0-9]+]] {
24 ; CGSCC-NEXT: [[B:%.*]] = alloca i32, align 4
25 ; CGSCC-NEXT: store volatile i32 -1, ptr [[B]], align 4
26 ; CGSCC-NEXT: ret void
29 %b = alloca i32, align 4 ; <ptr> [#uses=1]
30 store volatile i32 -1, ptr %b
34 define internal void @bar(ptr nocapture %pc) nounwind readonly {
35 ; CGSCC: Function Attrs: nounwind memory(read)
36 ; CGSCC-LABEL: define {{[^@]+}}@bar
37 ; CGSCC-SAME: (ptr nocapture [[PC:%.*]]) #[[ATTR1:[0-9]+]] {
39 ; CGSCC-NEXT: br label [[INDIRECTGOTO:%.*]]
41 ; CGSCC-NEXT: [[INDVAR_NEXT:%.*]] = add i32 [[INDVAR:%.*]], 1
42 ; CGSCC-NEXT: br label [[INDIRECTGOTO]]
44 ; CGSCC-NEXT: ret void
45 ; CGSCC: indirectgoto:
46 ; CGSCC-NEXT: [[INDVAR]] = phi i32 [ [[INDVAR_NEXT]], [[LAB0:%.*]] ], [ 0, [[ENTRY:%.*]] ]
47 ; CGSCC-NEXT: [[PC_ADDR_0:%.*]] = getelementptr i32, ptr [[PC]], i32 [[INDVAR]]
48 ; CGSCC-NEXT: [[TMP1_PN:%.*]] = load i32, ptr [[PC_ADDR_0]], align 4
49 ; CGSCC-NEXT: [[INDIRECT_GOTO_DEST_IN:%.*]] = getelementptr inbounds [2 x ptr], ptr @bar.l, i32 0, i32 [[TMP1_PN]]
50 ; CGSCC-NEXT: [[INDIRECT_GOTO_DEST:%.*]] = load ptr, ptr [[INDIRECT_GOTO_DEST_IN]], align 8
51 ; CGSCC-NEXT: indirectbr ptr [[INDIRECT_GOTO_DEST]], [label [[LAB0]], label %end]
54 br label %indirectgoto
56 lab0: ; preds = %indirectgoto
57 %indvar.next = add i32 %indvar, 1 ; <i32> [#uses=1]
58 br label %indirectgoto
60 end: ; preds = %indirectgoto
63 indirectgoto: ; preds = %lab0, %entry
64 %indvar = phi i32 [ %indvar.next, %lab0 ], [ 0, %entry ] ; <i32> [#uses=2]
65 %pc.addr.0 = getelementptr i32, ptr %pc, i32 %indvar ; <ptr> [#uses=1]
66 %tmp1.pn = load i32, ptr %pc.addr.0 ; <i32> [#uses=1]
67 %indirect.goto.dest.in = getelementptr inbounds [2 x ptr], ptr @bar.l, i32 0, i32 %tmp1.pn ; <ptr> [#uses=1]
68 %indirect.goto.dest = load ptr, ptr %indirect.goto.dest.in ; <ptr> [#uses=1]
69 indirectbr ptr %indirect.goto.dest, [label %lab0, label %end]
72 define i32 @main() nounwind readnone {
73 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
74 ; TUNIT-LABEL: define {{[^@]+}}@main
75 ; TUNIT-SAME: () #[[ATTR0:[0-9]+]] {
77 ; TUNIT-NEXT: ret i32 0
79 ; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
80 ; CGSCC-LABEL: define {{[^@]+}}@main
81 ; CGSCC-SAME: () #[[ATTR2:[0-9]+]] {
83 ; CGSCC-NEXT: ret i32 0
89 ; TUNIT: attributes #[[ATTR0]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }
91 ; CGSCC: attributes #[[ATTR0]] = { nounwind memory(none) }
92 ; CGSCC: attributes #[[ATTR1]] = { nounwind memory(read) }
93 ; CGSCC: attributes #[[ATTR2]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }
95 ;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line: