@@ -400,8 +400,8 @@ bool MoveKillsCopyableValuesChecker::check() {
400400 // Then look at all of our found consuming uses. See if any of these are
401401 // _move that are within the boundary.
402402 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 );
405405 for (auto *use : livenessInfo.consumingUse ) {
406406 if (auto *mvi = dyn_cast<MoveValueInst>(use->getUser ())) {
407407 // Only emit diagnostics if our move value allows us to.
@@ -420,14 +420,16 @@ bool MoveKillsCopyableValuesChecker::check() {
420420 emittedDiagnostic = true ;
421421 } else {
422422 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 );
425425 auto *next = mvi->getNextInstruction ();
426426 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 ());
429431 builder.createDebugValue (
430- dbgVarInfo. inst ->getLoc (),
432+ dbgVarInst ->getLoc (),
431433 SILUndef::get (mvi->getOperand ()->getType (), mod), *varInfo,
432434 false /* poison*/ , true /* moved*/ );
433435 }
@@ -439,7 +441,7 @@ bool MoveKillsCopyableValuesChecker::check() {
439441 // If we found a move, mark our debug var inst as having a moved value. This
440442 // ensures we emit llvm.dbg.addr instead of llvm.dbg.declare in IRGen.
441443 if (foundMove) {
442- dbgVarInfo .markAsMoved ();
444+ dbgVarInst .markAsMoved ();
443445 }
444446 }
445447
0 commit comments