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
This commit is contained in:
Victor Hernandez 2010-01-27 00:30:42 +00:00
parent d3b31a73e8
commit 2c9ad13b14

View File

@ -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);