summaryrefslogtreecommitdiff
path: root/lib/IR
diff options
context:
space:
mode:
Diffstat (limited to 'lib/IR')
-rw-r--r--lib/IR/DebugInfo.cpp23
-rw-r--r--lib/IR/Verifier.cpp6
2 files changed, 21 insertions, 8 deletions
diff --git a/lib/IR/DebugInfo.cpp b/lib/IR/DebugInfo.cpp
index bb6d5d2891..c9e19456a8 100644
--- a/lib/IR/DebugInfo.cpp
+++ b/lib/IR/DebugInfo.cpp
@@ -951,12 +951,21 @@ void DebugInfoFinder::reset() {
Scopes.clear();
NodesSeen.clear();
TypeIdentifierMap.clear();
+ TypeMapInitialized = false;
+}
+
+void DebugInfoFinder::IntializeTypeMap(const Module &M) {
+ if (!TypeMapInitialized)
+ if (NamedMDNode *CU_Nodes = M.getNamedMetadata("llvm.dbg.cu")) {
+ TypeIdentifierMap = generateDITypeIdentifierMap(CU_Nodes);
+ TypeMapInitialized = true;
+ }
}
/// processModule - Process entire module and collect debug info.
void DebugInfoFinder::processModule(const Module &M) {
+ IntializeTypeMap(M);
if (NamedMDNode *CU_Nodes = M.getNamedMetadata("llvm.dbg.cu")) {
- TypeIdentifierMap = generateDITypeIdentifierMap(CU_Nodes);
for (unsigned i = 0, e = CU_Nodes->getNumOperands(); i != e; ++i) {
DICompileUnit CU(CU_Nodes->getOperand(i));
addCompileUnit(CU);
@@ -993,11 +1002,12 @@ void DebugInfoFinder::processModule(const Module &M) {
}
/// processLocation - Process DILocation.
-void DebugInfoFinder::processLocation(DILocation Loc) {
+void DebugInfoFinder::processLocation(const Module &M, DILocation Loc) {
if (!Loc)
return;
+ IntializeTypeMap(M);
processScope(Loc.getScope());
- processLocation(Loc.getOrigLocation());
+ processLocation(M, Loc.getOrigLocation());
}
/// processType - Process DIType.
@@ -1084,10 +1094,12 @@ void DebugInfoFinder::processSubprogram(DISubprogram SP) {
}
/// processDeclare - Process DbgDeclareInst.
-void DebugInfoFinder::processDeclare(const DbgDeclareInst *DDI) {
+void DebugInfoFinder::processDeclare(const Module &M,
+ const DbgDeclareInst *DDI) {
MDNode *N = dyn_cast<MDNode>(DDI->getVariable());
if (!N)
return;
+ IntializeTypeMap(M);
DIDescriptor DV(N);
if (!DV.isVariable())
@@ -1099,10 +1111,11 @@ void DebugInfoFinder::processDeclare(const DbgDeclareInst *DDI) {
processType(DIVariable(N).getType());
}
-void DebugInfoFinder::processValue(const DbgValueInst *DVI) {
+void DebugInfoFinder::processValue(const Module &M, const DbgValueInst *DVI) {
MDNode *N = dyn_cast<MDNode>(DVI->getVariable());
if (!N)
return;
+ IntializeTypeMap(M);
DIDescriptor DV(N);
if (!DV.isVariable())
diff --git a/lib/IR/Verifier.cpp b/lib/IR/Verifier.cpp
index 8ce48bed28..32acfbd9cc 100644
--- a/lib/IR/Verifier.cpp
+++ b/lib/IR/Verifier.cpp
@@ -2125,7 +2125,7 @@ void Verifier::visitInstruction(Instruction &I) {
if (!DisableDebugInfoVerifier) {
MD = I.getMetadata(LLVMContext::MD_dbg);
- Finder.processLocation(DILocation(MD));
+ Finder.processLocation(*Mod, DILocation(MD));
}
InstsInThisBlock.insert(&I);
@@ -2303,13 +2303,13 @@ void Verifier::visitIntrinsicFunctionCall(Intrinsic::ID ID, CallInst &CI) {
Assert1(MD->getNumOperands() == 1,
"invalid llvm.dbg.declare intrinsic call 2", &CI);
if (!DisableDebugInfoVerifier)
- Finder.processDeclare(cast<DbgDeclareInst>(&CI));
+ Finder.processDeclare(*Mod, cast<DbgDeclareInst>(&CI));
} break;
case Intrinsic::dbg_value: { //llvm.dbg.value
if (!DisableDebugInfoVerifier) {
Assert1(CI.getArgOperand(0) && isa<MDNode>(CI.getArgOperand(0)),
"invalid llvm.dbg.value intrinsic call 1", &CI);
- Finder.processValue(cast<DbgValueInst>(&CI));
+ Finder.processValue(*Mod, cast<DbgValueInst>(&CI));
}
break;
}