From 0ef3fa6aabc80995c8a0bd829c85c89ef2d4c32d Mon Sep 17 00:00:00 2001 From: Devang Patel Date: Mon, 8 Mar 2010 19:20:38 +0000 Subject: [PATCH] Revert r97947. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97963 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Analysis/DebugInfo.h | 9 +- lib/Analysis/DebugInfo.cpp | 145 ++++++++++++++----------- lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 4 +- lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 121 ++++++++++++--------- lib/CodeGen/AsmPrinter/DwarfDebug.h | 2 +- lib/CodeGen/MachineInstr.cpp | 2 +- lib/Target/PIC16/PIC16DebugInfo.cpp | 2 +- lib/Transforms/Utils/CloneFunction.cpp | 6 +- 8 files changed, 163 insertions(+), 128 deletions(-) diff --git a/include/llvm/Analysis/DebugInfo.h b/include/llvm/Analysis/DebugInfo.h index 14c3e1bb1cf..f105c20ff20 100644 --- a/include/llvm/Analysis/DebugInfo.h +++ b/include/llvm/Analysis/DebugInfo.h @@ -67,7 +67,7 @@ namespace llvm { explicit DIDescriptor() : DbgNode(0) {} explicit DIDescriptor(MDNode *N) : DbgNode(N) {} - bool Verify() const { return DbgNode != 0; } + bool isNull() const { return DbgNode == 0; } MDNode *getNode() const { return DbgNode; } @@ -246,9 +246,7 @@ namespace llvm { bool isArtificial() const { return (getFlags() & FlagArtificial) != 0; } - bool isValid() const { - return DbgNode && (isBasicType() || isDerivedType() || isCompositeType()); - } + /// dump - print type. void dump() const; }; @@ -362,7 +360,7 @@ namespace llvm { /// DIType or as DICompositeType. StringRef getReturnTypeName() const { DICompositeType DCT(getFieldAs(8)); - if (DCT.Verify()) { + if (!DCT.isNull()) { DIArray A = DCT.getTypeArray(); DIType T(A.getElement(0).getNode()); return T.getName(); @@ -496,7 +494,6 @@ namespace llvm { DILocation getOrigLocation() const { return getFieldAs(3); } StringRef getFilename() const { return getScope().getFilename(); } StringRef getDirectory() const { return getScope().getDirectory(); } - bool Verify() const; }; /// DIFactory - This object assists with the construction of the various diff --git a/lib/Analysis/DebugInfo.cpp b/lib/Analysis/DebugInfo.cpp index 98082ffb18f..5cfe666b15e 100644 --- a/lib/Analysis/DebugInfo.cpp +++ b/lib/Analysis/DebugInfo.cpp @@ -132,12 +132,13 @@ unsigned DIVariable::getNumAddrElements() const { /// isBasicType - Return true if the specified tag is legal for /// DIBasicType. bool DIDescriptor::isBasicType() const { - return DbgNode && getTag() == dwarf::DW_TAG_base_type; + assert(!isNull() && "Invalid descriptor!"); + return getTag() == dwarf::DW_TAG_base_type; } /// isDerivedType - Return true if the specified tag is legal for DIDerivedType. bool DIDescriptor::isDerivedType() const { - if (!DbgNode) return false; + assert(!isNull() && "Invalid descriptor!"); switch (getTag()) { case dwarf::DW_TAG_typedef: case dwarf::DW_TAG_pointer_type: @@ -157,7 +158,7 @@ bool DIDescriptor::isDerivedType() const { /// isCompositeType - Return true if the specified tag is legal for /// DICompositeType. bool DIDescriptor::isCompositeType() const { - if (!DbgNode) return false; + assert(!isNull() && "Invalid descriptor!"); switch (getTag()) { case dwarf::DW_TAG_array_type: case dwarf::DW_TAG_structure_type: @@ -174,7 +175,7 @@ bool DIDescriptor::isCompositeType() const { /// isVariable - Return true if the specified tag is legal for DIVariable. bool DIDescriptor::isVariable() const { - if (!DbgNode) return false; + assert(!isNull() && "Invalid descriptor!"); switch (getTag()) { case dwarf::DW_TAG_auto_variable: case dwarf::DW_TAG_arg_variable: @@ -193,13 +194,15 @@ bool DIDescriptor::isType() const { /// isSubprogram - Return true if the specified tag is legal for /// DISubprogram. bool DIDescriptor::isSubprogram() const { - return DbgNode && getTag() == dwarf::DW_TAG_subprogram; + assert(!isNull() && "Invalid descriptor!"); + return getTag() == dwarf::DW_TAG_subprogram; } /// isGlobalVariable - Return true if the specified tag is legal for /// DIGlobalVariable. bool DIDescriptor::isGlobalVariable() const { - return DbgNode && getTag() == dwarf::DW_TAG_variable; + assert(!isNull() && "Invalid descriptor!"); + return getTag() == dwarf::DW_TAG_variable; } /// isGlobal - Return true if the specified tag is legal for DIGlobal. @@ -210,7 +213,7 @@ bool DIDescriptor::isGlobal() const { /// isScope - Return true if the specified tag is one of the scope /// related tag. bool DIDescriptor::isScope() const { - if (!DbgNode) return false; + assert(!isNull() && "Invalid descriptor!"); switch (getTag()) { case dwarf::DW_TAG_compile_unit: case dwarf::DW_TAG_lexical_block: @@ -225,27 +228,32 @@ bool DIDescriptor::isScope() const { /// isCompileUnit - Return true if the specified tag is DW_TAG_compile_unit. bool DIDescriptor::isCompileUnit() const { - return DbgNode && getTag() == dwarf::DW_TAG_compile_unit; + assert(!isNull() && "Invalid descriptor!"); + return getTag() == dwarf::DW_TAG_compile_unit; } /// isNameSpace - Return true if the specified tag is DW_TAG_namespace. bool DIDescriptor::isNameSpace() const { - return DbgNode && getTag() == dwarf::DW_TAG_namespace; + assert(!isNull() && "Invalid descriptor!"); + return getTag() == dwarf::DW_TAG_namespace; } /// isLexicalBlock - Return true if the specified tag is DW_TAG_lexical_block. bool DIDescriptor::isLexicalBlock() const { - return DbgNode && getTag() == dwarf::DW_TAG_lexical_block; + assert(!isNull() && "Invalid descriptor!"); + return getTag() == dwarf::DW_TAG_lexical_block; } /// isSubrange - Return true if the specified tag is DW_TAG_subrange_type. bool DIDescriptor::isSubrange() const { - return DbgNode && getTag() == dwarf::DW_TAG_subrange_type; + assert(!isNull() && "Invalid descriptor!"); + return getTag() == dwarf::DW_TAG_subrange_type; } /// isEnumerator - Return true if the specified tag is DW_TAG_enumerator. bool DIDescriptor::isEnumerator() const { - return DbgNode && getTag() == dwarf::DW_TAG_enumerator; + assert(!isNull() && "Invalid descriptor!"); + return getTag() == dwarf::DW_TAG_enumerator; } //===----------------------------------------------------------------------===// @@ -260,8 +268,7 @@ DIType::DIType(MDNode *N) : DIDescriptor(N) { } unsigned DIArray::getNumElements() const { - if (!DbgNode) - return 0; + assert(DbgNode && "Invalid DIArray"); return DbgNode->getNumOperands(); } @@ -269,9 +276,11 @@ unsigned DIArray::getNumElements() const { /// this descriptor. After this completes, the current debug info value /// is erased. void DIDerivedType::replaceAllUsesWith(DIDescriptor &D) { - if (!DbgNode) + if (isNull()) return; + assert(!D.isNull() && "Can not replace with null"); + // Since we use a TrackingVH for the node, its easy for clients to manufacture // legitimate situations where they want to replaceAllUsesWith() on something // which, due to uniquing, has merged with the source. We shield clients from @@ -286,7 +295,7 @@ void DIDerivedType::replaceAllUsesWith(DIDescriptor &D) { /// Verify - Verify that a compile unit is well formed. bool DICompileUnit::Verify() const { - if (!DbgNode) + if (isNull()) return false; StringRef N = getFilename(); if (N.empty()) @@ -297,36 +306,36 @@ bool DICompileUnit::Verify() const { /// Verify - Verify that a type descriptor is well formed. bool DIType::Verify() const { - if (!DbgNode) + if (isNull()) return false; - if (!getContext().Verify()) + if (getContext().isNull()) return false; DICompileUnit CU = getCompileUnit(); - if (!CU.Verify()) + if (!CU.isNull() && !CU.Verify()) return false; return true; } /// Verify - Verify that a composite type descriptor is well formed. bool DICompositeType::Verify() const { - if (!DbgNode) + if (isNull()) return false; - if (!getContext().Verify()) + if (getContext().isNull()) return false; DICompileUnit CU = getCompileUnit(); - if (!CU.Verify()) + if (!CU.isNull() && !CU.Verify()) return false; return true; } /// Verify - Verify that a subprogram descriptor is well formed. bool DISubprogram::Verify() const { - if (!DbgNode) + if (isNull()) return false; - if (!getContext().Verify()) + if (getContext().isNull()) return false; DICompileUnit CU = getCompileUnit(); @@ -334,24 +343,24 @@ bool DISubprogram::Verify() const { return false; DICompositeType Ty = getType(); - if (!Ty.Verify()) + if (!Ty.isNull() && !Ty.Verify()) return false; return true; } /// Verify - Verify that a global variable descriptor is well formed. bool DIGlobalVariable::Verify() const { - if (!DbgNode) + if (isNull()) return false; if (getDisplayName().empty()) return false; - if (!getContext().Verify()) + if (getContext().isNull()) return false; DICompileUnit CU = getCompileUnit(); - if (!CU.Verify()) + if (!CU.isNull() && !CU.Verify()) return false; DIType Ty = getType(); @@ -366,10 +375,10 @@ bool DIGlobalVariable::Verify() const { /// Verify - Verify that a variable descriptor is well formed. bool DIVariable::Verify() const { - if (!DbgNode) + if (isNull()) return false; - if (!getContext().Verify()) + if (getContext().isNull()) return false; DIType Ty = getType(); @@ -379,14 +388,6 @@ bool DIVariable::Verify() const { return true; } -/// Verify - Verify that a location descriptor is well formed. -bool DILocation::Verify() const { - if (!DbgNode) - return false; - - return DbgNode->getNumOperands() == 4; -} - /// getOriginalTypeSize - If this type is derived from a base type then /// return base type size. uint64_t DIDerivedType::getOriginalTypeSize() const { @@ -397,7 +398,7 @@ uint64_t DIDerivedType::getOriginalTypeSize() const { DIType BaseType = getTypeDerivedFrom(); // If this type is not derived from any type then take conservative // approach. - if (!BaseType.isValid()) + if (BaseType.isNull()) return getSizeInBits(); if (BaseType.isDerivedType()) return DIDerivedType(BaseType.getNode()).getOriginalTypeSize(); @@ -467,7 +468,7 @@ void DICompileUnit::dump() const { /// dump - Print type. void DIType::dump() const { - if (!DbgNode) return; + if (isNull()) return; StringRef Res = getName(); if (!Res.empty()) @@ -520,6 +521,8 @@ void DIDerivedType::dump() const { /// dump - Print composite type. void DICompositeType::dump() const { DIArray A = getTypeArray(); + if (A.isNull()) + return; dbgs() << " [" << A.getNumElements() << " elements]"; } @@ -1152,8 +1155,9 @@ void DebugInfoFinder::processModule(Module &M) { /// processLocation - Process DILocation. void DebugInfoFinder::processLocation(DILocation Loc) { - if (!Loc.Verify()) return; - DIDescriptor S(Loc.getScope().getNode()); + if (Loc.isNull()) return; + DIScope S(Loc.getScope().getNode()); + if (S.isNull()) return; if (S.isCompileUnit()) addCompileUnit(DICompileUnit(S.getNode())); else if (S.isSubprogram()) @@ -1173,21 +1177,26 @@ void DebugInfoFinder::processType(DIType DT) { DICompositeType DCT(DT.getNode()); processType(DCT.getTypeDerivedFrom()); DIArray DA = DCT.getTypeArray(); - for (unsigned i = 0, e = DA.getNumElements(); i != e; ++i) { - DIDescriptor D = DA.getElement(i); - if (D.isType()) - processType(DIType(D.getNode())); - else if (D.isSubprogram()) - processSubprogram(DISubprogram(D.getNode())); - } + if (!DA.isNull()) + for (unsigned i = 0, e = DA.getNumElements(); i != e; ++i) { + DIDescriptor D = DA.getElement(i); + DIType TyE = DIType(D.getNode()); + if (!TyE.isNull()) + processType(TyE); + else + processSubprogram(DISubprogram(D.getNode())); + } } else if (DT.isDerivedType()) { DIDerivedType DDT(DT.getNode()); - processType(DDT.getTypeDerivedFrom()); + if (!DDT.isNull()) + processType(DDT.getTypeDerivedFrom()); } } /// processLexicalBlock void DebugInfoFinder::processLexicalBlock(DILexicalBlock LB) { + if (LB.isNull()) + return; DIScope Context = LB.getContext(); if (Context.isLexicalBlock()) return processLexicalBlock(DILexicalBlock(Context.getNode())); @@ -1197,6 +1206,8 @@ void DebugInfoFinder::processLexicalBlock(DILexicalBlock LB) { /// processSubprogram - Process DISubprogram. void DebugInfoFinder::processSubprogram(DISubprogram SP) { + if (SP.isNull()) + return; if (!addSubprogram(SP)) return; addCompileUnit(SP.getCompileUnit()); @@ -1205,23 +1216,20 @@ void DebugInfoFinder::processSubprogram(DISubprogram SP) { /// processDeclare - Process DbgDeclareInst. void DebugInfoFinder::processDeclare(DbgDeclareInst *DDI) { - MDNode *N = dyn_cast(DDI->getVariable()); - if (!N) return; - - DIDescriptor DV(N); - if (!DV.isVariable()) + DIVariable DV(cast(DDI->getVariable())); + if (DV.isNull()) return; if (!NodesSeen.insert(DV.getNode())) return; - addCompileUnit(DIVariable(N).getCompileUnit()); - processType(DIVariable(N).getType()); + addCompileUnit(DV.getCompileUnit()); + processType(DV.getType()); } /// addType - Add type into Tys. bool DebugInfoFinder::addType(DIType DT) { - if (!DT.isValid()) + if (DT.isNull()) return false; if (!NodesSeen.insert(DT.getNode())) @@ -1233,7 +1241,7 @@ bool DebugInfoFinder::addType(DIType DT) { /// addCompileUnit - Add compile unit into CUs. bool DebugInfoFinder::addCompileUnit(DICompileUnit CU) { - if (!CU.Verify()) + if (CU.isNull()) return false; if (!NodesSeen.insert(CU.getNode())) @@ -1245,7 +1253,7 @@ bool DebugInfoFinder::addCompileUnit(DICompileUnit CU) { /// addGlobalVariable - Add global variable into GVs. bool DebugInfoFinder::addGlobalVariable(DIGlobalVariable DIG) { - if (!DIDescriptor(DIG.getNode()).isGlobalVariable()) + if (DIG.isNull()) return false; if (!NodesSeen.insert(DIG.getNode())) @@ -1257,7 +1265,7 @@ bool DebugInfoFinder::addGlobalVariable(DIGlobalVariable DIG) { // addSubprogram - Add subprgoram into SPs. bool DebugInfoFinder::addSubprogram(DISubprogram SP) { - if (!DIDescriptor(SP.getNode()).isSubprogram()) + if (SP.isNull()) return false; if (!NodesSeen.insert(SP.getNode())) @@ -1275,10 +1283,10 @@ static Value *findDbgGlobalDeclare(GlobalVariable *V) { return 0; for (unsigned i = 0, e = NMD->getNumOperands(); i != e; ++i) { - DIDescriptor DIG(cast_or_null(NMD->getOperand(i))); - if (!DIG.isGlobalVariable()) + DIGlobalVariable DIG(cast_or_null(NMD->getOperand(i))); + if (DIG.isNull()) continue; - if (DIGlobalVariable(DIG.getNode()).getGlobal() == V) + if (DIG.getGlobal() == V) return DIG.getNode(); } return 0; @@ -1370,6 +1378,12 @@ DebugLoc llvm::ExtractDebugLocation(DILocation &Loc, /// getDISubprogram - Find subprogram that is enclosing this scope. DISubprogram llvm::getDISubprogram(MDNode *Scope) { DIDescriptor D(Scope); + if (D.isNull()) + return DISubprogram(); + + if (D.isCompileUnit()) + return DISubprogram(); + if (D.isSubprogram()) return DISubprogram(Scope); @@ -1381,6 +1395,9 @@ DISubprogram llvm::getDISubprogram(MDNode *Scope) { /// getDICompositeType - Find underlying composite type. DICompositeType llvm::getDICompositeType(DIType T) { + if (T.isNull()) + return DICompositeType(); + if (T.isCompositeType()) return DICompositeType(T.getNode()); diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index c0d92ffbbbc..bd2b1b61971 100644 --- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -335,7 +335,7 @@ static void EmitComments(const MachineInstr &MI, raw_ostream &CommentOS) { // Print source line info. DIScope Scope = DLT.getScope(); // Omit the directory, because it's likely to be long and uninteresting. - if (Scope.Verify()) + if (!Scope.isNull()) CommentOS << Scope.getFilename(); else CommentOS << ""; @@ -1287,7 +1287,7 @@ void AsmPrinter::processDebugLoc(const MachineInstr *MI, if (DL.isUnknown()) return; DILocation CurDLT = MF->getDILocation(DL); - if (!CurDLT.getScope().Verify()) + if (CurDLT.getScope().isNull()) return; if (!BeforePrintingInsn) { diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index cfa84c40cb2..5ad1e5ea050 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -413,7 +413,7 @@ void DwarfDebug::addBlock(DIE *Die, unsigned Attribute, unsigned Form, /// entry. void DwarfDebug::addSourceLine(DIE *Die, const DIVariable *V) { // If there is no compile unit specified, don't add a line #. - if (!V->getCompileUnit().Verify()) + if (V->getCompileUnit().isNull()) return; unsigned Line = V->getLineNumber(); @@ -427,7 +427,7 @@ void DwarfDebug::addSourceLine(DIE *Die, const DIVariable *V) { /// entry. void DwarfDebug::addSourceLine(DIE *Die, const DIGlobal *G) { // If there is no compile unit specified, don't add a line #. - if (!G->getCompileUnit().Verify()) + if (G->getCompileUnit().isNull()) return; unsigned Line = G->getLineNumber(); @@ -441,7 +441,7 @@ void DwarfDebug::addSourceLine(DIE *Die, const DIGlobal *G) { /// entry. void DwarfDebug::addSourceLine(DIE *Die, const DISubprogram *SP) { // If there is no compile unit specified, don't add a line #. - if (!SP->getCompileUnit().Verify()) + if (SP->getCompileUnit().isNull()) return; // If the line number is 0, don't add it. if (SP->getLineNumber() == 0) @@ -460,7 +460,7 @@ void DwarfDebug::addSourceLine(DIE *Die, const DISubprogram *SP) { void DwarfDebug::addSourceLine(DIE *Die, const DIType *Ty) { // If there is no compile unit specified, don't add a line #. DICompileUnit CU = Ty->getCompileUnit(); - if (!CU.Verify()) + if (CU.isNull()) return; unsigned Line = Ty->getLineNumber(); @@ -474,7 +474,7 @@ void DwarfDebug::addSourceLine(DIE *Die, const DIType *Ty) { /// entry. void DwarfDebug::addSourceLine(DIE *Die, const DINameSpace *NS) { // If there is no compile unit specified, don't add a line #. - if (!NS->getCompileUnit().Verify()) + if (NS->getCompileUnit().isNull()) return; unsigned Line = NS->getLineNumber(); @@ -526,8 +526,12 @@ DIType DwarfDebug::getBlockByrefType(DIType Ty, std::string Name) { } DICompositeType blockStruct = DICompositeType(subType.getNode()); + DIArray Elements = blockStruct.getTypeArray(); + if (Elements.isNull()) + return Ty; + for (unsigned i = 0, N = Elements.getNumElements(); i < N; ++i) { DIDescriptor Element = Elements.getElement(i); DIDerivedType DT = DIDerivedType(Element.getNode()); @@ -673,6 +677,7 @@ void DwarfDebug::addBlockByrefAddress(DbgVariable *&DV, DIE *Die, DIDescriptor varField = DIDescriptor(); DIDescriptor forwardingField = DIDescriptor(); + for (unsigned i = 0, N = Fields.getNumElements(); i < N; ++i) { DIDescriptor Element = Fields.getElement(i); DIDerivedType DT = DIDerivedType(Element.getNode()); @@ -683,6 +688,10 @@ void DwarfDebug::addBlockByrefAddress(DbgVariable *&DV, DIE *Die, varField = Element; } + assert(!varField.isNull() && "Can't find byref variable in Block struct"); + assert(!forwardingField.isNull() + && "Can't find forwarding field in Block struct"); + // Get the offsets for the forwarding field and the variable field. unsigned int forwardingFieldOffset = DIDerivedType(forwardingField.getNode()).getOffsetInBits() >> 3; @@ -772,7 +781,9 @@ void DwarfDebug::addAddress(DIE *Die, unsigned Attribute, /// addToContextOwner - Add Die into the list of its context owner's children. void DwarfDebug::addToContextOwner(DIE *Die, DIDescriptor Context) { - if (Context.isType()) { + if (Context.isNull()) + ModuleCU->addDie(Die); + else if (Context.isType()) { DIE *ContextDIE = getOrCreateTypeDIE(DIType(Context.getNode())); ContextDIE->addChild(Die); } else if (Context.isNameSpace()) { @@ -809,7 +820,7 @@ DIE *DwarfDebug::getOrCreateTypeDIE(DIType Ty) { /// addType - Add a new type attribute to the specified entity. void DwarfDebug::addType(DIE *Entity, DIType Ty) { - if (!Ty.isValid()) + if (Ty.isNull()) return; // Check for pre-existence. @@ -895,9 +906,9 @@ void DwarfDebug::constructTypeDIE(DIE &Buffer, DICompositeType CTy) { // Add enumerators to enumeration type. for (unsigned i = 0, N = Elements.getNumElements(); i < N; ++i) { DIE *ElemDie = NULL; - DIDescriptor Enum(Elements.getElement(i).getNode()); - if (Enum.isEnumerator()) { - ElemDie = constructEnumTypeDIE(DIEnumerator(Enum.getNode())); + DIEnumerator Enum(Elements.getElement(i).getNode()); + if (!Enum.isNull()) { + ElemDie = constructEnumTypeDIE(&Enum); Buffer.addChild(ElemDie); } } @@ -928,17 +939,18 @@ void DwarfDebug::constructTypeDIE(DIE &Buffer, DICompositeType CTy) { DIArray Elements = CTy.getTypeArray(); // A forward struct declared type may not have elements available. - unsigned N = Elements.getNumElements(); - if (N == 0) + if (Elements.isNull()) break; // Add elements to structure type. - for (unsigned i = 0; i < N; ++i) { + for (unsigned i = 0, N = Elements.getNumElements(); i < N; ++i) { DIDescriptor Element = Elements.getElement(i); + if (Element.isNull()) + continue; DIE *ElemDie = NULL; - if (Element.isSubprogram()) + if (Element.getTag() == dwarf::DW_TAG_subprogram) ElemDie = createSubprogramDIE(DISubprogram(Element.getNode())); - else if (Element.isVariable()) { + else if (Element.getTag() == dwarf::DW_TAG_auto_variable) { DIVariable DV(Element.getNode()); ElemDie = new DIE(dwarf::DW_TAG_variable); addString(ElemDie, dwarf::DW_AT_name, dwarf::DW_FORM_string, @@ -947,10 +959,8 @@ void DwarfDebug::constructTypeDIE(DIE &Buffer, DICompositeType CTy) { addUInt(ElemDie, dwarf::DW_AT_declaration, dwarf::DW_FORM_flag, 1); addUInt(ElemDie, dwarf::DW_AT_external, dwarf::DW_FORM_flag, 1); addSourceLine(ElemDie, &DV); - } else if (Element.isDerivedType()) + } else ElemDie = createMemberDIE(DIDerivedType(Element.getNode())); - else - continue; Buffer.addChild(ElemDie); } @@ -963,7 +973,7 @@ void DwarfDebug::constructTypeDIE(DIE &Buffer, DICompositeType CTy) { dwarf::DW_FORM_data1, RLang); DICompositeType ContainingType = CTy.getContainingType(); - if (DIDescriptor(ContainingType.getNode()).isCompositeType()) + if (!ContainingType.isNull()) addDIEEntry(&Buffer, dwarf::DW_AT_containing_type, dwarf::DW_FORM_ref4, getOrCreateTypeDIE(DIType(ContainingType.getNode()))); break; @@ -1041,11 +1051,11 @@ void DwarfDebug::constructArrayTypeDIE(DIE &Buffer, } /// constructEnumTypeDIE - Construct enum type DIE from DIEnumerator. -DIE *DwarfDebug::constructEnumTypeDIE(DIEnumerator ETy) { +DIE *DwarfDebug::constructEnumTypeDIE(DIEnumerator *ETy) { DIE *Enumerator = new DIE(dwarf::DW_TAG_enumerator); - StringRef Name = ETy.getName(); + StringRef Name = ETy->getName(); addString(Enumerator, dwarf::DW_AT_name, dwarf::DW_FORM_string, Name); - int64_t Value = ETy.getEnumValue(); + int64_t Value = ETy->getEnumValue(); addSInt(Enumerator, dwarf::DW_AT_const_value, dwarf::DW_FORM_sdata, Value); return Enumerator; } @@ -1189,7 +1199,7 @@ DIE *DwarfDebug::createSubprogramDIE(const DISubprogram &SP, bool MakeDecl) { DIArray Args = SPTy.getTypeArray(); unsigned SPTag = SPTy.getTag(); - if (Args.getNumElements() == 0 || SPTag != dwarf::DW_TAG_subroutine_type) + if (Args.isNull() || SPTag != dwarf::DW_TAG_subroutine_type) addType(SPDie, SPTy); else addType(SPDie, DIType(Args.getElement(0).getNode())); @@ -1272,9 +1282,11 @@ DbgScope *DwarfDebug::getUpdatedDbgScope(MDNode *N, const MachineInstr *MI, Parent->addScope(NScope); } else if (DIDescriptor(N).isLexicalBlock()) { DILexicalBlock DB(N); - Parent = getUpdatedDbgScope(DB.getContext().getNode(), MI, InlinedAt); - NScope->setParent(Parent); - Parent->addScope(NScope); + if (!DB.getContext().isNull()) { + Parent = getUpdatedDbgScope(DB.getContext().getNode(), MI, InlinedAt); + NScope->setParent(Parent); + Parent->addScope(NScope); + } } NScope->setFirstInsn(MI); @@ -1306,7 +1318,8 @@ DbgScope *DwarfDebug::getOrCreateAbstractScope(MDNode *N) { if (Scope.isLexicalBlock()) { DILexicalBlock DB(N); DIDescriptor ParentDesc = DB.getContext(); - Parent = getOrCreateAbstractScope(ParentDesc.getNode()); + if (!ParentDesc.isNull()) + Parent = getOrCreateAbstractScope(ParentDesc.getNode()); } AScope = new DbgScope(Parent, DIDescriptor(N), NULL); @@ -1409,9 +1422,10 @@ DIE *DwarfDebug::constructInlinedScopeDIE(DbgScope *Scope) { // Ignore empty scopes. if (StartID == EndID && StartID != 0) return NULL; - if (!Scope->getScopeNode()) - return NULL; + DIScope DS(Scope->getScopeNode()); + if (DS.isNull()) + return NULL; DIE *ScopeDIE = new DIE(dwarf::DW_TAG_inlined_subroutine); DISubprogram InlinedSP = getDISubprogram(DS.getNode()); @@ -1533,12 +1547,15 @@ void DwarfDebug::addPubTypes(DISubprogram SP) { return; DIArray Args = SPTy.getTypeArray(); + if (Args.isNull()) + return; + for (unsigned i = 0, e = Args.getNumElements(); i != e; ++i) { DIType ATy(Args.getElement(i).getNode()); - if (!ATy.isValid()) + if (ATy.isNull()) continue; DICompositeType CATy = getDICompositeType(ATy); - if (DIDescriptor(CATy.getNode()).Verify() && !CATy.getName().empty()) { + if (!CATy.isNull() && !CATy.getName().empty()) { if (DIEEntry *Entry = ModuleCU->getDIEEntry(CATy.getNode())) ModuleCU->addGlobalType(CATy.getName(), Entry->getEntry()); } @@ -1547,24 +1564,26 @@ void DwarfDebug::addPubTypes(DISubprogram SP) { /// constructScopeDIE - Construct a DIE for this scope. DIE *DwarfDebug::constructScopeDIE(DbgScope *Scope) { - if (!Scope || !Scope->getScopeNode()) - return NULL; - - DIScope DS(Scope->getScopeNode()); - DIE *ScopeDIE = NULL; - if (Scope->getInlinedAt()) - ScopeDIE = constructInlinedScopeDIE(Scope); - else if (DS.isSubprogram()) { - if (Scope->isAbstractScope()) - ScopeDIE = ModuleCU->getDIE(DS.getNode()); - else - ScopeDIE = updateSubprogramScopeDIE(DS.getNode()); - } - else { - ScopeDIE = constructLexicalScopeDIE(Scope); - if (!ScopeDIE) return NULL; - } - + if (!Scope) + return NULL; + DIScope DS(Scope->getScopeNode()); + if (DS.isNull()) + return NULL; + + DIE *ScopeDIE = NULL; + if (Scope->getInlinedAt()) + ScopeDIE = constructInlinedScopeDIE(Scope); + else if (DS.isSubprogram()) { + if (Scope->isAbstractScope()) + ScopeDIE = ModuleCU->getDIE(DS.getNode()); + else + ScopeDIE = updateSubprogramScopeDIE(DS.getNode()); + } + else { + ScopeDIE = constructLexicalScopeDIE(Scope); + if (!ScopeDIE) return NULL; + } + // Add variables to scope. SmallVector &Variables = Scope->getVariables(); for (unsigned i = 0, N = Variables.size(); i < N; ++i) { @@ -2050,6 +2069,7 @@ bool DwarfDebug::extractScopeInformation() { if (DL.isUnknown()) continue; DILocation DLT = MF->getDILocation(DL); DIScope DLTScope = DLT.getScope(); + if (DLTScope.isNull()) continue; // There is no need to create another DIE for compile unit. For all // other scopes, create one DbgScope now. This will be translated // into a scope DIE at the end. @@ -2069,6 +2089,7 @@ bool DwarfDebug::extractScopeInformation() { if (DL.isUnknown()) continue; DILocation DLT = MF->getDILocation(DL); DIScope DLTScope = DLT.getScope(); + if (DLTScope.isNull()) continue; // There is no need to create another DIE for compile unit. For all // other scopes, create one DbgScope now. This will be translated // into a scope DIE at the end. @@ -2147,7 +2168,7 @@ void DwarfDebug::beginFunction(const MachineFunction *MF) { DILocation DLT = MF->getDILocation(FDL); unsigned LabelID = 0; DISubprogram SP = getDISubprogram(DLT.getScope().getNode()); - if (SP.Verify()) + if (!SP.isNull()) LabelID = recordSourceLine(SP.getLineNumber(), 0, DLT.getScope().getNode()); else diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.h b/lib/CodeGen/AsmPrinter/DwarfDebug.h index 14be2d7e0f8..55baa921006 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.h +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.h @@ -346,7 +346,7 @@ class DwarfDebug : public DwarfPrinter { DICompositeType *CTy); /// constructEnumTypeDIE - Construct enum type DIE from DIEnumerator. - DIE *constructEnumTypeDIE(DIEnumerator ETy); + DIE *constructEnumTypeDIE(DIEnumerator *ETy); /// createGlobalVariableDIE - Create new DIE using GV. DIE *createGlobalVariableDIE(const DIGlobalVariable &GV); diff --git a/lib/CodeGen/MachineInstr.cpp b/lib/CodeGen/MachineInstr.cpp index 4c7cb8f3aae..e23670d1d1d 100644 --- a/lib/CodeGen/MachineInstr.cpp +++ b/lib/CodeGen/MachineInstr.cpp @@ -1219,7 +1219,7 @@ void MachineInstr::print(raw_ostream &OS, const TargetMachine *TM) const { DIScope Scope = DLT.getScope(); OS << " dbg:"; // Omit the directory, since it's usually long and uninteresting. - if (Scope.Verify()) + if (!Scope.isNull()) OS << Scope.getFilename(); else OS << ""; diff --git a/lib/Target/PIC16/PIC16DebugInfo.cpp b/lib/Target/PIC16/PIC16DebugInfo.cpp index da4e0278769..877e4ffc6d7 100644 --- a/lib/Target/PIC16/PIC16DebugInfo.cpp +++ b/lib/Target/PIC16/PIC16DebugInfo.cpp @@ -333,7 +333,7 @@ void PIC16DbgInfo::EmitCompositeTypeDecls(Module &M) { for (DebugInfoFinder::iterator I = DbgFinder.type_begin(), E = DbgFinder.type_end(); I != E; ++I) { DICompositeType CTy(*I); - if (!CTy.Verify()) + if (CTy.isNull()) continue; if (CTy.getTag() == dwarf::DW_TAG_union_type || CTy.getTag() == dwarf::DW_TAG_structure_type ) { diff --git a/lib/Transforms/Utils/CloneFunction.cpp b/lib/Transforms/Utils/CloneFunction.cpp index 62fc2ec10b1..c80827d4983 100644 --- a/lib/Transforms/Utils/CloneFunction.cpp +++ b/lib/Transforms/Utils/CloneFunction.cpp @@ -336,14 +336,14 @@ ConstantFoldMappedInstruction(const Instruction *I) { static MDNode *UpdateInlinedAtInfo(MDNode *InsnMD, MDNode *TheCallMD) { DILocation ILoc(InsnMD); - if (!ILoc.Verify()) return InsnMD; + if (ILoc.isNull()) return InsnMD; DILocation CallLoc(TheCallMD); - if (!CallLoc.Verify()) return InsnMD; + if (CallLoc.isNull()) return InsnMD; DILocation OrigLocation = ILoc.getOrigLocation(); MDNode *NewLoc = TheCallMD; - if (OrigLocation.Verify()) + if (!OrigLocation.isNull()) NewLoc = UpdateInlinedAtInfo(OrigLocation.getNode(), TheCallMD); Value *MDVs[] = { -- 2.34.1