[llvm] r223555 - Utils: Avoid RAUW on metadata in CloneFunction()
Duncan P. N. Exon Smith
dexonsmith at apple.com
Fri Dec 5 16:48:14 PST 2014
Author: dexonsmith
Date: Fri Dec 5 18:48:13 2014
New Revision: 223555
URL: http://llvm.org/viewvc/llvm-project?rev=223555&view=rev
Log:
Utils: Avoid RAUW on metadata in CloneFunction()
Modified:
llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp
Modified: llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp?rev=223555&r1=223554&r2=223555&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp Fri Dec 5 18:48:13 2014
@@ -164,14 +164,13 @@ static MDNode* FindSubprogram(const Func
// 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<Value*, 16> 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(Funct
// 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;
}
}
}
More information about the llvm-commits
mailing list