diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp | 10 | ||||
-rw-r--r-- | lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 4 | ||||
-rw-r--r-- | lib/IR/DIBuilder.cpp | 2 | ||||
-rw-r--r-- | lib/IR/DebugInfo.cpp | 12 | ||||
-rw-r--r-- | lib/IR/Verifier.cpp | 4 |
5 files changed, 20 insertions, 12 deletions
diff --git a/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp index f9ce591833..1a527f24fc 100644 --- a/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp @@ -800,7 +800,7 @@ DIE *CompileUnit::getOrCreateTypeDIE(const MDNode *TyNode) { addAccelType(Ty.getName(), std::make_pair(TyDIE, Flags)); } - addToContextOwner(TyDIE, Ty.getContext()); + addToContextOwner(TyDIE, DD->resolve(Ty.getContext())); return TyDIE; } @@ -832,7 +832,7 @@ void CompileUnit::addType(DIE *Entity, DIType Ty, uint16_t Attribute) { /// addGlobalType - Add a new global type to the compile unit. /// void CompileUnit::addGlobalType(DIType Ty) { - DIDescriptor Context = Ty.getContext(); + DIDescriptor Context = DD->resolve(Ty.getContext()); if (Ty.isCompositeType() && !Ty.getName().empty() && !Ty.isForwardDecl() && (!Context || Context.isCompileUnit() || Context.isFile() || Context.isNameSpace())) @@ -914,7 +914,7 @@ void CompileUnit::constructTypeDIE(DIE &Buffer, DIDerivedType DTy) { /// Return true if the type is appropriately scoped to be contained inside /// its own type unit. static bool isTypeUnitScoped(DIType Ty, const DwarfDebug *DD) { - DIScope Parent = Ty.getContext(); + DIScope Parent = DD->resolve(Ty.getContext()); while (Parent) { // Don't generate a hash for anything scoped inside a function. if (Parent.isSubprogram()) @@ -1088,7 +1088,7 @@ void CompileUnit::constructTypeDIE(DIE &Buffer, DICompositeType CTy) { addDIEEntry(&Buffer, dwarf::DW_AT_containing_type, dwarf::DW_FORM_ref4, getOrCreateTypeDIE(DIType(ContainingType))); else - addToContextOwner(&Buffer, CTy.getContext()); + addToContextOwner(&Buffer, DD->resolve(CTy.getContext())); if (CTy.isObjcClassComplete()) addFlag(&Buffer, dwarf::DW_AT_APPLE_objc_complete_type); @@ -1373,7 +1373,7 @@ void CompileUnit::createGlobalVariableDIE(const MDNode *N) { // We need the declaration DIE that is in the static member's class. // But that class might not exist in the DWARF yet. // Creating the class will create the static member decl DIE. - getOrCreateContextDIE(SDMDecl.getContext()); + getOrCreateContextDIE(DD->resolve(SDMDecl.getContext())); VariableDIE = getDIE(SDMDecl); assert(VariableDIE && "Static member decl has no context?"); IsStaticMember = true; diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 1cfadc91e0..21f997ea48 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -341,7 +341,7 @@ bool DwarfDebug::isSubprogramContext(const MDNode *Context) { if (D.isSubprogram()) return true; if (D.isType()) - return isSubprogramContext(DIType(Context).getContext()); + return isSubprogramContext(resolve(DIType(Context).getContext())); return false; } @@ -2656,7 +2656,7 @@ DIScope DwarfDebug::resolve(DIScopeRef SRef) const { DIScope DwarfDebug::getScopeContext(DIScope S) const { if (S.isType()) - return DIType(S).getContext(); + return resolve(DIType(S).getContext()); if (S.isSubprogram()) return DISubprogram(S).getContext(); diff --git a/lib/IR/DIBuilder.cpp b/lib/IR/DIBuilder.cpp index c485cc15ec..9439305857 100644 --- a/lib/IR/DIBuilder.cpp +++ b/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/lib/IR/DebugInfo.cpp b/lib/IR/DebugInfo.cpp index dc22db3b01..e0b59649a7 100644 --- a/lib/IR/DebugInfo.cpp +++ b/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/lib/IR/Verifier.cpp b/lib/IR/Verifier.cpp index d939084052..b6d148b377 100644 --- a/lib/IR/Verifier.cpp +++ b/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); |