MoveOnlyAddressChecker: Reintroduce debug info for variables after reassignment.

After a value is consumed, we emit a `debug_value undef` to indicate that the
variable value is no longer valid to the debugger. However, once a value is
reassigned, it becomes valid again, so emit a `debug_value %original_address` to
reassociate the variable with the valid memory location. rdar://109218404
This commit is contained in:
Joe Groff
2023-05-17 20:39:54 -07:00
parent 73df9f2dd9
commit 51f75c99a4
4 changed files with 103 additions and 40 deletions

View File

@@ -64,3 +64,26 @@ bool swift::hasNonTrivialNonDebugTransitiveUsers(
}
return false;
}
DebugVarCarryingInst DebugVarCarryingInst::getFromValue(SILValue value) {
if (auto *svi = dyn_cast<SingleValueInstruction>(value)) {
if (auto result = VarDeclCarryingInst(svi)) {
switch (result.getKind()) {
case VarDeclCarryingInst::Kind::Invalid:
llvm_unreachable("ShouldKind have never seen this");
case VarDeclCarryingInst::Kind::DebugValue:
case VarDeclCarryingInst::Kind::AllocStack:
case VarDeclCarryingInst::Kind::AllocBox:
return DebugVarCarryingInst(svi);
case VarDeclCarryingInst::Kind::GlobalAddr:
case VarDeclCarryingInst::Kind::RefElementAddr:
return DebugVarCarryingInst();
}
}
}
if (auto *use = getSingleDebugUse(value))
return DebugVarCarryingInst(use->getUser());
return DebugVarCarryingInst();
}