Skip to content

Commit 0f962dd

Browse files
committed
[DebugInfo] Fix PhiExpansion losing debug info
When replacing a struct with its field, it now emits a debug_value with a fragment, instead of dropping the debug_value.
1 parent c02f663 commit 0f962dd

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lib/SILOptimizer/Transforms/PhiArgumentOptimizations.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,13 @@ bool PhiExpansionPass::optimizeArg(SILPhiArgument *initialArg) {
439439
}
440440

441441
for (DebugValueInst *dvi : debugValueUsers) {
442+
// Recreate the debug_value with a fragment.
443+
SILBuilder B(dvi, dvi->getDebugScope());
444+
SILDebugVariable var = *dvi->getVarInfo();
445+
if (!var.Type)
446+
var.Type = initialArg->getType();
447+
var.DIExpr.append(SILDebugInfoExpression::createFragment(field));
448+
B.createDebugValue(dvi->getLoc(), dvi->getOperand(), var);
442449
dvi->eraseFromParent();
443450
}
444451
for (StructExtractInst *sei : structExtractUsers) {

0 commit comments

Comments
 (0)