From: Duncan P. N. Exon Smith Date: Sat, 6 Dec 2014 00:48:13 +0000 (+0000) Subject: Utils: Avoid RAUW on metadata in CloneFunction() X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=fe10a1117a4bdaac063c29a13cdcf2dc9a9f8f60;p=oota-llvm.git Utils: Avoid RAUW on metadata in CloneFunction() git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223555 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/Utils/CloneFunction.cpp b/lib/Transforms/Utils/CloneFunction.cpp index 5c8f20d5f88..adad9709f1a 100644 --- a/lib/Transforms/Utils/CloneFunction.cpp +++ b/lib/Transforms/Utils/CloneFunction.cpp @@ -164,14 +164,13 @@ static MDNode* FindSubprogram(const Function *F, DebugInfoFinder &Finder) { // Add an operand to an existing MDNode. The new operand will be added at the // back of the operand list. -static void AddOperand(MDNode *Node, Value *Operand) { +static void AddOperand(DICompileUnit CU, MDNode *Node, Value *Operand) { SmallVector Operands; for (unsigned i = 0; i < Node->getNumOperands(); i++) { Operands.push_back(Node->getOperand(i)); } Operands.push_back(Operand); - MDNode *NewNode = MDNode::get(Node->getContext(), Operands); - Node->replaceAllUsesWith(NewNode); + CU.replaceSubprograms(DIArray(MDNode::get(CU->getContext(), Operands))); } // Clone the module-level debug info associated with OldFunc. The cloned data @@ -196,7 +195,8 @@ static void CloneDebugInfoMetadata(Function *NewFunc, const Function *OldFunc, // also contain the new one. for (unsigned i = 0; i < Subprograms.getNumElements(); i++) { if ((MDNode*)Subprograms.getElement(i) == OldSubprogramMDNode) { - AddOperand(Subprograms, NewSubprogram); + AddOperand(CU, Subprograms, NewSubprogram); + break; } } }