@@ -400,8 +400,8 @@ bool MoveKillsCopyableValuesChecker::check() {
400
400
// Then look at all of our found consuming uses. See if any of these are
401
401
// _move that are within the boundary.
402
402
bool foundMove = false ;
403
- auto dbgVarInfo = DebugVarCarryingInst::getFromValue (lexicalValue);
404
- StringRef varName = DebugVarCarryingInst::getName (dbgVarInfo );
403
+ auto dbgVarInst = DebugVarCarryingInst::getFromValue (lexicalValue);
404
+ StringRef varName = DebugVarCarryingInst::getName (dbgVarInst );
405
405
for (auto *use : livenessInfo.consumingUse ) {
406
406
if (auto *mvi = dyn_cast<MoveValueInst>(use->getUser ())) {
407
407
// Only emit diagnostics if our move value allows us to.
@@ -420,14 +420,16 @@ bool MoveKillsCopyableValuesChecker::check() {
420
420
emittedDiagnostic = true ;
421
421
} else {
422
422
LLVM_DEBUG (llvm::dbgs () << " WithinBoundary: No!\n " );
423
- if (auto varInfo = dbgVarInfo .getVarInfo ()) {
424
- successMovesDbgInfoCarryingInsts.push_back (*dbgVarInfo );
423
+ if (auto varInfo = dbgVarInst .getVarInfo ()) {
424
+ successMovesDbgInfoCarryingInsts.push_back (*dbgVarInst );
425
425
auto *next = mvi->getNextInstruction ();
426
426
SILBuilderWithScope builder (next);
427
- // Use an autogenerated location to ensure that if we are next to a
428
- // terminator, we don't assert.
427
+ // We need to make sure any undefs we put in are the same loc/debug
428
+ // scope as our original so that the backend treats them as
429
+ // referring to the same "debug entity".
430
+ builder.setCurrentDebugScope (dbgVarInst->getDebugScope ());
429
431
builder.createDebugValue (
430
- dbgVarInfo. inst ->getLoc (),
432
+ dbgVarInst ->getLoc (),
431
433
SILUndef::get (mvi->getOperand ()->getType (), mod), *varInfo,
432
434
false /* poison*/ , true /* moved*/ );
433
435
}
@@ -439,7 +441,7 @@ bool MoveKillsCopyableValuesChecker::check() {
439
441
// If we found a move, mark our debug var inst as having a moved value. This
440
442
// ensures we emit llvm.dbg.addr instead of llvm.dbg.declare in IRGen.
441
443
if (foundMove) {
442
- dbgVarInfo .markAsMoved ();
444
+ dbgVarInst .markAsMoved ();
443
445
}
444
446
}
445
447
0 commit comments