From 8a21901a45be6d44a2dfa9f94a4f9fd2d54b6cf0 Mon Sep 17 00:00:00 2001 From: Pedro Lobo Date: Sun, 8 Dec 2024 17:09:43 +0000 Subject: [PATCH] [LoopRotate] Use `poison` instead of `undef` as placeholder The `poison` values are used to substitute debug information of values moved from the original header into the preheader that are no longer available in the former. --- llvm/lib/Transforms/Utils/LoopRotationUtils.cpp | 8 ++++---- llvm/test/Transforms/LoopRotate/dbgvalue.ll | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp b/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp index 04042e71a2b82..fffff295ba926 100644 --- a/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp +++ b/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp @@ -171,14 +171,14 @@ static void RewriteUsesOfClonedInstructions(BasicBlock *OrigHeader, // Users in the OrigPreHeader need to use the value to which the // original definitions are mapped and anything else can be handled by // the SSAUpdater. To avoid adding PHINodes, check if the value is - // available in UserBB, if not substitute undef. + // available in UserBB, if not substitute poison. Value *NewVal; if (UserBB == OrigPreheader) NewVal = OrigPreHeaderVal; else if (SSA.HasValueForBlock(UserBB)) NewVal = SSA.GetValueInMiddleOfBlock(UserBB); else - NewVal = UndefValue::get(OrigHeaderVal->getType()); + NewVal = PoisonValue::get(OrigHeaderVal->getType()); DbgValue->replaceVariableLocationOp(OrigHeaderVal, NewVal); } @@ -194,14 +194,14 @@ static void RewriteUsesOfClonedInstructions(BasicBlock *OrigHeader, // Users in the OrigPreHeader need to use the value to which the // original definitions are mapped and anything else can be handled by // the SSAUpdater. To avoid adding PHINodes, check if the value is - // available in UserBB, if not substitute undef. + // available in UserBB, if not substitute poison. Value *NewVal; if (UserBB == OrigPreheader) NewVal = OrigPreHeaderVal; else if (SSA.HasValueForBlock(UserBB)) NewVal = SSA.GetValueInMiddleOfBlock(UserBB); else - NewVal = UndefValue::get(OrigHeaderVal->getType()); + NewVal = PoisonValue::get(OrigHeaderVal->getType()); DVR->replaceVariableLocationOp(OrigHeaderVal, NewVal); } } diff --git a/llvm/test/Transforms/LoopRotate/dbgvalue.ll b/llvm/test/Transforms/LoopRotate/dbgvalue.ll index b58d821fbca5d..026306a4637f0 100644 --- a/llvm/test/Transforms/LoopRotate/dbgvalue.ll +++ b/llvm/test/Transforms/LoopRotate/dbgvalue.ll @@ -113,7 +113,7 @@ return: ; preds = %if.end ; Check that the dbg.values move up to being immediately below the PHIs, ; using their Values. However once we exit the loop, the x and y values -; become irrelevant and undef, only z gets an LCSSA PHI to preserve it. +; become irrelevant and poison, only z gets an LCSSA PHI to preserve it. ; ; Note that while the icmp is initially undominated by any dbg.value and thus ; shouldn't get a variable location, the first iteration is peeled off into the @@ -138,8 +138,8 @@ define i32 @tak2(i32 %x, i32 %y, i32 %z) nounwind ssp !dbg !21 { ; CHECK: tail call i32 @tak(i32 ; CHECK: if.end: ; CHECK-NEXT: z.tr.lcssa = phi i32 -; CHECK-NEXT: #dbg_value(i32 undef -; CHECK-NEXT: #dbg_value(i32 undef +; CHECK-NEXT: #dbg_value(i32 poison +; CHECK-NEXT: #dbg_value(i32 poison ; CHECK-NEXT: #dbg_value(i32 %z.tr.lcssa entry: br label %tailrecurse