summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR
diff options
context:
space:
mode:
authorManman Ren <manman.ren@gmail.com>2013-09-09 19:47:11 +0000
committerManman Ren <manman.ren@gmail.com>2013-09-09 19:47:11 +0000
commit116868eaddccd6080ca0c564c6d7e44ebebcb3c9 (patch)
treef968356b1270e7622ee41ab446dccab2ba7b7c0f /llvm/lib/IR
parent7a8b6ca2d16c529dfa3e3f1188ec070454850b6f (diff)
downloadbcm5719-llvm-116868eaddccd6080ca0c564c6d7e44ebebcb3c9.tar.gz
bcm5719-llvm-116868eaddccd6080ca0c564c6d7e44ebebcb3c9.zip
Debug Info: Use DIScopeRef for DIType::getContext.
In DIBuilder, the context field of a TAG_member is updated to use the scope reference. Verifier is updated accordingly. DebugInfoFinder now needs to generate a type identifier map to have access to the actual scope. Same applies for BreakpointPrinter. processModule of DebugInfoFinder is called during initialization phase of the verifier to make sure the type identifier map is constructed early enough. We are now able to unique a simple class as demonstrated by the added testing case. llvm-svn: 190334
Diffstat (limited to 'llvm/lib/IR')
-rw-r--r--llvm/lib/IR/DIBuilder.cpp2
-rw-r--r--llvm/lib/IR/DebugInfo.cpp12
-rw-r--r--llvm/lib/IR/Verifier.cpp4
3 files changed, 13 insertions, 5 deletions
diff --git a/llvm/lib/IR/DIBuilder.cpp b/llvm/lib/IR/DIBuilder.cpp
index c485cc15ecf..9439305857c 100644
--- a/llvm/lib/IR/DIBuilder.cpp
+++ b/llvm/lib/IR/DIBuilder.cpp
@@ -417,7 +417,7 @@ DIDerivedType DIBuilder::createMemberType(
Value *Elts[] = {
GetTagConstant(VMContext, dwarf::DW_TAG_member),
File.getFileNode(),
- getNonCompileUnitScope(Scope),
+ DIScope(getNonCompileUnitScope(Scope)).generateRef(),
MDString::get(VMContext, Name),
ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber),
ConstantInt::get(Type::getInt64Ty(VMContext), SizeInBits),
diff --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp
index dc22db3b01b..e0b59649a76 100644
--- a/llvm/lib/IR/DebugInfo.cpp
+++ b/llvm/lib/IR/DebugInfo.cpp
@@ -446,12 +446,18 @@ static bool isScopeRef(const Value *Val) {
(isa<MDNode>(Val) && DIScope(cast<MDNode>(Val)).isScope());
}
+/// Check if a field at position Elt of a MDNode can be a ScopeRef.
+static bool fieldIsScopeRef(const MDNode *DbgNode, unsigned Elt) {
+ Value *Fld = getField(DbgNode, Elt);
+ return isScopeRef(Fld);
+}
+
/// Verify - Verify that a type descriptor is well formed.
bool DIType::Verify() const {
if (!isType())
return false;
// Make sure Context @ field 2 is MDNode.
- if (!fieldIsMDNode(DbgNode, 2))
+ if (!fieldIsScopeRef(DbgNode, 2))
return false;
// FIXME: Sink this into the various subclass verifies.
@@ -956,11 +962,13 @@ void DebugInfoFinder::reset() {
TYs.clear();
Scopes.clear();
NodesSeen.clear();
+ TypeIdentifierMap.clear();
}
/// processModule - Process entire module and collect debug info.
void DebugInfoFinder::processModule(const Module &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);
@@ -1010,7 +1018,7 @@ void DebugInfoFinder::processLocation(DILocation Loc) {
void DebugInfoFinder::processType(DIType DT) {
if (!addType(DT))
return;
- processScope(DT.getContext());
+ processScope(DT.getContext().resolve(TypeIdentifierMap));
if (DT.isCompositeType()) {
DICompositeType DCT(DT);
processType(DCT.getTypeDerivedFrom());
diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp
index d939084052e..b6d148b377c 100644
--- a/llvm/lib/IR/Verifier.cpp
+++ b/llvm/lib/IR/Verifier.cpp
@@ -170,6 +170,8 @@ namespace {
Finder.reset();
DL = getAnalysisIfAvailable<DataLayout>();
+ if (!DisableDebugInfoVerifier)
+ Finder.processModule(M);
// We must abort before returning back to the pass manager, or else the
// pass manager may try to run other passes on the broken module.
@@ -2305,8 +2307,6 @@ void Verifier::visitIntrinsicFunctionCall(Intrinsic::ID ID, CallInst &CI) {
void Verifier::verifyDebugInfo(Module &M) {
// Verify Debug Info.
if (!DisableDebugInfoVerifier) {
- Finder.processModule(M);
-
for (DebugInfoFinder::iterator I = Finder.compile_unit_begin(),
E = Finder.compile_unit_end(); I != E; ++I)
Assert1(DICompileUnit(*I).Verify(), "DICompileUnit does not Verify!", *I);
OpenPOWER on IntegriCloud