diff options
author | Devang Patel <dpatel@apple.com> | 2010-01-18 19:52:14 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2010-01-18 19:52:14 +0000 |
commit | f9d5c5cf9f1aa40aff80b5096a0a54e246fa89b5 (patch) | |
tree | 3853c83d4d55d2632904cae916c46741b5bdf672 /lib/Transforms/Utils | |
parent | b905b09f2167c5c45e23e55e609b8acff07d317d (diff) | |
download | external_llvm-f9d5c5cf9f1aa40aff80b5096a0a54e246fa89b5.zip external_llvm-f9d5c5cf9f1aa40aff80b5096a0a54e246fa89b5.tar.gz external_llvm-f9d5c5cf9f1aa40aff80b5096a0a54e246fa89b5.tar.bz2 |
While mapping llvm.dbg.declare intrinsic manually map its operand, if possible,
because it points to an alloca instruction through metadata.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93757 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils')
-rw-r--r-- | lib/Transforms/Utils/ValueMapper.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/Transforms/Utils/ValueMapper.cpp b/lib/Transforms/Utils/ValueMapper.cpp index 39331d7..b5b0d2e 100644 --- a/lib/Transforms/Utils/ValueMapper.cpp +++ b/lib/Transforms/Utils/ValueMapper.cpp @@ -16,6 +16,7 @@ #include "llvm/DerivedTypes.h" // For getNullValue(Type::Int32Ty) #include "llvm/Constants.h" #include "llvm/Function.h" +#include "llvm/IntrinsicInst.h" #include "llvm/Metadata.h" #include "llvm/ADT/SmallVector.h" #include "llvm/Support/ErrorHandling.h" @@ -130,4 +131,21 @@ void llvm::RemapInstruction(Instruction *I, ValueMapTy &ValueMap) { assert(V && "Referenced value not in value map!"); *op = V; } + + // Map llvm.dbg.declare instruction's first operand, which points to + // alloca instruction through MDNode. Since MDNodes are not counted as normal + // uses, this will fall through cracks otherwise. + const DbgDeclareInst *DDI = dyn_cast<DbgDeclareInst>(I); + if (!DDI) return; + + Value *AddrInsn = DDI->getAddress(); + if (!AddrInsn) return; + + ValueMapTy::iterator VMI = ValueMap.find(AddrInsn); + if (VMI == ValueMap.end()) return; + + Value *Elts[] = { VMI->second }; + MDNode *NewAddr = MDNode::get(AddrInsn->getContext(), Elts, 1); + I->setOperand(1, NewAddr); } + |