Skip to content

Commit d7c12ea

Browse files
authored
[LoopRotate] Use poison instead of undef as placeholder in debug info [NFC] (#119135)
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.
1 parent 20b071c commit d7c12ea

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

llvm/lib/Transforms/Utils/LoopRotationUtils.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,14 +171,14 @@ static void RewriteUsesOfClonedInstructions(BasicBlock *OrigHeader,
171171
// Users in the OrigPreHeader need to use the value to which the
172172
// original definitions are mapped and anything else can be handled by
173173
// the SSAUpdater. To avoid adding PHINodes, check if the value is
174-
// available in UserBB, if not substitute undef.
174+
// available in UserBB, if not substitute poison.
175175
Value *NewVal;
176176
if (UserBB == OrigPreheader)
177177
NewVal = OrigPreHeaderVal;
178178
else if (SSA.HasValueForBlock(UserBB))
179179
NewVal = SSA.GetValueInMiddleOfBlock(UserBB);
180180
else
181-
NewVal = UndefValue::get(OrigHeaderVal->getType());
181+
NewVal = PoisonValue::get(OrigHeaderVal->getType());
182182
DbgValue->replaceVariableLocationOp(OrigHeaderVal, NewVal);
183183
}
184184

@@ -194,14 +194,14 @@ static void RewriteUsesOfClonedInstructions(BasicBlock *OrigHeader,
194194
// Users in the OrigPreHeader need to use the value to which the
195195
// original definitions are mapped and anything else can be handled by
196196
// the SSAUpdater. To avoid adding PHINodes, check if the value is
197-
// available in UserBB, if not substitute undef.
197+
// available in UserBB, if not substitute poison.
198198
Value *NewVal;
199199
if (UserBB == OrigPreheader)
200200
NewVal = OrigPreHeaderVal;
201201
else if (SSA.HasValueForBlock(UserBB))
202202
NewVal = SSA.GetValueInMiddleOfBlock(UserBB);
203203
else
204-
NewVal = UndefValue::get(OrigHeaderVal->getType());
204+
NewVal = PoisonValue::get(OrigHeaderVal->getType());
205205
DVR->replaceVariableLocationOp(OrigHeaderVal, NewVal);
206206
}
207207
}

llvm/test/Transforms/LoopRotate/dbgvalue.ll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ return: ; preds = %if.end
113113

114114
; Check that the dbg.values move up to being immediately below the PHIs,
115115
; using their Values. However once we exit the loop, the x and y values
116-
; become irrelevant and undef, only z gets an LCSSA PHI to preserve it.
116+
; become irrelevant and poison, only z gets an LCSSA PHI to preserve it.
117117
;
118118
; Note that while the icmp is initially undominated by any dbg.value and thus
119119
; 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 {
138138
; CHECK: tail call i32 @tak(i32
139139
; CHECK: if.end:
140140
; CHECK-NEXT: z.tr.lcssa = phi i32
141-
; CHECK-NEXT: #dbg_value(i32 undef
142-
; CHECK-NEXT: #dbg_value(i32 undef
141+
; CHECK-NEXT: #dbg_value(i32 poison
142+
; CHECK-NEXT: #dbg_value(i32 poison
143143
; CHECK-NEXT: #dbg_value(i32 %z.tr.lcssa
144144
entry:
145145
br label %tailrecurse

0 commit comments

Comments
 (0)