Skip to content

Commit 32307a9

Browse files
committed
[DebugInfo] Fix undef debug values being removed
1 parent 7e380ba commit 32307a9

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

lib/IRGen/IRGenSIL.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5598,11 +5598,10 @@ void IRGenSILFunction::visitDebugValueInst(DebugValueInst *i) {
55985598

55995599
auto VarInfo = i->getVarInfo();
56005600
assert(VarInfo && "debug_value without debug info");
5601-
if (isa<SILUndef>(SILVal)) {
5601+
if (isa<SILUndef>(SILVal) && VarInfo->Name == "$error") {
56025602
// We cannot track the location of inlined error arguments because it has no
56035603
// representation in SIL.
5604-
if (!IsAddrVal &&
5605-
!i->getDebugScope()->InlinedCallSite && VarInfo->Name == "$error") {
5604+
if (!IsAddrVal && !i->getDebugScope()->InlinedCallSite) {
56065605
auto funcTy = CurSILFn->getLoweredFunctionType();
56075606
emitErrorResultVar(funcTy, funcTy->getErrorResult(), i);
56085607
}

lib/SILOptimizer/Transforms/DeadCodeElimination.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,10 @@ static bool seemsUseful(SILInstruction *I) {
7777
}
7878

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

8385
return false;
8486
}

0 commit comments

Comments
 (0)