From 62ec8e94b832725cfd257f79cff3685a3cd3bf8c Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Mon, 1 Aug 2022 07:22:35 +0200 Subject: [PATCH] [Examples] Fix SimplifyCFG example After fffabd53482f34f96ab9273486538f587e3d91fc, 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. --- llvm/examples/IRTransforms/SimplifyCFG.cpp | 4 ++-- .../SimplifyCFG/tut-simplify-cfg2-dead-block-order.ll | 11 +++-------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/llvm/examples/IRTransforms/SimplifyCFG.cpp b/llvm/examples/IRTransforms/SimplifyCFG.cpp index 111d453..72c86fa 100644 --- a/llvm/examples/IRTransforms/SimplifyCFG.cpp +++ b/llvm/examples/IRTransforms/SimplifyCFG.cpp @@ -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(); } diff --git a/llvm/test/Examples/IRTransforms/SimplifyCFG/tut-simplify-cfg2-dead-block-order.ll b/llvm/test/Examples/IRTransforms/SimplifyCFG/tut-simplify-cfg2-dead-block-order.ll index e7769fe..550322c 100644 --- a/llvm/test/Examples/IRTransforms/SimplifyCFG/tut-simplify-cfg2-dead-block-order.ll +++ b/llvm/test/Examples/IRTransforms/SimplifyCFG/tut-simplify-cfg2-dead-block-order.ll @@ -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 -- 2.7.4