diff options
author | Victor Hernandez <vhernandez@apple.com> | 2010-01-27 00:30:42 +0000 |
---|---|---|
committer | Victor Hernandez <vhernandez@apple.com> | 2010-01-27 00:30:42 +0000 |
commit | 38e810d870750c82bb0ac4ea21ac7120b7957b6a (patch) | |
tree | 7d52fa8dd84dbf16177e85d3ed1dfbb0b3f4f804 /llvm/lib | |
parent | 2ab11001cc817ca1edfedbb0e931450db2d2b9d1 (diff) | |
download | bcm5719-llvm-38e810d870750c82bb0ac4ea21ac7120b7957b6a.tar.gz bcm5719-llvm-38e810d870750c82bb0ac4ea21ac7120b7957b6a.zip |
Linker needs to do deep-copy of function-local metadata to update references to function arguments
llvm-svn: 94632
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Linker/LinkModules.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/llvm/lib/Linker/LinkModules.cpp b/llvm/lib/Linker/LinkModules.cpp index e2cd47a21b3..ac11450dc34 100644 --- a/llvm/lib/Linker/LinkModules.cpp +++ b/llvm/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); |