forked from OSchip/llvm-project
[Examples] Fix SimplifyCFG example
After fffabd5348
, the v2 and v3
versions produce poison instead of undef. Also adjust the v1
version, as well as the test expectations, to make the example
pass again.
This commit is contained in:
parent
f96ea53e89
commit
62ec8e94b8
|
@ -81,11 +81,11 @@ static bool removeDeadBlocks_v1(Function &F) {
|
|||
// for (PHINode &PN : make_early_inc_range(Succ->phis()))
|
||||
// PN.removeIncomingValue(&BB);
|
||||
|
||||
// Replace all instructions in BB with an undef constant. The block is
|
||||
// Replace all instructions in BB with a poison constant. The block is
|
||||
// unreachable, so the results of the instructions should never get used.
|
||||
while (!BB.empty()) {
|
||||
Instruction &I = BB.back();
|
||||
I.replaceAllUsesWith(UndefValue::get(I.getType()));
|
||||
I.replaceAllUsesWith(PoisonValue::get(I.getType()));
|
||||
I.eraseFromParent();
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@ define i32 @remove_dead_blocks() {
|
|||
; CHECK-LABEL: @remove_dead_blocks(
|
||||
; CHECK-NEXT: entry:
|
||||
; CHECK-NEXT: ret i32 1
|
||||
; CHECK-NEXT: }
|
||||
;
|
||||
entry:
|
||||
ret i32 1
|
||||
|
@ -25,7 +24,6 @@ define i32 @simp1() {
|
|||
; CHECK-NEXT: ret i32 1
|
||||
; CHECK: bb.1:
|
||||
; CHECK-NEXT: ret i32 2
|
||||
; CHECK-NEXT: }
|
||||
;
|
||||
entry:
|
||||
ret i32 1
|
||||
|
@ -46,7 +44,6 @@ define i32 @remove_dead_block_with_phi() {
|
|||
; CHECK-NEXT: br label [[BB_2:%.*]]
|
||||
; CHECK: bb.2:
|
||||
; CHECK-NEXT: ret i32 1
|
||||
; CHECK-NEXT: }
|
||||
;
|
||||
entry:
|
||||
br label %bb.2
|
||||
|
@ -63,7 +60,6 @@ define i32 @remove_dead_blocks_remaining_uses(i32 %a) {
|
|||
; CHECK-LABEL: @remove_dead_blocks_remaining_uses(
|
||||
; CHECK-NEXT: entry:
|
||||
; CHECK-NEXT: ret i32 1
|
||||
; CHECK-NEXT: }
|
||||
;
|
||||
entry:
|
||||
ret i32 1
|
||||
|
@ -81,12 +77,11 @@ define i32 @remove_dead_blocks_remaining_uses2(i32 %a, i1 %cond) {
|
|||
; CHECK-NEXT: entry:
|
||||
; CHECK-NEXT: ret i32 1
|
||||
; CHECK: bb.2:
|
||||
; CHECK-NEXT: [[RES2:%.*]] = add i32 undef, 10
|
||||
; CHECK-NEXT: [[RES3:%.*]] = mul i32 [[RES2]], undef
|
||||
; CHECK-NEXT: [[RES2:%.*]] = add i32 poison, 10
|
||||
; CHECK-NEXT: [[RES3:%.*]] = mul i32 [[RES2]], poison
|
||||
; CHECK-NEXT: ret i32 [[RES3]]
|
||||
; CHECK: bb.3:
|
||||
; CHECK-NEXT: ret i32 undef
|
||||
; CHECK-NEXT: }
|
||||
; CHECK-NEXT: ret i32 poison
|
||||
;
|
||||
entry:
|
||||
ret i32 1
|
||||
|
|
Loading…
Reference in New Issue