|
68 | 68 | ret void
|
69 | 69 | }
|
70 | 70 |
|
| 71 | +declare i32 @getv() |
| 72 | + |
| 73 | +; indirect.goto.dest2 should get hoisted, and that should not result |
| 74 | +; in a loss of profiling info |
| 75 | +define i32 @test19(i1 %cond, i1 %cond2, ptr %address, i32 %v1) nounwind { |
| 76 | +; CHECK-LABEL: define i32 @test19 |
| 77 | +; CHECK-SAME: (i1 [[COND:%.*]], i1 [[COND2:%.*]], ptr [[ADDRESS:%.*]], i32 [[V1:%.*]]) #[[ATTR0:[0-9]+]] { |
| 78 | +; CHECK-NEXT: entry: |
| 79 | +; CHECK-NEXT: [[INDIRECT_GOTO_DEST:%.*]] = select i1 [[COND]], ptr blockaddress(@test19, [[EXIT:%.*]]), ptr [[ADDRESS]], !prof [[PROF9:![0-9]+]] |
| 80 | +; CHECK-NEXT: [[INDIRECT_GOTO_DEST2:%.*]] = select i1 [[COND2]], ptr blockaddress(@test19, [[EXIT]]), ptr [[ADDRESS]], !prof [[PROF10:![0-9]+]] |
| 81 | +; CHECK-NEXT: br label [[L0:%.*]] |
| 82 | +; CHECK: L0: |
| 83 | +; CHECK-NEXT: [[V2:%.*]] = call i32 @getv() |
| 84 | +; CHECK-NEXT: [[SINKABLE:%.*]] = mul i32 [[V1]], [[V2]] |
| 85 | +; CHECK-NEXT: [[SINKABLE2:%.*]] = add i32 [[V1]], [[V2]] |
| 86 | +; CHECK-NEXT: indirectbr ptr [[INDIRECT_GOTO_DEST]], [label [[L1:%.*]], label %exit] |
| 87 | +; CHECK: L1: |
| 88 | +; CHECK-NEXT: indirectbr ptr [[INDIRECT_GOTO_DEST2]], [label [[L0]], label %exit] |
| 89 | +; CHECK: exit: |
| 90 | +; CHECK-NEXT: [[R:%.*]] = phi i32 [ [[SINKABLE]], [[L0]] ], [ [[SINKABLE2]], [[L1]] ] |
| 91 | +; CHECK-NEXT: ret i32 [[R]] |
| 92 | +; |
| 93 | +entry: |
| 94 | + br label %L0 |
| 95 | +L0: |
| 96 | + %indirect.goto.dest = select i1 %cond, ptr blockaddress(@test19, %exit), ptr %address, !prof !10 |
| 97 | + %v2 = call i32 @getv() |
| 98 | + %sinkable = mul i32 %v1, %v2 |
| 99 | + %sinkable2 = add i32 %v1, %v2 |
| 100 | + indirectbr ptr %indirect.goto.dest, [label %L1, label %exit] |
| 101 | + |
| 102 | +L1: |
| 103 | + %indirect.goto.dest2 = select i1 %cond2, ptr blockaddress(@test19, %exit), ptr %address, !prof !11 |
| 104 | + indirectbr ptr %indirect.goto.dest2, [label %L0, label %exit] |
| 105 | + |
| 106 | +exit: |
| 107 | + %r = phi i32 [%sinkable, %L0], [%sinkable2, %L1] |
| 108 | + ret i32 %r |
| 109 | +} |
| 110 | + |
71 | 111 | !llvm.module.flags = !{!2, !3}
|
72 | 112 |
|
73 | 113 | !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1)
|
|
80 | 120 | !7 = !DILocation(line: 3, column: 22, scope: !4)
|
81 | 121 | !8 = !{!"branch_weights", i32 5, i32 7}
|
82 | 122 | !9 = !{!"branch_weights", i32 13, i32 11}
|
| 123 | +!10 = !{!"branch_weights", i32 101, i32 189} |
| 124 | +!11 = !{!"branch_weights", i32 67, i32 1} |
| 125 | +;. |
| 126 | +; CHECK: attributes #[[ATTR0]] = { nounwind } |
83 | 127 | ;.
|
84 | 128 | ; FOR-DEBUG: [[META0:![0-9]+]] = !{i32 7, !"Dwarf Version", i32 5}
|
85 | 129 | ; FOR-DEBUG: [[META1:![0-9]+]] = !{i32 2, !"Debug Info Version", i32 3}
|
|
0 commit comments