diff options
-rw-r--r-- | lib/Linker/LinkModules.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/Linker/LinkModules.cpp b/lib/Linker/LinkModules.cpp index e2cd47a..ac11450 100644 --- a/lib/Linker/LinkModules.cpp +++ b/lib/Linker/LinkModules.cpp @@ -392,7 +392,19 @@ static Value *RemapOperand(const Value *In, assert(!isa<GlobalValue>(CPV) && "Unmapped global?"); llvm_unreachable("Unknown type of derived type constant value!"); } - } else if (isa<MDNode>(In) || isa<MDString>(In)) { + } else if (const MDNode *MD = dyn_cast<MDNode>(In)) { + if (MD->isFunctionLocal()) { + SmallVector<Value*, 4> 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<Argument>(Op) ? RemapOperand(Op, ValueMap) : Op); + } + Result = MDNode::get(In->getContext(), Elts.data(), MD->getNumOperands()); + } else { + Result = const_cast<Value*>(In); + } + } else if (isa<MDString>(In)) { Result = const_cast<Value*>(In); } else if (isa<InlineAsm>(In)) { Result = const_cast<Value*>(In); |