Skip to content

Commit a593e9c

Browse files
committed
Fix an iterator invalidation bug in the Swift-specific additions to
LiveDebugValues. The MachineOperand iterator is no longer happy with us modifying MachineOperands as we're iterating through them. rdar://105525639
1 parent 23919ba commit a593e9c

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1384,6 +1384,7 @@ bool InstrRefBasedLDV::transferDebugValue(const MachineInstr &MI) {
13841384

13851385
// MLocTracker needs to know that this register is read, even if it's only
13861386
// read by a debug inst.
1387+
bool convertToSwiftAsyncEntryValue = false;
13871388
for (const MachineOperand &MO : MI.debug_operands())
13881389
if (MO.isReg() && MO.getReg() != 0) {
13891390
ValueIDNum RegId = MTracker->readReg(MO.getReg());
@@ -1401,16 +1402,19 @@ bool InstrRefBasedLDV::transferDebugValue(const MachineInstr &MI) {
14011402
if (!Expr || !Expr->isEntryValue()) {
14021403
if (TTracker)
14031404
TTracker->recoverAsEntryValue(V, Properties, RegId);
1404-
else {
1405-
const_cast<MachineInstr *>(&MI)
1406-
->getOperand(MI.isDebugValueList() ? 1 : 3)
1407-
.setMetadata(
1408-
DIExpression::prepend(Expr, DIExpression::EntryValue));
1409-
}
1405+
else
1406+
convertToSwiftAsyncEntryValue = true;
14101407
}
14111408
}
14121409
}
1413-
// END SWIFT
1410+
1411+
if (convertToSwiftAsyncEntryValue && Expr) {
1412+
const_cast<MachineInstr *>(&MI)
1413+
->getOperand(MI.isDebugValueList() ? 1 : 3)
1414+
.setMetadata(DIExpression::prepend(Expr, DIExpression::EntryValue));
1415+
Properties.DIExpr = MI.getDebugExpression();
1416+
}
1417+
// END SWIFT
14141418

14151419
// If we're preparing for the second analysis (variables), the machine value
14161420
// locations are already solved, and we report this DBG_VALUE and the value

0 commit comments

Comments
 (0)