[llvm] r194973 - Debug Info Verifier: enable public functions of Finder to update the type map.
Manman Ren
manman.ren at gmail.com
Sun Nov 17 10:42:38 PST 2013
Author: mren
Date: Sun Nov 17 12:42:37 2013
New Revision: 194973
URL: http://llvm.org/viewvc/llvm-project?rev=194973&view=rev
Log:
Debug Info Verifier: enable public functions of Finder to update the type map.
We used to depend on running processModule before the other public functions
such as processDeclare, processValue and processLocation. We are now relaxing
the constraint by adding a module argument to the three functions and
letting the three functions to initialize the type map. This will be used in
a follow-on patch that collects nodes reachable from a Function.
Modified:
llvm/trunk/include/llvm/DebugInfo.h
llvm/trunk/lib/IR/DebugInfo.cpp
llvm/trunk/lib/IR/Verifier.cpp
Modified: llvm/trunk/include/llvm/DebugInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo.h?rev=194973&r1=194972&r2=194973&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo.h (original)
+++ llvm/trunk/include/llvm/DebugInfo.h Sun Nov 17 12:42:37 2013
@@ -766,16 +766,19 @@ public:
void processModule(const Module &M);
/// processDeclare - Process DbgDeclareInst.
- void processDeclare(const DbgDeclareInst *DDI);
+ void processDeclare(const Module &M, const DbgDeclareInst *DDI);
/// Process DbgValueInst.
- void processValue(const DbgValueInst *DVI);
+ void processValue(const Module &M, const DbgValueInst *DVI);
/// processLocation - Process DILocation.
- void processLocation(DILocation Loc);
+ void processLocation(const Module &M, DILocation Loc);
/// Clear all lists.
void reset();
private:
+ /// Initialize TypeIdentifierMap.
+ void IntializeTypeMap(const Module &M);
+
/// processType - Process DIType.
void processType(DIType DT);
@@ -828,6 +831,8 @@ private:
SmallVector<MDNode *, 8> Scopes; // Scopes
SmallPtrSet<MDNode *, 64> NodesSeen;
DITypeIdentifierMap TypeIdentifierMap;
+ /// Specify if TypeIdentifierMap is initialized.
+ bool TypeMapInitialized;
};
} // end namespace llvm
Modified: llvm/trunk/lib/IR/DebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DebugInfo.cpp?rev=194973&r1=194972&r2=194973&view=diff
==============================================================================
--- llvm/trunk/lib/IR/DebugInfo.cpp (original)
+++ llvm/trunk/lib/IR/DebugInfo.cpp Sun Nov 17 12:42:37 2013
@@ -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(cons
}
/// 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(
}
/// 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(con
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())
Modified: llvm/trunk/lib/IR/Verifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Verifier.cpp?rev=194973&r1=194972&r2=194973&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Verifier.cpp (original)
+++ llvm/trunk/lib/IR/Verifier.cpp Sun Nov 17 12:42:37 2013
@@ -2125,7 +2125,7 @@ void Verifier::visitInstruction(Instruct
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::visitIntrinsicFunctionCal
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;
}
More information about the llvm-commits
mailing list