[llvm] 62ec8e9 - [Examples] Fix SimplifyCFG example

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Sun Jul 31 22:23:50 PDT 2022


Author: Nikita Popov
Date: 2022-08-01T07:22:35+02:00
New Revision: 62ec8e94b832725cfd257f79cff3685a3cd3bf8c

URL: https://github.com/llvm/llvm-project/commit/62ec8e94b832725cfd257f79cff3685a3cd3bf8c
DIFF: https://github.com/llvm/llvm-project/commit/62ec8e94b832725cfd257f79cff3685a3cd3bf8c.diff

LOG: [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.

Added: 
    

Modified: 
    llvm/examples/IRTransforms/SimplifyCFG.cpp
    llvm/test/Examples/IRTransforms/SimplifyCFG/tut-simplify-cfg2-dead-block-order.ll

Removed: 
    


################################################################################
diff  --git a/llvm/examples/IRTransforms/SimplifyCFG.cpp b/llvm/examples/IRTransforms/SimplifyCFG.cpp
index 111d4538fae0f..72c86fae6c508 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 e7769fe47a0d0..550322ce7ed71 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


        


More information about the llvm-commits mailing list