Skip to content

Commit f2d4262

Browse files
committed
[DebugInfo] Fix AllocStackHoisting losing debug info
AllocStackHoisting was losing debug info, including at -Onone. When two alloc_stacks of the same type are merged, one of them would lose their debug variable. It is now salvaged, with an added debug_value. This case was previously only handled for noncopyable types, it is now done in all cases.
1 parent 43cc6ea commit f2d4262

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

lib/IRGen/AllocStackHoisting.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,8 @@ void moveAllocStackToBeginningOfBlock(
157157
// of the debug_value to the original position.
158158
if (haveMovedElt) {
159159
if (auto varInfo = AS->getVarInfo()) {
160-
SILBuilderWithScope Builder(AS);
161160
// SILBuilderWithScope skips over meta instructions when picking a scope.
162-
Builder.setCurrentDebugScope(AS->getDebugScope());
161+
SILBuilder Builder(AS, AS->getDebugScope());
163162
auto *DVI = Builder.createDebugValue(AS->getLoc(), AS, *varInfo);
164163
DVI->setUsesMoveableValueDebugInfo();
165164
DebugValueToBreakBlocksAt.push_back(DVI);
@@ -198,14 +197,14 @@ void Partition::assignStackLocation(
198197
if (AssignedLoc == AllocStack) continue;
199198
eraseDeallocStacks(AllocStack);
200199
AllocStack->replaceAllUsesWith(AssignedLoc);
201-
if (hasAtLeastOneMovedElt) {
202-
if (auto VarInfo = AllocStack->getVarInfo()) {
203-
SILBuilderWithScope Builder(AllocStack);
204-
auto *DVI = Builder.createDebugValue(AllocStack->getLoc(), AssignedLoc,
205-
*VarInfo);
200+
if (auto VarInfo = AllocStack->getVarInfo()) {
201+
SILBuilder Builder(AllocStack, AllocStack->getDebugScope());
202+
auto *DVI = Builder.createDebugValueAddr(AllocStack->getLoc(),
203+
AssignedLoc, *VarInfo);
204+
if (hasAtLeastOneMovedElt) {
206205
DVI->setUsesMoveableValueDebugInfo();
207-
DebugValueToBreakBlocksAt.push_back(DVI);
208206
}
207+
DebugValueToBreakBlocksAt.push_back(DVI);
209208
}
210209
AllocStack->eraseFromParent();
211210
}

0 commit comments

Comments
 (0)