summaryrefslogtreecommitdiff
path: root/lib/IR
diff options
context:
space:
mode:
authorManman Ren <manman.ren@gmail.com>2013-07-20 00:38:46 +0000
committerManman Ren <manman.ren@gmail.com>2013-07-20 00:38:46 +0000
commit96ea03839becf151b2eda518b4bc55b84f6373bf (patch)
tree8341a3e3bf7ab5d8e7be4f70f7ce4dd1341e536d /lib/IR
parentac9e819ca9ad93cfbcf0b7c5b0a7cbbd34cd9176 (diff)
downloadllvm-96ea03839becf151b2eda518b4bc55b84f6373bf.tar.gz
llvm-96ea03839becf151b2eda518b4bc55b84f6373bf.tar.bz2
llvm-96ea03839becf151b2eda518b4bc55b84f6373bf.tar.xz
Debug Info Verifier: simplify DIxxx::Verify
Simplify DIxxx:Verify to not call Verify on an operand. Instead, we use DebugInfoFinder to list all MDNodes that should be a DIScope and all MDNodes that should be a DIType and we will call Verify on those lists. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186737 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/IR')
-rw-r--r--lib/IR/DebugInfo.cpp42
-rw-r--r--lib/IR/Verifier.cpp3
2 files changed, 17 insertions, 28 deletions
diff --git a/lib/IR/DebugInfo.cpp b/lib/IR/DebugInfo.cpp
index 19de781177..f6ffc039dc 100644
--- a/lib/IR/DebugInfo.cpp
+++ b/lib/IR/DebugInfo.cpp
@@ -436,9 +436,6 @@ bool DIObjCProperty::Verify() const {
if (!isObjCProperty())
return false;
- DIType Ty = getType();
- if (!Ty.Verify()) return false;
-
// Don't worry about the rest of the strings for now.
return DbgNode->getNumOperands() == 8;
}
@@ -447,8 +444,6 @@ bool DIObjCProperty::Verify() const {
bool DIType::Verify() const {
if (!isType())
return false;
- if (getContext() && !getContext().Verify())
- return false;
unsigned Tag = getTag();
if (!isBasicType() && Tag != dwarf::DW_TAG_const_type &&
Tag != dwarf::DW_TAG_volatile_type && Tag != dwarf::DW_TAG_pointer_type &&
@@ -481,8 +476,6 @@ bool DIDerivedType::Verify() const {
bool DICompositeType::Verify() const {
if (!isCompositeType())
return false;
- if (getContext() && !getContext().Verify())
- return false;
return DbgNode->getNumOperands() >= 10 && DbgNode->getNumOperands() <= 14;
}
@@ -492,12 +485,6 @@ bool DISubprogram::Verify() const {
if (!isSubprogram())
return false;
- if (getContext() && !getContext().Verify())
- return false;
-
- DICompositeType Ty = getType();
- if (!Ty.Verify())
- return false;
return DbgNode->getNumOperands() == 20;
}
@@ -509,13 +496,6 @@ bool DIGlobalVariable::Verify() const {
if (getDisplayName().empty())
return false;
- if (getContext() && !getContext().Verify())
- return false;
-
- DIType Ty = getType();
- if (!Ty.Verify())
- return false;
-
return DbgNode->getNumOperands() == 13;
}
@@ -524,13 +504,6 @@ bool DIVariable::Verify() const {
if (!isVariable())
return false;
- if (getContext() && !getContext().Verify())
- return false;
-
- DIType Ty = getType();
- if (!Ty.Verify())
- return false;
-
return DbgNode->getNumOperands() >= 8;
}
@@ -883,8 +856,10 @@ void DebugInfoFinder::processModule(const Module &M) {
DIArray GVs = CU.getGlobalVariables();
for (unsigned i = 0, e = GVs.getNumElements(); i != e; ++i) {
DIGlobalVariable DIG(GVs.getElement(i));
- if (addGlobalVariable(DIG))
+ if (addGlobalVariable(DIG)) {
+ addScope(DIG.getContext());
processType(DIG.getType());
+ }
}
DIArray SPs = CU.getSubprograms();
for (unsigned i = 0, e = SPs.getNumElements(); i != e; ++i)
@@ -922,6 +897,7 @@ void DebugInfoFinder::processLocation(DILocation Loc) {
void DebugInfoFinder::processType(DIType DT) {
if (!addType(DT))
return;
+ addScope(DT.getContext());
if (DT.isCompositeType()) {
DICompositeType DCT(DT);
processType(DCT.getTypeDerivedFrom());
@@ -956,6 +932,7 @@ void DebugInfoFinder::processLexicalBlock(DILexicalBlock LB) {
void DebugInfoFinder::processSubprogram(DISubprogram SP) {
if (!addSubprogram(SP))
return;
+ addScope(SP.getContext());
processType(SP.getType());
}
@@ -1021,6 +998,15 @@ bool DebugInfoFinder::addSubprogram(DISubprogram SP) {
return true;
}
+bool DebugInfoFinder::addScope(DIScope Scope) {
+ if (!Scope)
+ return false;
+ if (!NodesSeen.insert(Scope))
+ return false;
+ Scopes.push_back(Scope);
+ return true;
+}
+
//===----------------------------------------------------------------------===//
// DIDescriptor: dump routines for all descriptors.
//===----------------------------------------------------------------------===//
diff --git a/lib/IR/Verifier.cpp b/lib/IR/Verifier.cpp
index 1d495b7ed4..38fc7e3a1b 100644
--- a/lib/IR/Verifier.cpp
+++ b/lib/IR/Verifier.cpp
@@ -2214,6 +2214,9 @@ void Verifier::verifyDebugInfo(Module &M) {
for (DebugInfoFinder::iterator I = Finder.type_begin(),
E = Finder.type_end(); I != E; ++I)
Assert1(DIType(*I).Verify(), "DIType does not Verify!", *I);
+ for (DebugInfoFinder::iterator I = Finder.scope_begin(),
+ E = Finder.scope_end(); I != E; ++I)
+ Assert1(DIScope(*I).Verify(), "DIScope does not Verify!", *I);
}
}