From 0586d1cac2856e2848e289947910ad2dafe26d85 Mon Sep 17 00:00:00 2001 From: Nuno Lopes Date: Thu, 30 Jun 2022 21:46:19 +0100 Subject: [PATCH] [NFC] Switch a few uses of undef to poison as placeholders for unreachble code --- llvm/lib/Transforms/Scalar/IndVarSimplify.cpp | 2 +- llvm/lib/Transforms/Scalar/LoopDeletion.cpp | 6 +++--- llvm/lib/Transforms/Scalar/Scalarizer.cpp | 2 +- llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp | 2 +- llvm/test/Transforms/LoopDeletion/unreachable-loops.ll | 8 ++++---- llvm/test/Transforms/LoopDeletion/update-scev.ll | 6 +++--- llvm/test/Transforms/Scalarizer/phi-unreachable-pred.ll | 8 ++++---- 7 files changed, 17 insertions(+), 17 deletions(-) diff --git a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp index a8c39f809f2e..e977dd18be9f 100644 --- a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp +++ b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp @@ -382,7 +382,7 @@ bool IndVarSimplify::handleFloatingPointIV(Loop *L, PHINode *PN) { RecursivelyDeleteTriviallyDeadInstructions(Compare, TLI, MSSAU.get()); // Delete the old floating point increment. - Incr->replaceAllUsesWith(UndefValue::get(Incr->getType())); + Incr->replaceAllUsesWith(PoisonValue::get(Incr->getType())); RecursivelyDeleteTriviallyDeadInstructions(Incr, TLI, MSSAU.get()); // If the FP induction variable still has uses, this is because something else diff --git a/llvm/lib/Transforms/Scalar/LoopDeletion.cpp b/llvm/lib/Transforms/Scalar/LoopDeletion.cpp index 66d452f07cb5..93f3cd704196 100644 --- a/llvm/lib/Transforms/Scalar/LoopDeletion.cpp +++ b/llvm/lib/Transforms/Scalar/LoopDeletion.cpp @@ -458,13 +458,13 @@ static LoopDeletionResult deleteLoopIfDead(Loop *L, DominatorTree &DT, if (ExitBlock && isLoopNeverExecuted(L)) { LLVM_DEBUG(dbgs() << "Loop is proven to never execute, delete it!"); // We need to forget the loop before setting the incoming values of the exit - // phis to undef, so we properly invalidate the SCEV expressions for those + // phis to poison, so we properly invalidate the SCEV expressions for those // phis. SE.forgetLoop(L); - // Set incoming value to undef for phi nodes in the exit block. + // Set incoming value to poison for phi nodes in the exit block. for (PHINode &P : ExitBlock->phis()) { std::fill(P.incoming_values().begin(), P.incoming_values().end(), - UndefValue::get(P.getType())); + PoisonValue::get(P.getType())); } ORE.emit([&]() { return OptimizationRemark(DEBUG_TYPE, "NeverExecutes", L->getStartLoc(), diff --git a/llvm/lib/Transforms/Scalar/Scalarizer.cpp b/llvm/lib/Transforms/Scalar/Scalarizer.cpp index 8a5c988a514e..08f4b2173da2 100644 --- a/llvm/lib/Transforms/Scalar/Scalarizer.cpp +++ b/llvm/lib/Transforms/Scalar/Scalarizer.cpp @@ -400,7 +400,7 @@ Scatterer ScalarizerVisitor::scatter(Instruction *Point, Value *V, // need to analyse them further. if (!DT->isReachableFromEntry(VOp->getParent())) return Scatterer(Point->getParent(), Point->getIterator(), - UndefValue::get(V->getType()), PtrElemTy); + PoisonValue::get(V->getType()), PtrElemTy); // Put the scattered form of an instruction directly after the // instruction, skipping over PHI nodes and debug intrinsics. BasicBlock *BB = VOp->getParent(); diff --git a/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp b/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp index e37d7c0dc189..0535608244cc 100644 --- a/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp +++ b/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp @@ -1684,7 +1684,7 @@ deleteDeadBlocksFromLoop(Loop &L, // uses in other blocks. for (auto &I : *BB) if (!I.use_empty()) - I.replaceAllUsesWith(UndefValue::get(I.getType())); + I.replaceAllUsesWith(PoisonValue::get(I.getType())); BB->dropAllReferences(); } diff --git a/llvm/test/Transforms/LoopDeletion/unreachable-loops.ll b/llvm/test/Transforms/LoopDeletion/unreachable-loops.ll index bd0d53f28a72..ff37be29b0e6 100644 --- a/llvm/test/Transforms/LoopDeletion/unreachable-loops.ll +++ b/llvm/test/Transforms/LoopDeletion/unreachable-loops.ll @@ -79,7 +79,7 @@ define i64 @test3(i64 %n, i64 %m, i64 %maybe_zero) nounwind { ; CHECK: bb.preheader: ; CHECK-NEXT: br label [[RETURN_LOOPEXIT:%.*]] ; CHECK: return.loopexit: -; CHECK-NEXT: [[X_LCSSA_PH:%.*]] = phi i64 [ undef, [[BB_PREHEADER]] ] +; CHECK-NEXT: [[X_LCSSA_PH:%.*]] = phi i64 [ poison, [[BB_PREHEADER]] ] ; CHECK-NEXT: br label [[RETURN]] ; CHECK: return: ; CHECK-NEXT: [[X_LCSSA:%.*]] = phi i64 [ 20, [[ENTRY:%.*]] ], [ [[X_LCSSA_PH]], [[RETURN_LOOPEXIT]] ] @@ -244,7 +244,7 @@ define i64 @test7(i64 %n) { ; CHECK: L2.preheader: ; CHECK-NEXT: br label [[L1LATCH_LOOPEXIT:%.*]] ; CHECK: L1Latch.loopexit: -; CHECK-NEXT: [[Y_L2_LCSSA:%.*]] = phi i64 [ undef, [[L2_PREHEADER]] ] +; CHECK-NEXT: [[Y_L2_LCSSA:%.*]] = phi i64 [ poison, [[L2_PREHEADER]] ] ; CHECK-NEXT: br label [[L1LATCH]] ; CHECK: L1Latch: ; CHECK-NEXT: [[Y:%.*]] = phi i64 [ [[Y_NEXT]], [[L1]] ], [ [[Y_L2_LCSSA]], [[L1LATCH_LOOPEXIT]] ] @@ -430,7 +430,7 @@ define i64 @test12(i64 %n){ ; CHECK: exit1: ; CHECK-NEXT: ret i64 42 ; CHECK: exit: -; CHECK-NEXT: [[Y_PHI:%.*]] = phi i64 [ undef, [[L1_PREHEADER]] ] +; CHECK-NEXT: [[Y_PHI:%.*]] = phi i64 [ poison, [[L1_PREHEADER]] ] ; CHECK-NEXT: ret i64 [[Y_PHI]] ; ; REMARKS-LABEL: Function: test12 @@ -470,7 +470,7 @@ define i64 @test13(i64 %n) { ; CHECK: exit1: ; CHECK-NEXT: ret i64 42 ; CHECK: exit: -; CHECK-NEXT: [[Y_PHI:%.*]] = phi i64 [ undef, [[L1_PREHEADER]] ] +; CHECK-NEXT: [[Y_PHI:%.*]] = phi i64 [ poison, [[L1_PREHEADER]] ] ; CHECK-NEXT: ret i64 [[Y_PHI]] ; ; REMARKS-LABEL: Function: test13 diff --git a/llvm/test/Transforms/LoopDeletion/update-scev.ll b/llvm/test/Transforms/LoopDeletion/update-scev.ll index 56cc263ba1fb..71078d8b7c05 100644 --- a/llvm/test/Transforms/LoopDeletion/update-scev.ll +++ b/llvm/test/Transforms/LoopDeletion/update-scev.ll @@ -7,7 +7,7 @@ target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-apple-macosx10.11.0" -define void @pr27570() { +define void @pr27570(i1 %c1) { ; IR-AFTER-TRANSFORM-LABEL: @pr27570( entry: br label %for.cond @@ -52,7 +52,7 @@ for.inc11: ; preds = %for.body6 br i1 %tobool, label %for.cond14, label %for.body for.cond14: ; preds = %for.cond14, %for.inc11 - br i1 undef, label %for.cond, label %for.cond14 + br i1 %c1, label %for.cond, label %for.cond14 } declare void @sideeffect(i32) @@ -65,7 +65,7 @@ define void @test2(double* %bx, i64 %by) local_unnamed_addr align 2 { ; IR-AFTER-TRANSFORM-NOT: for.body7.1: ; SCEV-EXPRS-LABEL: test2 -; SCEV-EXPRS: %inc.lcssa.1 = phi i64 [ undef, %for.body7.preheader.1 ] +; SCEV-EXPRS: %inc.lcssa.1 = phi i64 [ poison, %for.body7.preheader.1 ] ; SCEV-EXPRS-NEXT: --> undef entry: %cmp = icmp sgt i64 %by, 0 diff --git a/llvm/test/Transforms/Scalarizer/phi-unreachable-pred.ll b/llvm/test/Transforms/Scalarizer/phi-unreachable-pred.ll index b0df8001d1c5..d700858b1508 100644 --- a/llvm/test/Transforms/Scalarizer/phi-unreachable-pred.ll +++ b/llvm/test/Transforms/Scalarizer/phi-unreachable-pred.ll @@ -11,8 +11,8 @@ define i16 @f1() { ; CHECK: for.cond: ; CHECK-NEXT: br i1 undef, label [[FOR_BODY:%.*]], label [[FOR_END]] ; CHECK: for.end: -; CHECK-NEXT: [[EXTRACT:%.*]] = phi i16 [ 1, [[ENTRY:%.*]] ], [ undef, [[FOR_COND]] ] -; CHECK-NEXT: ret i16 [[EXTRACT]] +; CHECK-NEXT: [[PHI_I0:%.*]] = phi i16 [ 1, [[ENTRY:%.*]] ], [ poison, [[FOR_COND]] ] +; CHECK-NEXT: ret i16 [[PHI_I0]] ; entry: br label %for.end @@ -53,8 +53,8 @@ define void @f2() { ; CHECK: for.cond1.for.end7_crit_edge: ; CHECK-NEXT: br label [[IF_END8]] ; CHECK: if.end8: -; CHECK-NEXT: [[E_SROA_3_4_I0:%.*]] = phi i64 [ undef, [[FOR_BODY]] ], [ undef, [[FOR_COND1_FOR_END7_CRIT_EDGE]] ], [ undef, [[IF_THEN]] ] -; CHECK-NEXT: [[E_SROA_3_4_I1:%.*]] = phi i64 [ undef, [[FOR_BODY]] ], [ undef, [[FOR_COND1_FOR_END7_CRIT_EDGE]] ], [ undef, [[IF_THEN]] ] +; CHECK-NEXT: [[E_SROA_3_4_I0:%.*]] = phi i64 [ undef, [[FOR_BODY]] ], [ poison, [[FOR_COND1_FOR_END7_CRIT_EDGE]] ], [ undef, [[IF_THEN]] ] +; CHECK-NEXT: [[E_SROA_3_4_I1:%.*]] = phi i64 [ undef, [[FOR_BODY]] ], [ poison, [[FOR_COND1_FOR_END7_CRIT_EDGE]] ], [ undef, [[IF_THEN]] ] ; CHECK-NEXT: br label [[FOR_BODY]] ; entry: