aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/CloneFunction.cpp
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2014-12-06 00:48:13 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2014-12-06 00:48:13 +0000
commitb13f7d2e36b12af3a534c8df5d48861d94637f30 (patch)
treedcbe6d427128ec247ba48673115cbe11989f7277 /llvm/lib/Transforms/Utils/CloneFunction.cpp
parent05044c248e640118ae8b7870b94bf127bb23ef73 (diff)
downloadllvm-b13f7d2e36b12af3a534c8df5d48861d94637f30.zip
llvm-b13f7d2e36b12af3a534c8df5d48861d94637f30.tar.gz
llvm-b13f7d2e36b12af3a534c8df5d48861d94637f30.tar.bz2
Utils: Avoid RAUW on metadata in CloneFunction()
llvm-svn: 223555
Diffstat (limited to 'llvm/lib/Transforms/Utils/CloneFunction.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/CloneFunction.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/Utils/CloneFunction.cpp b/llvm/lib/Transforms/Utils/CloneFunction.cpp
index 5c8f20d..adad970 100644
--- a/llvm/lib/Transforms/Utils/CloneFunction.cpp
+++ b/llvm/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<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(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;
}
}
}