diff --git a/llvm/lib/CodeGen/MachineDebugify.cpp b/llvm/lib/CodeGen/MachineDebugify.cpp --- a/llvm/lib/CodeGen/MachineDebugify.cpp +++ b/llvm/lib/CodeGen/MachineDebugify.cpp @@ -153,10 +153,15 @@ NMD->setOperand(Idx, MDNode::get(Ctx, ValueAsMetadata::getConstant( ConstantInt::get(Int32Ty, N)))); }; + auto getDebugifyOperand = [&](unsigned Idx) { + return mdconst::extract(NMD->getOperand(Idx)->getOperand(0)) + ->getZExtValue(); + }; // Set number of lines. setDebugifyOperand(0, NextLine - 1); // Set number of variables. - setDebugifyOperand(1, VarSet.size()); + auto OldNumVars = getDebugifyOperand(1); + setDebugifyOperand(1, OldNumVars + VarSet.size()); } return true;