From 2c9ad13b14de9fcc98f868d301950f0f386f2545 Mon Sep 17 00:00:00 2001 From: Victor Hernandez Date: Wed, 27 Jan 2010 00:30:42 +0000 Subject: [PATCH] Linker needs to do deep-copy of function-local metadata to update references to function arguments git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94632 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Linker/LinkModules.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/Linker/LinkModules.cpp b/lib/Linker/LinkModules.cpp index e2cd47a21b3..ac11450dc34 100644 --- a/lib/Linker/LinkModules.cpp +++ b/lib/Linker/LinkModules.cpp @@ -392,7 +392,19 @@ static Value *RemapOperand(const Value *In, assert(!isa(CPV) && "Unmapped global?"); llvm_unreachable("Unknown type of derived type constant value!"); } - } else if (isa(In) || isa(In)) { + } else if (const MDNode *MD = dyn_cast(In)) { + if (MD->isFunctionLocal()) { + SmallVector Elts; + for (unsigned i = 0, e = MD->getNumOperands(); i != e; ++i) { + Value *Op = MD->getOperand(i); + // LinkFunctionBody() already handled non-argument values. + Elts.push_back(isa(Op) ? RemapOperand(Op, ValueMap) : Op); + } + Result = MDNode::get(In->getContext(), Elts.data(), MD->getNumOperands()); + } else { + Result = const_cast(In); + } + } else if (isa(In)) { Result = const_cast(In); } else if (isa(In)) { Result = const_cast(In);