Skip to content

Commit

Permalink
[DebugInfo] Fix undef debug values being removed
Browse files Browse the repository at this point in the history
  • Loading branch information
Snowy1803 committed Apr 26, 2024
1 parent 7e380ba commit 32307a9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 2 additions & 3 deletions lib/IRGen/IRGenSIL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5598,11 +5598,10 @@ void IRGenSILFunction::visitDebugValueInst(DebugValueInst *i) {

auto VarInfo = i->getVarInfo();
assert(VarInfo && "debug_value without debug info");
if (isa<SILUndef>(SILVal)) {
if (isa<SILUndef>(SILVal) && VarInfo->Name == "$error") {
// We cannot track the location of inlined error arguments because it has no
// representation in SIL.
if (!IsAddrVal &&
!i->getDebugScope()->InlinedCallSite && VarInfo->Name == "$error") {
if (!IsAddrVal && !i->getDebugScope()->InlinedCallSite) {
auto funcTy = CurSILFn->getLoweredFunctionType();
emitErrorResultVar(funcTy, funcTy->getErrorResult(), i);
}
Expand Down
4 changes: 3 additions & 1 deletion lib/SILOptimizer/Transforms/DeadCodeElimination.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,10 @@ static bool seemsUseful(SILInstruction *I) {
}

// Is useful if it's associating with a function argument
// If undef, it is useful and it doesn't cost anything.
if (isa<DebugValueInst>(I))
return isa<SILFunctionArgument>(I->getOperand(0));
return isa<SILFunctionArgument>(I->getOperand(0))
|| isa<SILUndef>(I->getOperand(0));

return false;
}
Expand Down

0 comments on commit 32307a9

Please sign in to comment.