summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Utils/ValueMapper.cpp
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2010-01-18 19:52:14 +0000
committerDevang Patel <dpatel@apple.com>2010-01-18 19:52:14 +0000
commit696cb8d410a95ee2b08bac2fa87525f48fac11b7 (patch)
tree713ad92b9fe40244fc74bdcaff5968374c179210 /llvm/lib/Transforms/Utils/ValueMapper.cpp
parentffcec8f0d8ab20d2c66e07a582acbda5e6c3775b (diff)
downloadbcm5719-llvm-696cb8d410a95ee2b08bac2fa87525f48fac11b7.tar.gz
bcm5719-llvm-696cb8d410a95ee2b08bac2fa87525f48fac11b7.zip
While mapping llvm.dbg.declare intrinsic manually map its operand, if possible,
because it points to an alloca instruction through metadata. llvm-svn: 93757
Diffstat (limited to 'llvm/lib/Transforms/Utils/ValueMapper.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/ValueMapper.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/ValueMapper.cpp b/llvm/lib/Transforms/Utils/ValueMapper.cpp
index 39331d78169..b5b0d2e2de7 100644
--- a/llvm/lib/Transforms/Utils/ValueMapper.cpp
+++ b/llvm/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);
}
+
OpenPOWER on IntegriCloud