diff options
author | Manman Ren <mren@apple.com> | 2013-01-30 17:42:15 +0000 |
---|---|---|
committer | Manman Ren <mren@apple.com> | 2013-01-30 17:42:15 +0000 |
commit | 1229c0cb10e1c3640253ece03670621d96762e75 (patch) | |
tree | c1c729a50e8ef4340319ac0148226270c38bfcae /lib | |
parent | 0f156af8312a0f3ce88e5c006bf2a52691039ceb (diff) | |
download | external_llvm-1229c0cb10e1c3640253ece03670621d96762e75.zip external_llvm-1229c0cb10e1c3640253ece03670621d96762e75.tar.gz external_llvm-1229c0cb10e1c3640253ece03670621d96762e75.tar.bz2 |
Linker: correctly link in dbg.declare
Given source IR:
call void @llvm.dbg.declare(metadata !{i32* %argc.addr}, metadata !14), !dbg !15
we used to generate
call void @llvm.dbg.declare(metadata !27, metadata !28), !dbg !29
!27 = metadata !{null}
With this patch, we will correctly generate
call void @llvm.dbg.declare(metadata !{i32* %argc.addr}, metadata !27), !dbg !28
Looking up %argc.addr in ValueMap will return null, since %argc.addr is already
correctly set up, we can use identity mapping.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173946 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Transforms/Utils/ValueMapper.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/Transforms/Utils/ValueMapper.cpp b/lib/Transforms/Utils/ValueMapper.cpp index a5e1643..b9e4ddf 100644 --- a/lib/Transforms/Utils/ValueMapper.cpp +++ b/lib/Transforms/Utils/ValueMapper.cpp @@ -63,14 +63,23 @@ Value *llvm::MapValue(const Value *V, ValueToValueMapTy &VM, RemapFlags Flags, // Check all operands to see if any need to be remapped. for (unsigned i = 0, e = MD->getNumOperands(); i != e; ++i) { Value *OP = MD->getOperand(i); - if (OP == 0 || MapValue(OP, VM, Flags, TypeMapper) == OP) continue; + if (OP == 0) continue; + Value *Mapped_OP = MapValue(OP, VM, Flags, TypeMapper); + // If Mapped_Op is null, we should use indentity map. + if (Mapped_OP == OP || Mapped_OP == 0) continue; // Ok, at least one operand needs remapping. SmallVector<Value*, 4> Elts; Elts.reserve(MD->getNumOperands()); for (i = 0; i != e; ++i) { Value *Op = MD->getOperand(i); - Elts.push_back(Op ? MapValue(Op, VM, Flags, TypeMapper) : 0); + if (Op == 0) + Elts.push_back(0); + else { + Value *Mapped_Op = MapValue(Op, VM, Flags, TypeMapper); + // If Mapped_Op is null, we should use indentity map. + Elts.push_back(Mapped_Op ? Mapped_Op : Op); + } } MDNode *NewMD = MDNode::get(V->getContext(), Elts); Dummy->replaceAllUsesWith(NewMD); |