[llvm-commits] [llvm] r94632 - /llvm/trunk/lib/Linker/LinkModules.cpp
Victor Hernandez
vhernandez at apple.com
Tue Jan 26 16:30:42 PST 2010
Author: hernande
Date: Tue Jan 26 18:30:42 2010
New Revision: 94632
URL: http://llvm.org/viewvc/llvm-project?rev=94632&view=rev
Log:
Linker needs to do deep-copy of function-local metadata to update references to function arguments
Modified:
llvm/trunk/lib/Linker/LinkModules.cpp
Modified: llvm/trunk/lib/Linker/LinkModules.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Linker/LinkModules.cpp?rev=94632&r1=94631&r2=94632&view=diff
==============================================================================
--- llvm/trunk/lib/Linker/LinkModules.cpp (original)
+++ llvm/trunk/lib/Linker/LinkModules.cpp Tue Jan 26 18:30:42 2010
@@ -392,7 +392,19 @@
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);
More information about the llvm-commits
mailing list