aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Linker
diff options
context:
space:
mode:
authorVictor Hernandez <vhernandez@apple.com>2010-01-27 00:30:42 +0000
committerVictor Hernandez <vhernandez@apple.com>2010-01-27 00:30:42 +0000
commit2c9ad13b14de9fcc98f868d301950f0f386f2545 (patch)
tree95e27efe0e69babb293d8c352ae17dac7bd3fe3f /lib/Linker
parentd3b31a73e8b58e837510fd429f0f4cb2b8c1a0c2 (diff)
downloadexternal_llvm-2c9ad13b14de9fcc98f868d301950f0f386f2545.zip
external_llvm-2c9ad13b14de9fcc98f868d301950f0f386f2545.tar.gz
external_llvm-2c9ad13b14de9fcc98f868d301950f0f386f2545.tar.bz2
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
Diffstat (limited to 'lib/Linker')
-rw-r--r--lib/Linker/LinkModules.cpp14
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);