Skip to content

Commit a680a8f

Browse files
committed
[Debug info] Add new DbgValues after looping over DAG
I was contacted by Jesper Antonsson from Ericsson who ran into problems with r311181 in their test suites with for an out-of-tree target. Because of the latter I don't have a reproducer, but we definitely don't want to modify the data structure on which we are iterating inside the loop. llvm-svn: 311466
1 parent 0ab50f6 commit a680a8f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -834,6 +834,7 @@ static void transferDbgValues(SelectionDAG &DAG, DIBuilder &DIB, SDValue From,
834834
SDNode *ToNode = To.getNode();
835835
assert(FromNode != ToNode);
836836

837+
SmallVector<SDDbgValue *, 2> ClonedDVs;
837838
for (SDDbgValue *Dbg : DAG.GetDbgValues(FromNode)) {
838839
if (Dbg->getKind() != SDDbgValue::SDNODE)
839840
break;
@@ -846,12 +847,15 @@ static void transferDbgValues(SelectionDAG &DAG, DIBuilder &DIB, SDValue From,
846847
DAG.getDbgValue(Var, Fragment, ToNode, To.getResNo(), Dbg->isIndirect(),
847848
Dbg->getDebugLoc(), Dbg->getOrder());
848849
Dbg->setIsInvalidated();
849-
DAG.AddDbgValue(Clone, ToNode, false);
850+
ClonedDVs.push_back(Clone);
850851

851852
// Add the expression to the metadata graph so isn't lost in MIR dumps.
852853
const Module *M = DAG.getMachineFunction().getMMI().getModule();
853854
M->getNamedMetadata("llvm.dbg.mir")->addOperand(Fragment);
854855
}
856+
857+
for (SDDbgValue *Dbg : ClonedDVs)
858+
DAG.AddDbgValue(Dbg, ToNode, false);
855859
}
856860

857861
void DAGTypeLegalizer::SetExpandedInteger(SDValue Op, SDValue Lo,

0 commit comments

Comments
 (0)