]> granicus.if.org Git - llvm/commitdiff
[Debug info] Add new DbgValues after looping over DAG
authorJonas Devlieghere <jonas@devlieghere.com>
Tue, 22 Aug 2017 16:28:07 +0000 (16:28 +0000)
committerJonas Devlieghere <jonas@devlieghere.com>
Tue, 22 Aug 2017 16:28:07 +0000 (16:28 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@311466 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SelectionDAG/LegalizeTypes.cpp

index 7bef90d01a0ae42095cbd877510aa098bac7a843..9321a956fbdd6f0c1c405d198bd927e660e4a2a1 100644 (file)
@@ -834,6 +834,7 @@ static void transferDbgValues(SelectionDAG &DAG, DIBuilder &DIB, SDValue From,
   SDNode *ToNode = To.getNode();
   assert(FromNode != ToNode);
 
+  SmallVector<SDDbgValue *, 2> ClonedDVs;
   for (SDDbgValue *Dbg : DAG.GetDbgValues(FromNode)) {
     if (Dbg->getKind() != SDDbgValue::SDNODE)
       break;
@@ -846,12 +847,15 @@ static void transferDbgValues(SelectionDAG &DAG, DIBuilder &DIB, SDValue From,
         DAG.getDbgValue(Var, Fragment, ToNode, To.getResNo(), Dbg->isIndirect(),
                         Dbg->getDebugLoc(), Dbg->getOrder());
     Dbg->setIsInvalidated();
-    DAG.AddDbgValue(Clone, ToNode, false);
+    ClonedDVs.push_back(Clone);
 
     // Add the expression to the metadata graph so isn't lost in MIR dumps.
     const Module *M = DAG.getMachineFunction().getMMI().getModule();
     M->getNamedMetadata("llvm.dbg.mir")->addOperand(Fragment);
   }
+
+  for (SDDbgValue *Dbg : ClonedDVs)
+    DAG.AddDbgValue(Dbg, ToNode, false);
 }
 
 void DAGTypeLegalizer::SetExpandedInteger(SDValue Op, SDValue Lo,