diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2015-04-29 16:38:44 +0000 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2015-04-29 16:38:44 +0000 |
commit | a9308c49ef421d5fa6c990bc8cbdf500acbffd33 (patch) | |
tree | 47dd65fa788567095dea285879afda802522a48d /llvm/lib/CodeGen/AsmPrinter | |
parent | 753954873832863c045afe09953c67bf21ed7fc5 (diff) | |
download | bcm5719-llvm-a9308c49ef421d5fa6c990bc8cbdf500acbffd33.tar.gz bcm5719-llvm-a9308c49ef421d5fa6c990bc8cbdf500acbffd33.zip |
IR: Give 'DI' prefix to debug info metadata
Finish off PR23080 by renaming the debug info IR constructs from `MD*`
to `DI*`. The last of the `DIDescriptor` classes were deleted in
r235356, and the last of the related typedefs removed in r235413, so
this has all baked for about a week.
Note: If you have out-of-tree code (like a frontend), I recommend that
you get everything compiling and tests passing with the *previous*
commit before updating to this one. It'll be easier to keep track of
what code is using the `DIDescriptor` hierarchy and what you've already
updated, and I think you're extremely unlikely to insert bugs. YMMV of
course.
Back to *this* commit: I did this using the rename-md-di-nodes.sh
upgrade script I've attached to PR23080 (both code and testcases) and
filtered through clang-format-diff.py. I edited the tests for
test/Assembler/invalid-generic-debug-node-*.ll by hand since the columns
were off-by-three. It should work on your out-of-tree testcases (and
code, if you've followed the advice in the previous paragraph).
Some of the tests are in badly named files now (e.g.,
test/Assembler/invalid-mdcompositetype-missing-tag.ll should be
'dicompositetype'); I'll come back and move the files in a follow-up
commit.
llvm-svn: 236120
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 6 | ||||
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DbgValueHistoryCalculator.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DbgValueHistoryCalculator.h | 6 | ||||
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DebugLocEntry.h | 20 | ||||
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp | 48 | ||||
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h | 20 | ||||
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 94 | ||||
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h | 42 | ||||
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp | 6 | ||||
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h | 6 | ||||
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfFile.h | 6 | ||||
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp | 181 | ||||
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h | 84 | ||||
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/WinCodeViewLineTables.cpp | 6 |
15 files changed, 264 insertions, 265 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index a8fb9b776d4..d56a1808049 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -668,15 +668,15 @@ static bool emitDebugValueComment(const MachineInstr *MI, AsmPrinter &AP) { raw_svector_ostream OS(Str); OS << "DEBUG_VALUE: "; - const MDLocalVariable *V = MI->getDebugVariable(); - if (auto *SP = dyn_cast<MDSubprogram>(V->getScope())) { + const DILocalVariable *V = MI->getDebugVariable(); + if (auto *SP = dyn_cast<DISubprogram>(V->getScope())) { StringRef Name = SP->getDisplayName(); if (!Name.empty()) OS << Name << ":"; } OS << V->getName(); - const MDExpression *Expr = MI->getDebugExpression(); + const DIExpression *Expr = MI->getDebugExpression(); if (Expr->isBitPiece()) OS << " [bit_piece offset=" << Expr->getBitPieceOffset() << " size=" << Expr->getBitPieceSize() << "]"; diff --git a/llvm/lib/CodeGen/AsmPrinter/DbgValueHistoryCalculator.cpp b/llvm/lib/CodeGen/AsmPrinter/DbgValueHistoryCalculator.cpp index 9cb0aab7705..3c46a99d084 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DbgValueHistoryCalculator.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DbgValueHistoryCalculator.cpp @@ -204,7 +204,7 @@ void llvm::calculateDbgValueHistory(const MachineFunction *MF, // Use the base variable (without any DW_OP_piece expressions) // as index into History. The full variables including the // piece expressions are attached to the MI. - const MDLocalVariable *RawVar = MI.getDebugVariable(); + const DILocalVariable *RawVar = MI.getDebugVariable(); assert(RawVar->isValidLocationForIntrinsic(MI.getDebugLoc()) && "Expected inlined-at fields to agree"); InlinedVariable Var(RawVar, MI.getDebugLoc()->getInlinedAt()); diff --git a/llvm/lib/CodeGen/AsmPrinter/DbgValueHistoryCalculator.h b/llvm/lib/CodeGen/AsmPrinter/DbgValueHistoryCalculator.h index c25aaffd2d1..546d1b44378 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DbgValueHistoryCalculator.h +++ b/llvm/lib/CodeGen/AsmPrinter/DbgValueHistoryCalculator.h @@ -17,8 +17,8 @@ namespace llvm { class MachineFunction; class MachineInstr; -class MDLocalVariable; -class MDLocation; +class DILocalVariable; +class DILocation; class TargetRegisterInfo; // For each user variable, keep a list of instruction ranges where this variable @@ -32,7 +32,7 @@ class DbgValueHistoryMap { public: typedef std::pair<const MachineInstr *, const MachineInstr *> InstrRange; typedef SmallVector<InstrRange, 4> InstrRanges; - typedef std::pair<const MDLocalVariable *, const MDLocation *> + typedef std::pair<const DILocalVariable *, const DILocation *> InlinedVariable; typedef MapVector<InlinedVariable, InstrRanges> InstrRangesMap; diff --git a/llvm/lib/CodeGen/AsmPrinter/DebugLocEntry.h b/llvm/lib/CodeGen/AsmPrinter/DebugLocEntry.h index ff3eb030a65..6a943c64ea2 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DebugLocEntry.h +++ b/llvm/lib/CodeGen/AsmPrinter/DebugLocEntry.h @@ -29,25 +29,25 @@ class DebugLocEntry { public: /// \brief A single location or constant. struct Value { - Value(const MDExpression *Expr, int64_t i) + Value(const DIExpression *Expr, int64_t i) : Expression(Expr), EntryKind(E_Integer) { Constant.Int = i; } - Value(const MDExpression *Expr, const ConstantFP *CFP) + Value(const DIExpression *Expr, const ConstantFP *CFP) : Expression(Expr), EntryKind(E_ConstantFP) { Constant.CFP = CFP; } - Value(const MDExpression *Expr, const ConstantInt *CIP) + Value(const DIExpression *Expr, const ConstantInt *CIP) : Expression(Expr), EntryKind(E_ConstantInt) { Constant.CIP = CIP; } - Value(const MDExpression *Expr, MachineLocation Loc) + Value(const DIExpression *Expr, MachineLocation Loc) : Expression(Expr), EntryKind(E_Location), Loc(Loc) { - assert(cast<MDExpression>(Expr)->isValid()); + assert(cast<DIExpression>(Expr)->isValid()); } /// Any complex address location expression for this Value. - const MDExpression *Expression; + const DIExpression *Expression; /// Type of entry that this represents. enum EntryType { E_Location, E_Integer, E_ConstantFP, E_ConstantInt }; @@ -72,7 +72,7 @@ public: const ConstantInt *getConstantInt() const { return Constant.CIP; } MachineLocation getLoc() const { return Loc; } bool isBitPiece() const { return getExpression()->isBitPiece(); } - const MDExpression *getExpression() const { return Expression; } + const DIExpression *getExpression() const { return Expression; } friend bool operator==(const Value &, const Value &); friend bool operator<(const Value &, const Value &); }; @@ -94,8 +94,8 @@ public: /// Return true if the merge was successful. bool MergeValues(const DebugLocEntry &Next) { if (Begin == Next.Begin) { - auto *Expr = cast_or_null<MDExpression>(Values[0].Expression); - auto *NextExpr = cast_or_null<MDExpression>(Next.Values[0].Expression); + auto *Expr = cast_or_null<DIExpression>(Values[0].Expression); + auto *NextExpr = cast_or_null<DIExpression>(Next.Values[0].Expression); if (Expr->isBitPiece() && NextExpr->isBitPiece()) { addValues(Next.Values); End = Next.End; @@ -143,7 +143,7 @@ public: /// \brief Lower this entry into a DWARF expression. void finalize(const AsmPrinter &AP, DebugLocStream &Locs, - const MDBasicType *BT); + const DIBasicType *BT); }; /// \brief Compare two Values for equality. diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp index 856920f2ffc..c10e70352af 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp @@ -16,7 +16,7 @@ namespace llvm { -DwarfCompileUnit::DwarfCompileUnit(unsigned UID, const MDCompileUnit *Node, +DwarfCompileUnit::DwarfCompileUnit(unsigned UID, const DICompileUnit *Node, AsmPrinter *A, DwarfDebug *DW, DwarfFile *DWU) : DwarfUnit(UID, dwarf::DW_TAG_compile_unit, Node, A, DW, DWU), @@ -98,7 +98,7 @@ static const ConstantExpr *getMergedGlobalExpr(const Value *V) { /// getOrCreateGlobalVariableDIE - get or create global variable DIE. DIE *DwarfCompileUnit::getOrCreateGlobalVariableDIE( - const MDGlobalVariable *GV) { + const DIGlobalVariable *GV) { // Check for pre-existence. if (DIE *Die = getDIE(GV)) return Die; @@ -114,7 +114,7 @@ DIE *DwarfCompileUnit::getOrCreateGlobalVariableDIE( // Add to map. DIE *VariableDIE = &createAndAddDIE(GV->getTag(), *ContextDIE, GV); - MDScope *DeclContext; + DIScope *DeclContext; if (auto *SDMDecl = GV->getStaticDataMemberDeclaration()) { DeclContext = resolve(SDMDecl->getScope()); assert(SDMDecl->isStaticMember() && "Expected static member decl"); @@ -277,7 +277,7 @@ void DwarfCompileUnit::attachLowHighPC(DIE &D, const MCSymbol *Begin, // Find DIE for the given subprogram and attach appropriate DW_AT_low_pc // and DW_AT_high_pc attributes. If there are global variables in this // scope then create and insert DIEs for these variables. -DIE &DwarfCompileUnit::updateSubprogramScopeDIE(const MDSubprogram *SP) { +DIE &DwarfCompileUnit::updateSubprogramScopeDIE(const DISubprogram *SP) { DIE *SPDie = getOrCreateSubprogramDIE(SP, includeMinimalInlineScopes()); attachLowHighPC(*SPDie, Asm->getFunctionBegin(), Asm->getFunctionEnd()); @@ -308,7 +308,7 @@ void DwarfCompileUnit::constructScopeDIE( auto *DS = Scope->getScopeNode(); - assert((Scope->getInlinedAt() || !isa<MDSubprogram>(DS)) && + assert((Scope->getInlinedAt() || !isa<DISubprogram>(DS)) && "Only handle inlined subprograms here, use " "constructSubprogramScopeDIE for non-inlined " "subprograms"); @@ -319,7 +319,7 @@ void DwarfCompileUnit::constructScopeDIE( // avoid creating un-used children then removing them later when we find out // the scope DIE is null. std::unique_ptr<DIE> ScopeDIE; - if (Scope->getParent() && isa<MDSubprogram>(DS)) { + if (Scope->getParent() && isa<DISubprogram>(DS)) { ScopeDIE = constructInlinedScopeDIE(Scope); if (!ScopeDIE) return; @@ -341,7 +341,7 @@ void DwarfCompileUnit::constructScopeDIE( // There is no need to emit empty lexical block DIE. for (const auto &E : DD->findImportedEntitiesForScope(DS)) Children.push_back( - constructImportedEntityDIE(cast<MDImportedEntity>(E.second))); + constructImportedEntityDIE(cast<DIImportedEntity>(E.second))); } // If there are only other scopes as children, put them directly in the @@ -432,7 +432,7 @@ DwarfCompileUnit::constructInlinedScopeDIE(LexicalScope *Scope) { attachRangesOrLowHighPC(*ScopeDIE, Scope->getRanges()); // Add the call site information to the DIE. - const MDLocation *IA = Scope->getInlinedAt(); + const DILocation *IA = Scope->getInlinedAt(); addUInt(*ScopeDIE, dwarf::DW_AT_call_file, None, getOrCreateSourceID(IA->getFilename(), IA->getDirectory())); addUInt(*ScopeDIE, dwarf::DW_AT_call_line, None, IA->getLine()); @@ -563,14 +563,14 @@ void DwarfCompileUnit::constructSubprogramScopeDIE(LexicalScope *Scope) { assert(Scope && Scope->getScopeNode()); assert(!Scope->getInlinedAt()); assert(!Scope->isAbstractScope()); - auto *Sub = cast<MDSubprogram>(Scope->getScopeNode()); + auto *Sub = cast<DISubprogram>(Scope->getScopeNode()); DD->getProcessedSPNodes().insert(Sub); DIE &ScopeDIE = updateSubprogramScopeDIE(Sub); // If this is a variadic function, add an unspecified parameter. - MDTypeRefArray FnArgs = Sub->getType()->getTypeArray(); + DITypeRefArray FnArgs = Sub->getType()->getTypeArray(); // Collect lexical scope children first. // ObjectPointer might be a local (non-argument) local variable if it's a @@ -605,7 +605,7 @@ DwarfCompileUnit::constructAbstractSubprogramScopeDIE(LexicalScope *Scope) { if (AbsDef) return; - auto *SP = cast<MDSubprogram>(Scope->getScopeNode()); + auto *SP = cast<DISubprogram>(Scope->getScopeNode()); DIE *ContextDIE; @@ -633,18 +633,18 @@ DwarfCompileUnit::constructAbstractSubprogramScopeDIE(LexicalScope *Scope) { } std::unique_ptr<DIE> -DwarfCompileUnit::constructImportedEntityDIE(const MDImportedEntity *Module) { +DwarfCompileUnit::constructImportedEntityDIE(const DIImportedEntity *Module) { std::unique_ptr<DIE> IMDie = make_unique<DIE>((dwarf::Tag)Module->getTag()); insertDIE(Module, IMDie.get()); DIE *EntityDie; auto *Entity = resolve(Module->getEntity()); - if (auto *NS = dyn_cast<MDNamespace>(Entity)) + if (auto *NS = dyn_cast<DINamespace>(Entity)) EntityDie = getOrCreateNameSpace(NS); - else if (auto *SP = dyn_cast<MDSubprogram>(Entity)) + else if (auto *SP = dyn_cast<DISubprogram>(Entity)) EntityDie = getOrCreateSubprogramDIE(SP); - else if (auto *T = dyn_cast<MDType>(Entity)) + else if (auto *T = dyn_cast<DIType>(Entity)) EntityDie = getOrCreateTypeDIE(T); - else if (auto *GV = dyn_cast<MDGlobalVariable>(Entity)) + else if (auto *GV = dyn_cast<DIGlobalVariable>(Entity)) EntityDie = getOrCreateGlobalVariableDIE(GV); else EntityDie = getDIE(Entity); @@ -659,7 +659,7 @@ DwarfCompileUnit::constructImportedEntityDIE(const MDImportedEntity *Module) { return IMDie; } -void DwarfCompileUnit::finishSubprogramDefinition(const MDSubprogram *SP) { +void DwarfCompileUnit::finishSubprogramDefinition(const DISubprogram *SP) { DIE *D = getDIE(SP); if (DIE *AbsSPDIE = DU->getAbstractSPDies().lookup(SP)) { if (D) @@ -676,7 +676,7 @@ void DwarfCompileUnit::finishSubprogramDefinition(const MDSubprogram *SP) { applySubprogramAttributesToDefinition(SP, *D); } } -void DwarfCompileUnit::collectDeadVariables(const MDSubprogram *SP) { +void DwarfCompileUnit::collectDeadVariables(const DISubprogram *SP) { assert(SP && "CU's subprogram list contains a non-subprogram"); assert(SP->isDefinition() && "CU's subprogram list contains a subprogram declaration"); @@ -688,7 +688,7 @@ void DwarfCompileUnit::collectDeadVariables(const MDSubprogram *SP) { if (!SPDIE) SPDIE = getDIE(SP); assert(SPDIE); - for (const MDLocalVariable *DV : Variables) { + for (const DILocalVariable *DV : Variables) { DbgVariable NewVar(DV, /* IA */ nullptr, /* Expr */ nullptr, DD); auto VariableDie = constructVariableDIE(NewVar); applyVariableAttributes(NewVar, *VariableDie); @@ -708,7 +708,7 @@ void DwarfCompileUnit::emitHeader(bool UseOffsets) { /// addGlobalName - Add a new global name to the compile unit. void DwarfCompileUnit::addGlobalName(StringRef Name, DIE &Die, - const MDScope *Context) { + const DIScope *Context) { if (includeMinimalInlineScopes()) return; std::string FullName = getParentContextString(Context) + Name.str(); @@ -716,8 +716,8 @@ void DwarfCompileUnit::addGlobalName(StringRef Name, DIE &Die, } /// Add a new global type to the unit. -void DwarfCompileUnit::addGlobalType(const MDType *Ty, const DIE &Die, - const MDScope *Context) { +void DwarfCompileUnit::addGlobalType(const DIType *Ty, const DIE &Die, + const DIScope *Context) { if (includeMinimalInlineScopes()) return; std::string FullName = getParentContextString(Context) + Ty->getName().str(); @@ -764,7 +764,7 @@ void DwarfCompileUnit::addComplexAddress(const DbgVariable &DV, DIE &Die, DIELoc *Loc = new (DIEValueAllocator) DIELoc(); DIEDwarfExpression DwarfExpr(*Asm, *this, *Loc); assert(DV.getExpression().size() == 1); - const MDExpression *Expr = DV.getExpression().back(); + const DIExpression *Expr = DV.getExpression().back(); bool ValidReg; if (Location.getOffset()) { ValidReg = DwarfExpr.AddMachineRegIndirect(Location.getReg(), @@ -807,7 +807,7 @@ void DwarfCompileUnit::addExpr(DIELoc &Die, dwarf::Form Form, } void DwarfCompileUnit::applySubprogramAttributesToDefinition( - const MDSubprogram *SP, DIE &SPDie) { + const DISubprogram *SP, DIE &SPDie) { auto *SPDecl = SP->getDeclaration(); auto *Context = resolve(SPDecl ? SPDecl->getScope() : SP->getScope()); applySubprogramAttributes(SP, SPDie, includeMinimalInlineScopes()); diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h index 76811d9401c..50e4a54eb3e 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h @@ -66,7 +66,7 @@ class DwarfCompileUnit : public DwarfUnit { bool includeMinimalInlineScopes() const; public: - DwarfCompileUnit(unsigned UID, const MDCompileUnit *Node, AsmPrinter *A, + DwarfCompileUnit(unsigned UID, const DICompileUnit *Node, AsmPrinter *A, DwarfDebug *DW, DwarfFile *DWU); DwarfCompileUnit *getSkeleton() const { @@ -79,7 +79,7 @@ public: void applyStmtList(DIE &D); /// getOrCreateGlobalVariableDIE - get or create global variable DIE. - DIE *getOrCreateGlobalVariableDIE(const MDGlobalVariable *GV); + DIE *getOrCreateGlobalVariableDIE(const DIGlobalVariable *GV); /// addLabelAddress - Add a dwarf label attribute data and value using /// either DW_FORM_addr or DW_FORM_GNU_addr_index. @@ -113,7 +113,7 @@ public: /// DW_AT_low_pc and DW_AT_high_pc attributes. If there are global /// variables in this scope then create and insert DIEs for these /// variables. - DIE &updateSubprogramScopeDIE(const MDSubprogram *SP); + DIE &updateSubprogramScopeDIE(const DISubprogram *SP); void constructScopeDIE(LexicalScope *Scope, SmallVectorImpl<std::unique_ptr<DIE>> &FinalChildren); @@ -156,11 +156,11 @@ public: /// \brief Construct import_module DIE. std::unique_ptr<DIE> - constructImportedEntityDIE(const MDImportedEntity *Module); + constructImportedEntityDIE(const DIImportedEntity *Module); - void finishSubprogramDefinition(const MDSubprogram *SP); + void finishSubprogramDefinition(const DISubprogram *SP); - void collectDeadVariables(const MDSubprogram *SP); + void collectDeadVariables(const DISubprogram *SP); /// Set the skeleton unit associated with this unit. void setSkeleton(DwarfCompileUnit &Skel) { Skeleton = &Skel; } @@ -183,11 +183,11 @@ public: } /// Add a new global name to the compile unit. - void addGlobalName(StringRef Name, DIE &Die, const MDScope *Context) override; + void addGlobalName(StringRef Name, DIE &Die, const DIScope *Context) override; /// Add a new global type to the compile unit. - void addGlobalType(const MDType *Ty, const DIE &Die, - const MDScope *Context) override; + void addGlobalType(const DIType *Ty, const DIE &Die, + const DIScope *Context) override; const StringMap<const DIE *> &getGlobalNames() const { return GlobalNames; } const StringMap<const DIE *> &getGlobalTypes() const { return GlobalTypes; } @@ -215,7 +215,7 @@ public: /// Add a Dwarf expression attribute data and value. void addExpr(DIELoc &Die, dwarf::Form Form, const MCExpr *Expr); - void applySubprogramAttributesToDefinition(const MDSubprogram *SP, + void applySubprogramAttributesToDefinition(const DISubprogram *SP, DIE &SPDie); /// getRangeLists - Get the vector of range lists. diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 345eea67f7d..4f2b47f0e6f 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -130,7 +130,7 @@ bool DebugLocDwarfExpression::isFrameRegister(unsigned MachineReg) { /// resolve - Look in the DwarfDebug map for the MDNode that /// corresponds to the reference. -template <typename T> T *DbgVariable::resolve(TypedDebugNodeRef<T> Ref) const { +template <typename T> T *DbgVariable::resolve(TypedDINodeRef<T> Ref) const { return DD->resolve(Ref); } @@ -141,8 +141,8 @@ bool DbgVariable::isBlockByrefVariable() const { ->isBlockByrefStruct(); } -const MDType *DbgVariable::getType() const { - MDType *Ty = Var->getType().resolve(DD->getTypeIdentifierMap()); +const DIType *DbgVariable::getType() const { + DIType *Ty = Var->getType().resolve(DD->getTypeIdentifierMap()); // FIXME: isBlockByrefVariable should be reformulated in terms of complex // addresses instead. if (Ty->isBlockByrefStruct()) { @@ -170,15 +170,15 @@ const MDType *DbgVariable::getType() const { have a DW_AT_location that tells the debugger how to unwind through the pointers and __Block_byref_x_VarName struct to find the actual value of the variable. The function addBlockByrefType does this. */ - MDType *subType = Ty; + DIType *subType = Ty; uint16_t tag = Ty->getTag(); if (tag == dwarf::DW_TAG_pointer_type) - subType = resolve(cast<MDDerivedType>(Ty)->getBaseType()); + subType = resolve(cast<DIDerivedType>(Ty)->getBaseType()); - auto Elements = cast<MDCompositeTypeBase>(subType)->getElements(); + auto Elements = cast<DICompositeTypeBase>(subType)->getElements(); for (unsigned i = 0, N = Elements.size(); i < N; ++i) { - auto *DT = cast<MDDerivedTypeBase>(Elements[i]); + auto *DT = cast<DIDerivedTypeBase>(Elements[i]); if (getName() == DT->getName()) return resolve(DT->getBaseType()); } @@ -277,7 +277,7 @@ static StringRef getObjCMethodName(StringRef In) { // TODO: Determine whether or not we should add names for programs // that do not have a DW_AT_name or DW_AT_linkage_name field - this // is only slightly different than the lookup of non-standard ObjC names. -void DwarfDebug::addSubprogramNames(const MDSubprogram *SP, DIE &Die) { +void DwarfDebug::addSubprogramNames(const DISubprogram *SP, DIE &Die) { if (!SP->isDefinition()) return; addAccelName(SP->getName(), Die); @@ -305,9 +305,9 @@ void DwarfDebug::addSubprogramNames(const MDSubprogram *SP, DIE &Die) { bool DwarfDebug::isSubprogramContext(const MDNode *Context) { if (!Context) return false; - if (isa<MDSubprogram>(Context)) + if (isa<DISubprogram>(Context)) return true; - if (auto *T = dyn_cast<MDType>(Context)) + if (auto *T = dyn_cast<DIType>(Context)) return isSubprogramContext(resolve(T->getScope())); return false; } @@ -364,7 +364,7 @@ void DwarfDebug::addGnuPubAttributes(DwarfUnit &U, DIE &D) const { // Create new DwarfCompileUnit for the given metadata node with tag // DW_TAG_compile_unit. DwarfCompileUnit & -DwarfDebug::constructDwarfCompileUnit(const MDCompileUnit *DIUnit) { +DwarfDebug::constructDwarfCompileUnit(const DICompileUnit *DIUnit) { StringRef FN = DIUnit->getFilename(); CompilationDir = DIUnit->getDirectory(); @@ -422,7 +422,7 @@ DwarfDebug::constructDwarfCompileUnit(const MDCompileUnit *DIUnit) { } void DwarfDebug::constructAndAddImportedEntityDIE(DwarfCompileUnit &TheCU, - const MDImportedEntity *N) { + const DIImportedEntity *N) { if (DIE *D = TheCU.getOrCreateContextDIE(N->getScope())) D->addChild(TheCU.constructImportedEntityDIE(N)); } @@ -446,7 +446,7 @@ void DwarfDebug::beginModule() { SingleCU = CU_Nodes->getNumOperands() == 1; for (MDNode *N : CU_Nodes->operands()) { - auto *CUNode = cast<MDCompileUnit>(N); + auto *CUNode = cast<DICompileUnit>(N); DwarfCompileUnit &CU = constructDwarfCompileUnit(CUNode); for (auto *IE : CUNode->getImportedEntities()) ScopesWithImportedEntities.push_back(std::make_pair(IE->getScope(), IE)); @@ -462,12 +462,12 @@ void DwarfDebug::beginModule() { for (auto *Ty : CUNode->getEnumTypes()) { // The enum types array by design contains pointers to // MDNodes rather than DIRefs. Unique them here. - CU.getOrCreateTypeDIE(cast<MDType>(resolve(Ty->getRef()))); + CU.getOrCreateTypeDIE(cast<DIType>(resolve(Ty->getRef()))); } for (auto *Ty : CUNode->getRetainedTypes()) { // The retained types array by design contains pointers to // MDNodes rather than DIRefs. Unique them here. - CU.getOrCreateTypeDIE(cast<MDType>(resolve(Ty->getRef()))); + CU.getOrCreateTypeDIE(cast<DIType>(resolve(Ty->getRef()))); } // Emit imported_modules last so that the relevant context is already // available. @@ -501,7 +501,7 @@ void DwarfDebug::finishVariableDefinitions() { void DwarfDebug::finishSubprogramDefinitions() { for (const auto &P : SPMap) forBothCUs(*P.second, [&](DwarfCompileUnit &CU) { - CU.finishSubprogramDefinition(cast<MDSubprogram>(P.first)); + CU.finishSubprogramDefinition(cast<DISubprogram>(P.first)); }); } @@ -512,7 +512,7 @@ void DwarfDebug::collectDeadVariables() { if (NamedMDNode *CU_Nodes = M->getNamedMetadata("llvm.dbg.cu")) { for (MDNode *N : CU_Nodes->operands()) { - auto *TheCU = cast<MDCompileUnit>(N); + auto *TheCU = cast<DICompileUnit>(N); // Construct subprogram DIE and add variables DIEs. DwarfCompileUnit *SPCU = static_cast<DwarfCompileUnit *>(CUMap.lookup(TheCU)); @@ -662,7 +662,7 @@ void DwarfDebug::endModule() { // Find abstract variable, if any, associated with Var. DbgVariable * DwarfDebug::getExistingAbstractVariable(InlinedVariable IV, - const MDLocalVariable *&Cleansed) { + const DILocalVariable *&Cleansed) { // More then one inlined variable corresponds to one abstract variable. Cleansed = IV.first; auto I = AbstractVariables.find(Cleansed); @@ -672,11 +672,11 @@ DwarfDebug::getExistingAbstractVariable(InlinedVariable IV, } DbgVariable *DwarfDebug::getExistingAbstractVariable(InlinedVariable IV) { - const MDLocalVariable *Cleansed; + const DILocalVariable *Cleansed; return getExistingAbstractVariable(IV, Cleansed); } -void DwarfDebug::createAbstractVariable(const MDLocalVariable *Var, +void DwarfDebug::createAbstractVariable(const DILocalVariable *Var, LexicalScope *Scope) { auto AbsDbgVariable = make_unique<DbgVariable>(Var, /* IA */ nullptr, /* Expr */ nullptr, this); @@ -686,22 +686,22 @@ void DwarfDebug::createAbstractVariable(const MDLocalVariable *Var, void DwarfDebug::ensureAbstractVariableIsCreated(InlinedVariable IV, const MDNode *ScopeNode) { - const MDLocalVariable *Cleansed = nullptr; + const DILocalVariable *Cleansed = nullptr; if (getExistingAbstractVariable(IV, Cleansed)) return; createAbstractVariable(Cleansed, LScopes.getOrCreateAbstractScope( - cast<MDLocalScope>(ScopeNode))); + cast<DILocalScope>(ScopeNode))); } void DwarfDebug::ensureAbstractVariableIsCreatedIfScoped( InlinedVariable IV, const MDNode *ScopeNode) { - const MDLocalVariable *Cleansed = nullptr; + const DILocalVariable *Cleansed = nullptr; if (getExistingAbstractVariable(IV, Cleansed)) return; if (LexicalScope *Scope = - LScopes.findAbstractScope(cast_or_null<MDLocalScope>(ScopeNode))) + LScopes.findAbstractScope(cast_or_null<DILocalScope>(ScopeNode))) createAbstractVariable(Cleansed, Scope); } @@ -722,7 +722,7 @@ void DwarfDebug::collectVariableInfoFromMMITable( if (!Scope) continue; - const MDExpression *Expr = cast_or_null<MDExpression>(VI.Expr); + const DIExpression *Expr = cast_or_null<DIExpression>(VI.Expr); ensureAbstractVariableIsCreatedIfScoped(Var, Scope->getScopeNode()); auto RegVar = make_unique<DbgVariable>(Var.first, Var.second, Expr, this, VI.Slot); @@ -733,7 +733,7 @@ void DwarfDebug::collectVariableInfoFromMMITable( // Get .debug_loc entry for the instruction range starting at MI. static DebugLocEntry::Value getDebugLocValue(const MachineInstr *MI) { - const MDExpression *Expr = MI->getDebugExpression(); + const DIExpression *Expr = MI->getDebugExpression(); assert(MI->getNumOperands() == 4); if (MI->getOperand(0).isReg()) { @@ -757,7 +757,7 @@ static DebugLocEntry::Value getDebugLocValue(const MachineInstr *MI) { } /// Determine whether two variable pieces overlap. -static bool piecesOverlap(const MDExpression *P1, const MDExpression *P2) { +static bool piecesOverlap(const DIExpression *P1, const DIExpression *P2) { if (!P1->isBitPiece() || !P2->isBitPiece()) return true; unsigned l1 = P1->getBitPieceOffset(); @@ -809,7 +809,7 @@ DwarfDebug::buildLocationList(SmallVectorImpl<DebugLocEntry> &DebugLoc, } // If this piece overlaps with any open ranges, truncate them. - const MDExpression *DIExpr = Begin->getDebugExpression(); + const DIExpression *DIExpr = Begin->getDebugExpression(); auto Last = std::remove_if(OpenRanges.begin(), OpenRanges.end(), [&](DebugLocEntry::Value R) { return piecesOverlap(DIExpr, R.getExpression()); @@ -874,7 +874,7 @@ DwarfDebug::buildLocationList(SmallVectorImpl<DebugLocEntry> &DebugLoc, // Find variables for each lexical scope. void DwarfDebug::collectVariableInfo(DwarfCompileUnit &TheCU, - const MDSubprogram *SP, + const DISubprogram *SP, DenseSet<InlinedVariable> &Processed) { // Grab the variable info that was squirreled away in the MMI side-table. collectVariableInfoFromMMITable(Processed); @@ -890,7 +890,7 @@ void DwarfDebug::collectVariableInfo(DwarfCompileUnit &TheCU, continue; LexicalScope *Scope = nullptr; - if (const MDLocation *IA = IV.second) + if (const DILocation *IA = IV.second) Scope = LScopes.findInlinedScope(IV.first->getScope(), IA); else Scope = LScopes.findLexicalScope(IV.first->getScope()); @@ -918,10 +918,10 @@ void DwarfDebug::collectVariableInfo(DwarfCompileUnit &TheCU, SmallVector<DebugLocEntry, 8> Entries; buildLocationList(Entries, Ranges); - // If the variable has an MDBasicType, extract it. Basic types cannot have + // If the variable has an DIBasicType, extract it. Basic types cannot have // unique identifiers, so don't bother resolving the type with the // identifier map. - const MDBasicType *BT = dyn_cast<MDBasicType>( + const DIBasicType *BT = dyn_cast<DIBasicType>( static_cast<const Metadata *>(IV.first->getType())); // Finalize the entry by lowering it into a DWARF bytestream. @@ -930,7 +930,7 @@ void DwarfDebug::collectVariableInfo(DwarfCompileUnit &TheCU, } // Collect info for variables that were optimized out. - for (const MDLocalVariable *DV : SP->getVariables()) { + for (const DILocalVariable *DV : SP->getVariables()) { if (!Processed.insert(InlinedVariable(DV, nullptr)).second) continue; if (LexicalScope *Scope = LScopes.findLexicalScope(DV->getScope())) { @@ -1128,14 +1128,14 @@ void DwarfDebug::beginFunction(const MachineFunction *MF) { // The first mention of a function argument gets the CurrentFnBegin // label, so arguments are visible when breaking at function entry. - const MDLocalVariable *DIVar = Ranges.front().first->getDebugVariable(); + const DILocalVariable *DIVar = Ranges.front().first->getDebugVariable(); if (DIVar->getTag() == dwarf::DW_TAG_arg_variable && getDISubprogram(DIVar->getScope())->describes(MF->getFunction())) { LabelsBeforeInsn[Ranges.front().first] = Asm->getFunctionBegin(); if (Ranges.front().first->getDebugExpression()->isBitPiece()) { // Mark all non-overlapping initial pieces. for (auto I = Ranges.begin(); I != Ranges.end(); ++I) { - const MDExpression *Piece = I->first->getDebugExpression(); + const DIExpression *Piece = I->first->getDebugExpression(); if (std::all_of(Ranges.begin(), I, [&](DbgValueHistoryMap::InstrRange Pred) { return !piecesOverlap(Piece, Pred.first->getDebugExpression()); @@ -1159,7 +1159,7 @@ void DwarfDebug::beginFunction(const MachineFunction *MF) { // Record beginning of function. PrologEndLoc = findPrologueEndLoc(MF); - if (MDLocation *L = PrologEndLoc) { + if (DILocation *L = PrologEndLoc) { // We'd like to list the prologue as "not statements" but GDB behaves // poorly if we do that. Revisit this with caution/GDB (7.5+) testing. auto *SP = L->getInlinedAtScope()->getSubprogram(); @@ -1186,7 +1186,7 @@ void DwarfDebug::endFunction(const MachineFunction *MF) { Asm->OutStreamer->getContext().setDwarfCompileUnitID(0); LexicalScope *FnScope = LScopes.getCurrentFunctionScope(); - auto *SP = cast<MDSubprogram>(FnScope->getScopeNode()); + auto *SP = cast<DISubprogram>(FnScope->getScopeNode()); DwarfCompileUnit &TheCU = *SPMap.lookup(SP); DenseSet<InlinedVariable> ProcessedVars; @@ -1216,9 +1216,9 @@ void DwarfDebug::endFunction(const MachineFunction *MF) { #endif // Construct abstract scopes. for (LexicalScope *AScope : LScopes.getAbstractScopesList()) { - auto *SP = cast<MDSubprogram>(AScope->getScopeNode()); + auto *SP = cast<DISubprogram>(AScope->getScopeNode()); // Collect info for variables that were optimized out. - for (const MDLocalVariable *DV : SP->getVariables()) { + for (const DILocalVariable *DV : SP->getVariables()) { if (!ProcessedVars.insert(InlinedVariable(DV, nullptr)).second) continue; ensureAbstractVariableIsCreated(InlinedVariable(DV, nullptr), @@ -1254,10 +1254,10 @@ void DwarfDebug::recordSourceLine(unsigned Line, unsigned Col, const MDNode *S, StringRef Dir; unsigned Src = 1; unsigned Discriminator = 0; - if (auto *Scope = cast_or_null<MDScope>(S)) { + if (auto *Scope = cast_or_null<DIScope>(S)) { Fn = Scope->getFilename(); Dir = Scope->getDirectory(); - if (auto *LBF = dyn_cast<MDLexicalBlockFile>(Scope)) + if (auto *LBF = dyn_cast<DILexicalBlockFile>(Scope)) Discriminator = LBF->getDiscriminator(); unsigned CUID = Asm->OutStreamer->getContext().getDwarfCompileUnitID(); @@ -1471,7 +1471,7 @@ void DwarfDebug::emitDebugLocEntry(ByteStreamer &Streamer, Streamer.EmitInt8(Byte, Comment != End ? *(Comment++) : ""); } -static void emitDebugLocValue(const AsmPrinter &AP, const MDBasicType *BT, +static void emitDebugLocValue(const AsmPrinter &AP, const DIBasicType *BT, ByteStreamer &Streamer, const DebugLocEntry::Value &Value, unsigned PieceOffsetInBits) { @@ -1487,7 +1487,7 @@ static void emitDebugLocValue(const AsmPrinter &AP, const MDBasicType *BT, DwarfExpr.AddUnsignedConstant(Value.getInt()); } else if (Value.isLocation()) { MachineLocation Loc = Value.getLoc(); - const MDExpression *Expr = Value.getExpression(); + const DIExpression *Expr = Value.getExpression(); if (!Expr || !Expr->getNumElements()) // Regular entry. AP.EmitDwarfRegOp(Streamer, Loc); @@ -1508,7 +1508,7 @@ static void emitDebugLocValue(const AsmPrinter &AP, const MDBasicType *BT, } void DebugLocEntry::finalize(const AsmPrinter &AP, DebugLocStream &Locs, - const MDBasicType *BT) { + const DIBasicType *BT) { Locs.startEntry(Begin, End); BufferByteStreamer Streamer = Locs.getStreamer(); const DebugLocEntry::Value &Value = Values[0]; @@ -1522,7 +1522,7 @@ void DebugLocEntry::finalize(const AsmPrinter &AP, DebugLocStream &Locs, unsigned Offset = 0; for (auto Piece : Values) { - const MDExpression *Expr = Piece.getExpression(); + const DIExpression *Expr = Piece.getExpression(); unsigned PieceOffset = Expr->getBitPieceOffset(); unsigned PieceSize = Expr->getBitPieceSize(); assert(Offset <= PieceOffset && "overlapping or duplicate pieces"); @@ -1903,7 +1903,7 @@ static uint64_t makeTypeSignature(StringRef Identifier) { void DwarfDebug::addDwarfTypeUnitType(DwarfCompileUnit &CU, StringRef Identifier, DIE &RefDie, - const MDCompositeType *CTy) { + const DICompositeType *CTy) { // Fast path if we're building some type units and one has already used the // address pool we know we're going to throw away all this work anyway, so // don't bother building dependent types. @@ -1962,7 +1962,7 @@ void DwarfDebug::addDwarfTypeUnitType(DwarfCompileUnit &CU, // This is inefficient because all the dependent types will be rebuilt // from scratch, including building them in type units, discovering that // they depend on addresses, throwing them out and rebuilding them. - CU.constructTypeDIE(RefDie, cast<MDCompositeType>(CTy)); + CU.constructTypeDIE(RefDie, cast<DICompositeType>(CTy)); return; } diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h index 708fb8f01e5..59024a78a7c 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h @@ -75,9 +75,9 @@ public: /// - Variables that are described by multiple MMI table entries have multiple /// expressions and frame indices. class DbgVariable { - const MDLocalVariable *Var; /// Variable Descriptor. - const MDLocation *IA; /// Inlined at location. - SmallVector<const MDExpression *, 1> + const DILocalVariable *Var; /// Variable Descriptor. + const DILocation *IA; /// Inlined at location. + SmallVector<const DIExpression *, 1> Expr; /// Complex address location expression. DIE *TheDIE; /// Variable DIE. unsigned DebugLocListIndex; /// Offset in DebugLocs. @@ -87,8 +87,8 @@ class DbgVariable { public: /// Construct a DbgVariable from a variable. - DbgVariable(const MDLocalVariable *V, const MDLocation *IA, - const MDExpression *E, DwarfDebug *DD, int FI = ~0) + DbgVariable(const DILocalVariable *V, const DILocation *IA, + const DIExpression *E, DwarfDebug *DD, int FI = ~0) : Var(V), IA(IA), Expr(1, E), TheDIE(nullptr), DebugLocListIndex(~0U), MInsn(nullptr), DD(DD) { FrameIndex.push_back(FI); @@ -106,9 +106,9 @@ public: } // Accessors. - const MDLocalVariable *getVariable() const { return Var; } - const MDLocation *getInlinedAt() const { return IA; } - const ArrayRef<const MDExpression *> getExpression() const { return Expr; } + const DILocalVariable *getVariable() const { return Var; } + const DILocation *getInlinedAt() const { return IA; } + const ArrayRef<const DIExpression *> getExpression() const { return Expr; } void setDIE(DIE &D) { TheDIE = &D; } DIE *getDIE() const { return TheDIE; } void setDebugLocListIndex(unsigned O) { DebugLocListIndex = O; } @@ -130,7 +130,7 @@ public: FrameIndex.append(FI.begin(), FI.end()); } assert(Expr.size() > 1 ? std::all_of(Expr.begin(), Expr.end(), - [](const MDExpression *E) { + [](const DIExpression *E) { return E->isBitPiece(); }) : (true && "conflicting locations for variable")); @@ -167,12 +167,12 @@ public: return Expr.back()->getNumElements() > 0; } bool isBlockByrefVariable() const; - const MDType *getType() const; + const DIType *getType() const; private: /// resolve - Look in the DwarfDebug map for the MDNode that /// corresponds to the reference. - template <typename T> T *resolve(TypedDebugNodeRef<T> Ref) const; + template <typename T> T *resolve(TypedDINodeRef<T> Ref) const; }; @@ -271,7 +271,7 @@ class DwarfDebug : public AsmPrinterHandler { DenseMap<const MDNode *, const DwarfTypeUnit *> DwarfTypeUnits; SmallVector< - std::pair<std::unique_ptr<DwarfTypeUnit>, const MDCompositeType *>, 1> + std::pair<std::unique_ptr<DwarfTypeUnit>, const DICompositeType *>, 1> TypeUnitsUnderConstruction; // Whether to emit the pubnames/pubtypes sections. @@ -324,7 +324,7 @@ class DwarfDebug : public AsmPrinterHandler { DwarfAccelTable AccelNamespace; DwarfAccelTable AccelTypes; - DenseMap<const Function *, MDSubprogram *> FunctionDIs; + DenseMap<const Function *, DISubprogram *> FunctionDIs; MCDwarfDwoLineTable *getDwoLineTable(const DwarfCompileUnit &); @@ -336,9 +336,9 @@ class DwarfDebug : public AsmPrinterHandler { /// \brief Find abstract variable associated with Var. DbgVariable *getExistingAbstractVariable(InlinedVariable IV, - const MDLocalVariable *&Cleansed); + const DILocalVariable *&Cleansed); DbgVariable *getExistingAbstractVariable(InlinedVariable IV); - void createAbstractVariable(const MDLocalVariable *DV, LexicalScope *Scope); + void createAbstractVariable(const DILocalVariable *DV, LexicalScope *Scope); void ensureAbstractVariableIsCreated(InlinedVariable Var, const MDNode *Scope); void ensureAbstractVariableIsCreatedIfScoped(InlinedVariable Var, @@ -453,11 +453,11 @@ class DwarfDebug : public AsmPrinterHandler { /// \brief Create new DwarfCompileUnit for the given metadata node with tag /// DW_TAG_compile_unit. - DwarfCompileUnit &constructDwarfCompileUnit(const MDCompileUnit *DIUnit); + DwarfCompileUnit &constructDwarfCompileUnit(const DICompileUnit *DIUnit); /// \brief Construct imported_module or imported_declaration DIE. void constructAndAddImportedEntityDIE(DwarfCompileUnit &TheCU, - const MDImportedEntity *N); + const DIImportedEntity *N); /// \brief Register a source line with debug info. Returns the unique /// label that was emitted and which provides correspondence to the @@ -470,7 +470,7 @@ class DwarfDebug : public AsmPrinterHandler { void identifyScopeMarkers(); /// \brief Populate LexicalScope entries with variables' info. - void collectVariableInfo(DwarfCompileUnit &TheCU, const MDSubprogram *SP, + void collectVariableInfo(DwarfCompileUnit &TheCU, const DISubprogram *SP, DenseSet<InlinedVariable> &ProcessedVars); /// \brief Build the location list for all DBG_VALUEs in the @@ -522,7 +522,7 @@ public: /// \brief Add a DIE to the set of types that we're going to pull into /// type units. void addDwarfTypeUnitType(DwarfCompileUnit &CU, StringRef Identifier, - DIE &Die, const MDCompositeType *CTy); + DIE &Die, const DICompositeType *CTy); /// \brief Add a label so that arange data can be generated for it. void addArangeLabel(SymbolCU SCU) { ArangeLabels.push_back(SCU); } @@ -566,7 +566,7 @@ public: void emitDebugLocEntryLocation(const DebugLocStream::Entry &Entry); /// Find the MDNode for the given reference. - template <typename T> T *resolve(TypedDebugNodeRef<T> Ref) const { + template <typename T> T *resolve(TypedDINodeRef<T> Ref) const { return Ref.resolve(TypeIdentifierMap); } @@ -583,7 +583,7 @@ public: /// or another context nested inside a subprogram. bool isSubprogramContext(const MDNode *Context); - void addSubprogramNames(const MDSubprogram *SP, DIE &Die); + void addSubprogramNames(const DISubprogram *SP, DIE &Die); AddressPool &getAddressPool() { return AddrPool; } diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp index fbe209a6663..a2799b8d630 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp @@ -192,7 +192,7 @@ static unsigned getOffsetOrZero(unsigned OffsetInBits, return OffsetInBits; } -bool DwarfExpression::AddMachineRegExpression(const MDExpression *Expr, +bool DwarfExpression::AddMachineRegExpression(const DIExpression *Expr, unsigned MachineReg, unsigned PieceOffsetInBits) { auto I = Expr->expr_op_begin(); @@ -240,8 +240,8 @@ bool DwarfExpression::AddMachineRegExpression(const MDExpression *Expr, return true; } -void DwarfExpression::AddExpression(MDExpression::expr_op_iterator I, - MDExpression::expr_op_iterator E, +void DwarfExpression::AddExpression(DIExpression::expr_op_iterator I, + DIExpression::expr_op_iterator E, unsigned PieceOffsetInBits) { for (; I != E; ++I) { switch (I->getOp()) { diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h b/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h index 3b77a44c28a..78ec937a6b6 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h @@ -93,13 +93,13 @@ public: /// \param PieceOffsetInBits If this is one piece out of a fragmented /// location, this is the offset of the piece inside the entire variable. /// \return false if no DWARF register exists for MachineReg. - bool AddMachineRegExpression(const MDExpression *Expr, unsigned MachineReg, + bool AddMachineRegExpression(const DIExpression *Expr, unsigned MachineReg, unsigned PieceOffsetInBits = 0); /// Emit a the operations remaining the DIExpressionIterator I. /// \param PieceOffsetInBits If this is one piece out of a fragmented /// location, this is the offset of the piece inside the entire variable. - void AddExpression(MDExpression::expr_op_iterator I, - MDExpression::expr_op_iterator E, + void AddExpression(DIExpression::expr_op_iterator I, + DIExpression::expr_op_iterator E, unsigned PieceOffsetInBits = 0); }; diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp index 50dbb41c07c..1d6298c228a 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp @@ -137,7 +137,7 @@ void DwarfFile::emitStrings(const MCSection *StrSection, bool DwarfFile::addScopeVariable(LexicalScope *LS, DbgVariable *Var) { SmallVectorImpl<DbgVariable *> &Vars = ScopeVariables[LS]; - const MDLocalVariable *DV = Var->getVariable(); + const DILocalVariable *DV = Var->getVariable(); // Variables with positive arg numbers are parameters. if (unsigned ArgNum = DV->getArg()) { // Keep all parameters in order at the start of the variable list to ensure diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfFile.h b/llvm/lib/CodeGen/AsmPrinter/DwarfFile.h index 19bb3471b08..a3a5e99e3a8 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfFile.h +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfFile.h @@ -56,7 +56,7 @@ class DwarfFile { /// Maps MDNodes for type system with the corresponding DIEs. These DIEs can /// be shared across CUs, that is why we keep the map here instead /// of in DwarfCompileUnit. - DenseMap<const MDNode *, DIE *> MDTypeNodeToDieMap; + DenseMap<const MDNode *, DIE *> DITypeNodeToDieMap; public: DwarfFile(AsmPrinter *AP, StringRef Pref, BumpPtrAllocator &DA); @@ -103,10 +103,10 @@ public: } void insertDIE(const MDNode *TypeMD, DIE *Die) { - MDTypeNodeToDieMap.insert(std::make_pair(TypeMD, Die)); + DITypeNodeToDieMap.insert(std::make_pair(TypeMD, Die)); } DIE *getDIE(const MDNode *TypeMD) { - return MDTypeNodeToDieMap.lookup(TypeMD); + return DITypeNodeToDieMap.lookup(TypeMD); } }; } diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp index b721077594c..ee233f710f2 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp @@ -64,7 +64,7 @@ bool DIEDwarfExpression::isFrameRegister(unsigned MachineReg) { } DwarfUnit::DwarfUnit(unsigned UID, dwarf::Tag UnitTag, - const MDCompileUnit *Node, AsmPrinter *A, DwarfDebug *DW, + const DICompileUnit *Node, AsmPrinter *A, DwarfDebug *DW, DwarfFile *DWU) : UniqueID(UID), CUNode(Node), UnitDie(UnitTag), DebugInfoOffset(0), Asm(A), DD(DW), DU(DWU), IndexTyDie(nullptr), Section(nullptr) { @@ -161,7 +161,7 @@ int64_t DwarfUnit::getDefaultLowerBound() const { } /// Check whether the DIE for this MDNode can be shared across CUs. -static bool isShareableAcrossCUs(const DebugNode *D) { +static bool isShareableAcrossCUs(const DINode *D) { // When the MDNode can be part of the type system, the DIE can be shared // across CUs. // Combining type units and cross-CU DIE sharing is lower value (since @@ -169,18 +169,18 @@ static bool isShareableAcrossCUs(const DebugNode *D) { // level already) but may be implementable for some value in projects // building multiple independent libraries with LTO and then linking those // together. - return (isa<MDType>(D) || - (isa<MDSubprogram>(D) && !cast<MDSubprogram>(D)->isDefinition())) && + return (isa<DIType>(D) || + (isa<DISubprogram>(D) && !cast<DISubprogram>(D)->isDefinition())) && !GenerateDwarfTypeUnits; } -DIE *DwarfUnit::getDIE(const DebugNode *D) const { +DIE *DwarfUnit::getDIE(const DINode *D) const { if (isShareableAcrossCUs(D)) return DU->getDIE(D); return MDNodeToDieMap.lookup(D); } -void DwarfUnit::insertDIE(const DebugNode *Desc, DIE *D) { +void DwarfUnit::insertDIE(const DINode *Desc, DIE *D) { if (isShareableAcrossCUs(Desc)) { DU->insertDIE(Desc, D); return; @@ -320,7 +320,7 @@ void DwarfUnit::addDIEEntry(DIE &Die, dwarf::Attribute Attribute, Entry); } -DIE &DwarfUnit::createAndAddDIE(unsigned Tag, DIE &Parent, const DebugNode *N) { +DIE &DwarfUnit::createAndAddDIE(unsigned Tag, DIE &Parent, const DINode *N) { assert(Tag != dwarf::DW_TAG_auto_variable && Tag != dwarf::DW_TAG_arg_variable); Parent.addChild(make_unique<DIE>((dwarf::Tag)Tag)); @@ -354,38 +354,38 @@ void DwarfUnit::addSourceLine(DIE &Die, unsigned Line, StringRef File, addUInt(Die, dwarf::DW_AT_decl_line, None, Line); } -void DwarfUnit::addSourceLine(DIE &Die, const MDLocalVariable *V) { +void DwarfUnit::addSourceLine(DIE &Die, const DILocalVariable *V) { assert(V); addSourceLine(Die, V->getLine(), V->getScope()->getFilename(), V->getScope()->getDirectory()); } -void DwarfUnit::addSourceLine(DIE &Die, const MDGlobalVariable *G) { +void DwarfUnit::addSourceLine(DIE &Die, const DIGlobalVariable *G) { assert(G); addSourceLine(Die, G->getLine(), G->getFilename(), G->getDirectory()); } -void DwarfUnit::addSourceLine(DIE &Die, const MDSubprogram *SP) { +void DwarfUnit::addSourceLine(DIE &Die, const DISubprogram *SP) { assert(SP); addSourceLine(Die, SP->getLine(), SP->getFilename(), SP->getDirectory()); } -void DwarfUnit::addSourceLine(DIE &Die, const MDType *Ty) { +void DwarfUnit::addSourceLine(DIE &Die, const DIType *Ty) { assert(Ty); addSourceLine(Die, Ty->getLine(), Ty->getFilename(), Ty->getDirectory()); } -void DwarfUnit::addSourceLine(DIE &Die, const MDObjCProperty *Ty) { +void DwarfUnit::addSourceLine(DIE &Die, const DIObjCProperty *Ty) { assert(Ty); addSourceLine(Die, Ty->getLine(), Ty->getFilename(), Ty->getDirectory()); } -void DwarfUnit::addSourceLine(DIE &Die, const MDNamespace *NS) { +void DwarfUnit::addSourceLine(DIE &Die, const DINamespace *NS) { addSourceLine(Die, NS->getLine(), NS->getFilename(), NS->getDirectory()); } @@ -459,27 +459,27 @@ bool DwarfUnit::addRegisterOffset(DIELoc &TheDie, unsigned Reg, void DwarfUnit::addBlockByrefAddress(const DbgVariable &DV, DIE &Die, dwarf::Attribute Attribute, const MachineLocation &Location) { - const MDType *Ty = DV.getType(); - const MDType *TmpTy = Ty; + const DIType *Ty = DV.getType(); + const DIType *TmpTy = Ty; uint16_t Tag = Ty->getTag(); bool isPointer = false; StringRef varName = DV.getName(); if (Tag == dwarf::DW_TAG_pointer_type) { - auto *DTy = cast<MDDerivedType>(Ty); + auto *DTy = cast<DIDerivedType>(Ty); TmpTy = resolve(DTy->getBaseType()); isPointer = true; } // Find the __forwarding field and the variable field in the __Block_byref // struct. - DebugNodeArray Fields = cast<MDCompositeTypeBase>(TmpTy)->getElements(); - const MDDerivedType *varField = nullptr; - const MDDerivedType *forwardingField = nullptr; + DINodeArray Fields = cast<DICompositeTypeBase>(TmpTy)->getElements(); + const DIDerivedType *varField = nullptr; + const DIDerivedType *forwardingField = nullptr; for (unsigned i = 0, N = Fields.size(); i < N; ++i) { - auto *DT = cast<MDDerivedType>(Fields[i]); + auto *DT = cast<DIDerivedType>(Fields[i]); StringRef fieldName = DT->getName(); if (fieldName == "__forwarding") forwardingField = DT; @@ -534,8 +534,8 @@ void DwarfUnit::addBlockByrefAddress(const DbgVariable &DV, DIE &Die, } /// Return true if type encoding is unsigned. -static bool isUnsignedDIType(DwarfDebug *DD, const MDType *Ty) { - if (auto *DTy = dyn_cast<MDDerivedTypeBase>(Ty)) { +static bool isUnsignedDIType(DwarfDebug *DD, const DIType *Ty) { + if (auto *DTy = dyn_cast<DIDerivedTypeBase>(Ty)) { dwarf::Tag T = (dwarf::Tag)Ty->getTag(); // Encode pointer constants as unsigned bytes. This is used at least for // null pointer constant emission. @@ -557,7 +557,7 @@ static bool isUnsignedDIType(DwarfDebug *DD, const MDType *Ty) { T == dwarf::DW_TAG_volatile_type || T == dwarf::DW_TAG_restrict_type || T == dwarf::DW_TAG_enumeration_type); - if (MDTypeRef Deriv = DTy->getBaseType()) + if (DITypeRef Deriv = DTy->getBaseType()) return isUnsignedDIType(DD, DD->resolve(Deriv)); // FIXME: Enums without a fixed underlying type have unknown signedness // here, leading to incorrectly emitted constants. @@ -565,7 +565,7 @@ static bool isUnsignedDIType(DwarfDebug *DD, const MDType *Ty) { return false; } - auto *BTy = cast<MDBasicType>(Ty); + auto *BTy = cast<DIBasicType>(Ty); unsigned Encoding = BTy->getEncoding(); assert((Encoding == dwarf::DW_ATE_unsigned || Encoding == dwarf::DW_ATE_unsigned_char || @@ -583,7 +583,7 @@ static bool isUnsignedDIType(DwarfDebug *DD, const MDType *Ty) { } /// If this type is derived from a base type then return base type size. -static uint64_t getBaseTypeSize(DwarfDebug *DD, const MDDerivedType *Ty) { +static uint64_t getBaseTypeSize(DwarfDebug *DD, const DIDerivedType *Ty) { unsigned Tag = Ty->getTag(); if (Tag != dwarf::DW_TAG_member && Tag != dwarf::DW_TAG_typedef && @@ -602,7 +602,7 @@ static uint64_t getBaseTypeSize(DwarfDebug *DD, const MDDerivedType *Ty) { BaseType->getTag() == dwarf::DW_TAG_rvalue_reference_type) return Ty->getSizeInBits(); - if (auto *DT = dyn_cast<MDDerivedType>(BaseType)) + if (auto *DT = dyn_cast<DIDerivedType>(BaseType)) return getBaseTypeSize(DD, DT); return BaseType->getSizeInBits(); @@ -636,12 +636,12 @@ void DwarfUnit::addConstantFPValue(DIE &Die, const ConstantFP *CFP) { } void DwarfUnit::addConstantValue(DIE &Die, const ConstantInt *CI, - const MDType *Ty) { + const DIType *Ty) { addConstantValue(Die, CI->getValue(), Ty); } void DwarfUnit::addConstantValue(DIE &Die, const MachineOperand &MO, - const MDType *Ty) { + const DIType *Ty) { assert(MO.isImm() && "Invalid machine operand!"); addConstantValue(Die, isUnsignedDIType(DD, Ty), MO.getImm()); @@ -654,7 +654,7 @@ void DwarfUnit::addConstantValue(DIE &Die, bool Unsigned, uint64_t Val) { Unsigned ? dwarf::DW_FORM_udata : dwarf::DW_FORM_sdata, Val); } -void DwarfUnit::addConstantValue(DIE &Die, const APInt &Val, const MDType *Ty) { +void DwarfUnit::addConstantValue(DIE &Die, const APInt &Val, const DIType *Ty) { addConstantValue(Die, Val, isUnsignedDIType(DD, Ty)); } @@ -695,29 +695,29 @@ void DwarfUnit::addLinkageName(DIE &Die, StringRef LinkageName) { GlobalValue::getRealLinkageName(LinkageName)); } -void DwarfUnit::addTemplateParams(DIE &Buffer, DebugNodeArray TParams) { +void DwarfUnit::addTemplateParams(DIE &Buffer, DINodeArray TParams) { // Add template parameters. for (const auto *Element : TParams) { - if (auto *TTP = dyn_cast<MDTemplateTypeParameter>(Element)) + if (auto *TTP = dyn_cast<DITemplateTypeParameter>(Element)) constructTemplateTypeParameterDIE(Buffer, TTP); - else if (auto *TVP = dyn_cast<MDTemplateValueParameter>(Element)) + else if (auto *TVP = dyn_cast<DITemplateValueParameter>(Element)) constructTemplateValueParameterDIE(Buffer, TVP); } } -DIE *DwarfUnit::getOrCreateContextDIE(const MDScope *Context) { - if (!Context || isa<MDFile>(Context)) +DIE *DwarfUnit::getOrCreateContextDIE(const DIScope *Context) { + if (!Context || isa<DIFile>(Context)) return &getUnitDie(); - if (auto *T = dyn_cast<MDType>(Context)) + if (auto *T = dyn_cast<DIType>(Context)) return getOrCreateTypeDIE(T); - if (auto *NS = dyn_cast<MDNamespace>(Context)) + if (auto *NS = dyn_cast<DINamespace>(Context)) return getOrCreateNameSpace(NS); - if (auto *SP = dyn_cast<MDSubprogram>(Context)) + if (auto *SP = dyn_cast<DISubprogram>(Context)) return getOrCreateSubprogramDIE(SP); return getDIE(Context); } -DIE *DwarfUnit::createTypeDIE(const MDCompositeType *Ty) { +DIE *DwarfUnit::createTypeDIE(const DICompositeType *Ty) { auto *Context = resolve(Ty->getScope()); DIE *ContextDIE = getOrCreateContextDIE(Context); @@ -727,7 +727,7 @@ DIE *DwarfUnit::createTypeDIE(const MDCompositeType *Ty) { // Create new type. DIE &TyDIE = createAndAddDIE(Ty->getTag(), *ContextDIE, Ty); - constructTypeDIE(TyDIE, cast<MDCompositeType>(Ty)); + constructTypeDIE(TyDIE, cast<DICompositeType>(Ty)); updateAcceleratorTables(Context, Ty, TyDIE); return &TyDIE; @@ -737,14 +737,13 @@ DIE *DwarfUnit::getOrCreateTypeDIE(const MDNode *TyNode) { if (!TyNode) return nullptr; - auto *Ty = cast<MDType>(TyNode); + auto *Ty = cast<DIType>(TyNode); assert(Ty == resolve(Ty->getRef()) && "type was not uniqued, possible ODR violation."); // DW_TAG_restrict_type is not supported in DWARF2 if (Ty->getTag() == dwarf::DW_TAG_restrict_type && DD->getDwarfVersion() <= 2) - return getOrCreateTypeDIE( - resolve(cast<MDDerivedType>(Ty)->getBaseType())); + return getOrCreateTypeDIE(resolve(cast<DIDerivedType>(Ty)->getBaseType())); // Construct the context before querying for the existence of the DIE in case // such construction creates the DIE. @@ -760,11 +759,11 @@ DIE *DwarfUnit::getOrCreateTypeDIE(const MDNode *TyNode) { updateAcceleratorTables(Context, Ty, TyDIE); - if (auto *BT = dyn_cast<MDBasicType>(Ty)) + if (auto *BT = dyn_cast<DIBasicType>(Ty)) constructTypeDIE(TyDIE, BT); - else if (auto *STy = dyn_cast<MDSubroutineType>(Ty)) + else if (auto *STy = dyn_cast<DISubroutineType>(Ty)) constructTypeDIE(TyDIE, STy); - else if (auto *CTy = dyn_cast<MDCompositeType>(Ty)) { + else if (auto *CTy = dyn_cast<DICompositeType>(Ty)) { if (GenerateDwarfTypeUnits && !Ty->isForwardDecl()) if (MDString *TypeId = CTy->getRawIdentifier()) { DD->addDwarfTypeUnitType(getCU(), TypeId->getString(), TyDIE, CTy); @@ -773,17 +772,17 @@ DIE *DwarfUnit::getOrCreateTypeDIE(const MDNode *TyNode) { } constructTypeDIE(TyDIE, CTy); } else { - constructTypeDIE(TyDIE, cast<MDDerivedType>(Ty)); + constructTypeDIE(TyDIE, cast<DIDerivedType>(Ty)); } return &TyDIE; } -void DwarfUnit::updateAcceleratorTables(const MDScope *Context, - const MDType *Ty, const DIE &TyDIE) { +void DwarfUnit::updateAcceleratorTables(const DIScope *Context, + const DIType *Ty, const DIE &TyDIE) { if (!Ty->getName().empty() && !Ty->isForwardDecl()) { bool IsImplementation = 0; - if (auto *CT = dyn_cast<MDCompositeTypeBase>(Ty)) { + if (auto *CT = dyn_cast<DICompositeTypeBase>(Ty)) { // A runtime language of 0 actually means C/C++ and that any // non-negative value is some version of Objective-C/C++. IsImplementation = CT->getRuntimeLang() == 0 || CT->isObjcClassComplete(); @@ -791,13 +790,13 @@ void DwarfUnit::updateAcceleratorTables(const MDScope *Context, unsigned Flags = IsImplementation ? dwarf::DW_FLAG_type_implementation : 0; DD->addAccelType(Ty->getName(), TyDIE, Flags); - if (!Context || isa<MDCompileUnit>(Context) || isa<MDFile>(Context) || - isa<MDNamespace>(Context)) + if (!Context || isa<DICompileUnit>(Context) || isa<DIFile>(Context) || + isa<DINamespace>(Context)) addGlobalType(Ty, TyDIE, Context); } } -void DwarfUnit::addType(DIE &Entity, const MDType *Ty, +void DwarfUnit::addType(DIE &Entity, const DIType *Ty, dwarf::Attribute Attribute) { assert(Ty && "Trying to add a type that doesn't exist?"); @@ -818,7 +817,7 @@ void DwarfUnit::addType(DIE &Entity, const MDType *Ty, addDIEEntry(Entity, Attribute, Entry); } -std::string DwarfUnit::getParentContextString(const MDScope *Context) const { +std::string DwarfUnit::getParentContextString(const DIScope *Context) const { if (!Context) return ""; @@ -827,8 +826,8 @@ std::string DwarfUnit::getParentContextString(const MDScope *Context) const { return ""; std::string CS; - SmallVector<const MDScope *, 1> Parents; - while (!isa<MDCompileUnit>(Context)) { + SmallVector<const DIScope *, 1> Parents; + while (!isa<DICompileUnit>(Context)) { Parents.push_back(Context); if (Context->getScope()) Context = resolve(Context->getScope()); @@ -841,9 +840,9 @@ std::string DwarfUnit::getParentContextString(const MDScope *Context) const { // Reverse iterate over our list to go from the outermost construct to the // innermost. for (auto I = Parents.rbegin(), E = Parents.rend(); I != E; ++I) { - const MDScope *Ctx = *I; + const DIScope *Ctx = *I; StringRef Name = Ctx->getName(); - if (Name.empty() && isa<MDNamespace>(Ctx)) + if (Name.empty() && isa<DINamespace>(Ctx)) Name = "(anonymous namespace)"; if (!Name.empty()) { CS += Name; @@ -853,7 +852,7 @@ std::string DwarfUnit::getParentContextString(const MDScope *Context) const { return CS; } -void DwarfUnit::constructTypeDIE(DIE &Buffer, const MDBasicType *BTy) { +void DwarfUnit::constructTypeDIE(DIE &Buffer, const DIBasicType *BTy) { // Get core information. StringRef Name = BTy->getName(); // Add name if not anonymous or intermediate type. @@ -871,14 +870,14 @@ void DwarfUnit::constructTypeDIE(DIE &Buffer, const MDBasicType *BTy) { addUInt(Buffer, dwarf::DW_AT_byte_size, None, Size); } -void DwarfUnit::constructTypeDIE(DIE &Buffer, const MDDerivedType *DTy) { +void DwarfUnit::constructTypeDIE(DIE &Buffer, const DIDerivedType *DTy) { // Get core information. StringRef Name = DTy->getName(); uint64_t Size = DTy->getSizeInBits() >> 3; uint16_t Tag = Buffer.getTag(); // Map to main type, void will not have a type. - const MDType *FromTy = resolve(DTy->getBaseType()); + const DIType *FromTy = resolve(DTy->getBaseType()); if (FromTy) addType(Buffer, FromTy); @@ -894,15 +893,15 @@ void DwarfUnit::constructTypeDIE(DIE &Buffer, const MDDerivedType *DTy) { if (Tag == dwarf::DW_TAG_ptr_to_member_type) addDIEEntry( Buffer, dwarf::DW_AT_containing_type, - *getOrCreateTypeDIE(resolve(cast<MDDerivedType>(DTy)->getClassType()))); + *getOrCreateTypeDIE(resolve(cast<DIDerivedType>(DTy)->getClassType()))); // Add source line info if available and TyDesc is not a forward declaration. if (!DTy->isForwardDecl()) addSourceLine(Buffer, DTy); } -void DwarfUnit::constructSubprogramArguments(DIE &Buffer, MDTypeRefArray Args) { +void DwarfUnit::constructSubprogramArguments(DIE &Buffer, DITypeRefArray Args) { for (unsigned i = 1, N = Args.size(); i < N; ++i) { - const MDType *Ty = resolve(Args[i]); + const DIType *Ty = resolve(Args[i]); if (!Ty) { assert(i == N-1 && "Unspecified parameter must be the last argument"); createAndAddDIE(dwarf::DW_TAG_unspecified_parameters, Buffer); @@ -915,9 +914,9 @@ void DwarfUnit::constructSubprogramArguments(DIE &Buffer, MDTypeRefArray Args) { } } -void DwarfUnit::constructTypeDIE(DIE &Buffer, const MDSubroutineType *CTy) { +void DwarfUnit::constructTypeDIE(DIE &Buffer, const DISubroutineType *CTy) { // Add return type. A void return won't have a type. - auto Elements = cast<MDSubroutineType>(CTy)->getTypeArray(); + auto Elements = cast<DISubroutineType>(CTy)->getTypeArray(); if (Elements.size()) if (auto RTy = resolve(Elements[0])) addType(Buffer, RTy); @@ -943,7 +942,7 @@ void DwarfUnit::constructTypeDIE(DIE &Buffer, const MDSubroutineType *CTy) { addFlag(Buffer, dwarf::DW_AT_rvalue_reference); } -void DwarfUnit::constructTypeDIE(DIE &Buffer, const MDCompositeType *CTy) { +void DwarfUnit::constructTypeDIE(DIE &Buffer, const DICompositeType *CTy) { // Add name if not anonymous or intermediate type. StringRef Name = CTy->getName(); @@ -961,13 +960,13 @@ void DwarfUnit::constructTypeDIE(DIE &Buffer, const MDCompositeType *CTy) { case dwarf::DW_TAG_union_type: case dwarf::DW_TAG_class_type: { // Add elements to structure type. - DebugNodeArray Elements = CTy->getElements(); + DINodeArray Elements = CTy->getElements(); for (const auto *Element : Elements) { if (!Element) continue; - if (auto *SP = dyn_cast<MDSubprogram>(Element)) + if (auto *SP = dyn_cast<DISubprogram>(Element)) getOrCreateSubprogramDIE(SP); - else if (auto *DDTy = dyn_cast<MDDerivedType>(Element)) { + else if (auto *DDTy = dyn_cast<DIDerivedType>(Element)) { if (DDTy->getTag() == dwarf::DW_TAG_friend) { DIE &ElemDie = createAndAddDIE(dwarf::DW_TAG_friend, Buffer); addType(ElemDie, resolve(DDTy->getBaseType()), dwarf::DW_AT_friend); @@ -976,7 +975,7 @@ void DwarfUnit::constructTypeDIE(DIE &Buffer, const MDCompositeType *CTy) { } else { constructMemberDIE(Buffer, DDTy); } - } else if (auto *Property = dyn_cast<MDObjCProperty>(Element)) { + } else if (auto *Property = dyn_cast<DIObjCProperty>(Element)) { DIE &ElemDie = createAndAddDIE(Property->getTag(), Buffer); StringRef PropertyName = Property->getName(); addString(ElemDie, dwarf::DW_AT_APPLE_property_name, PropertyName); @@ -1007,7 +1006,7 @@ void DwarfUnit::constructTypeDIE(DIE &Buffer, const MDCompositeType *CTy) { // This is outside the DWARF spec, but GDB expects a DW_AT_containing_type // inside C++ composite types to point to the base class with the vtable. if (auto *ContainingType = - dyn_cast_or_null<MDCompositeType>(resolve(CTy->getVTableHolder()))) + dyn_cast_or_null<DICompositeType>(resolve(CTy->getVTableHolder()))) addDIEEntry(Buffer, dwarf::DW_AT_containing_type, *getOrCreateTypeDIE(ContainingType)); @@ -1058,7 +1057,7 @@ void DwarfUnit::constructTypeDIE(DIE &Buffer, const MDCompositeType *CTy) { } void DwarfUnit::constructTemplateTypeParameterDIE( - DIE &Buffer, const MDTemplateTypeParameter *TP) { + DIE &Buffer, const DITemplateTypeParameter *TP) { DIE &ParamDIE = createAndAddDIE(dwarf::DW_TAG_template_type_parameter, Buffer); // Add the type if it exists, it could be void and therefore no type. @@ -1069,7 +1068,7 @@ void DwarfUnit::constructTemplateTypeParameterDIE( } void DwarfUnit::constructTemplateValueParameterDIE( - DIE &Buffer, const MDTemplateValueParameter *VP) { + DIE &Buffer, const DITemplateValueParameter *VP) { DIE &ParamDIE = createAndAddDIE(VP->getTag(), Buffer); // Add the type if there is one, template template and template parameter @@ -1100,7 +1099,7 @@ void DwarfUnit::constructTemplateValueParameterDIE( } } -DIE *DwarfUnit::getOrCreateNameSpace(const MDNamespace *NS) { +DIE *DwarfUnit::getOrCreateNameSpace(const DINamespace *NS) { // Construct the context before querying for the existence of the DIE in case // such construction creates the DIE. DIE *ContextDIE = getOrCreateContextDIE(NS->getScope()); @@ -1120,7 +1119,7 @@ DIE *DwarfUnit::getOrCreateNameSpace(const MDNamespace *NS) { return &NDie; } -DIE *DwarfUnit::getOrCreateSubprogramDIE(const MDSubprogram *SP, bool Minimal) { +DIE *DwarfUnit::getOrCreateSubprogramDIE(const DISubprogram *SP, bool Minimal) { // Construct the context before querying for the existence of the DIE in case // such construction creates the DIE (as is the case for member function // declarations). @@ -1151,7 +1150,7 @@ DIE *DwarfUnit::getOrCreateSubprogramDIE(const MDSubprogram *SP, bool Minimal) { return &SPDie; } -bool DwarfUnit::applySubprogramDefinitionAttributes(const MDSubprogram *SP, +bool DwarfUnit::applySubprogramDefinitionAttributes(const DISubprogram *SP, DIE &SPDie) { DIE *DeclDie = nullptr; StringRef DeclLinkageName; @@ -1183,7 +1182,7 @@ bool DwarfUnit::applySubprogramDefinitionAttributes(const MDSubprogram *SP, return true; } -void DwarfUnit::applySubprogramAttributes(const MDSubprogram *SP, DIE &SPDie, +void DwarfUnit::applySubprogramAttributes(const DISubprogram *SP, DIE &SPDie, bool Minimal) { if (!Minimal) if (applySubprogramDefinitionAttributes(SP, SPDie)) @@ -1207,7 +1206,7 @@ void DwarfUnit::applySubprogramAttributes(const MDSubprogram *SP, DIE &SPDie, Language == dwarf::DW_LANG_ObjC)) addFlag(SPDie, dwarf::DW_AT_prototyped); - const MDSubroutineType *SPTy = SP->getType(); + const DISubroutineType *SPTy = SP->getType(); assert(SPTy->getTag() == dwarf::DW_TAG_subroutine_type && "the type of a subprogram should be a subroutine"); @@ -1269,7 +1268,7 @@ void DwarfUnit::applySubprogramAttributes(const MDSubprogram *SP, DIE &SPDie, addFlag(SPDie, dwarf::DW_AT_explicit); } -void DwarfUnit::constructSubrangeDIE(DIE &Buffer, const MDSubrange *SR, +void DwarfUnit::constructSubrangeDIE(DIE &Buffer, const DISubrange *SR, DIE *IndexTy) { DIE &DW_Subrange = createAndAddDIE(dwarf::DW_TAG_subrange_type, Buffer); addDIEEntry(DW_Subrange, dwarf::DW_AT_type, *IndexTy); @@ -1303,7 +1302,7 @@ DIE *DwarfUnit::getIndexTyDie() { return IndexTyDie; } -void DwarfUnit::constructArrayTypeDIE(DIE &Buffer, const MDCompositeType *CTy) { +void DwarfUnit::constructArrayTypeDIE(DIE &Buffer, const DICompositeType *CTy) { if (CTy->isVector()) addFlag(Buffer, dwarf::DW_AT_GNU_vector); @@ -1316,21 +1315,21 @@ void DwarfUnit::constructArrayTypeDIE(DIE &Buffer, const MDCompositeType *CTy) { DIE *IdxTy = getIndexTyDie(); // Add subranges to array type. - DebugNodeArray Elements = CTy->getElements(); + DINodeArray Elements = CTy->getElements(); for (unsigned i = 0, N = Elements.size(); i < N; ++i) { // FIXME: Should this really be such a loose cast? - if (auto *Element = dyn_cast_or_null<DebugNode>(Elements[i])) + if (auto *Element = dyn_cast_or_null<DINode>(Elements[i])) if (Element->getTag() == dwarf::DW_TAG_subrange_type) - constructSubrangeDIE(Buffer, cast<MDSubrange>(Element), IdxTy); + constructSubrangeDIE(Buffer, cast<DISubrange>(Element), IdxTy); } } -void DwarfUnit::constructEnumTypeDIE(DIE &Buffer, const MDCompositeType *CTy) { - DebugNodeArray Elements = CTy->getElements(); +void DwarfUnit::constructEnumTypeDIE(DIE &Buffer, const DICompositeType *CTy) { + DINodeArray Elements = CTy->getElements(); // Add enumerators to enumeration type. for (unsigned i = 0, N = Elements.size(); i < N; ++i) { - auto *Enum = dyn_cast_or_null<MDEnumerator>(Elements[i]); + auto *Enum = dyn_cast_or_null<DIEnumerator>(Elements[i]); if (Enum) { DIE &Enumerator = createAndAddDIE(dwarf::DW_TAG_enumerator, Buffer); StringRef Name = Enum->getName(); @@ -1340,7 +1339,7 @@ void DwarfUnit::constructEnumTypeDIE(DIE &Buffer, const MDCompositeType *CTy) { Value); } } - const MDType *DTy = resolve(CTy->getBaseType()); + const DIType *DTy = resolve(CTy->getBaseType()); if (DTy) { addType(Buffer, DTy); addFlag(Buffer, dwarf::DW_AT_enum_class); @@ -1351,7 +1350,7 @@ void DwarfUnit::constructContainingTypeDIEs() { for (auto CI = ContainingTypeMap.begin(), CE = ContainingTypeMap.end(); CI != CE; ++CI) { DIE &SPDie = *CI->first; - const DebugNode *D = CI->second; + const DINode *D = CI->second; if (!D) continue; DIE *NDie = getDIE(D); @@ -1361,7 +1360,7 @@ void DwarfUnit::constructContainingTypeDIEs() { } } -void DwarfUnit::constructMemberDIE(DIE &Buffer, const MDDerivedType *DT) { +void DwarfUnit::constructMemberDIE(DIE &Buffer, const DIDerivedType *DT) { DIE &MemberDie = createAndAddDIE(DT->getTag(), Buffer); StringRef Name = DT->getName(); if (!Name.empty()) @@ -1449,7 +1448,7 @@ void DwarfUnit::constructMemberDIE(DIE &Buffer, const MDDerivedType *DT) { addFlag(MemberDie, dwarf::DW_AT_artificial); } -DIE *DwarfUnit::getOrCreateStaticMemberDIE(const MDDerivedType *DT) { +DIE *DwarfUnit::getOrCreateStaticMemberDIE(const DIDerivedType *DT) { if (!DT) return nullptr; @@ -1464,7 +1463,7 @@ DIE *DwarfUnit::getOrCreateStaticMemberDIE(const MDDerivedType *DT) { DIE &StaticMemberDIE = createAndAddDIE(DT->getTag(), *ContextDIE, DT); - const MDType *Ty = resolve(DT->getBaseType()); + const DIType *Ty = resolve(DT->getBaseType()); addString(StaticMemberDIE, dwarf::DW_AT_name, DT->getName()); addType(StaticMemberDIE, Ty); diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h index 1cbf3489b1b..a0ea3c870c3 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h @@ -71,7 +71,7 @@ protected: unsigned UniqueID; /// MDNode for the compile unit. - const MDCompileUnit *CUNode; + const DICompileUnit *CUNode; /// Unit debug information entry. DIE UnitDie; @@ -106,7 +106,7 @@ protected: /// This map is used to keep track of subprogram DIEs that need /// DW_AT_containing_type attribute. This attribute points to a DIE that /// corresponds to the MDNode mapped with the subprogram DIE. - DenseMap<DIE *, const DebugNode *> ContainingTypeMap; + DenseMap<DIE *, const DINode *> ContainingTypeMap; // All DIEValues are allocated through this allocator. BumpPtrAllocator DIEValueAllocator; @@ -117,7 +117,7 @@ protected: /// The section this unit will be emitted in. const MCSection *Section; - DwarfUnit(unsigned UID, dwarf::Tag, const MDCompileUnit *CU, AsmPrinter *A, + DwarfUnit(unsigned UID, dwarf::Tag, const DICompileUnit *CU, AsmPrinter *A, DwarfDebug *DW, DwarfFile *DWU); /// \brief Add a string attribute data and value. @@ -127,7 +127,7 @@ protected: void addIndexedString(DIE &Die, dwarf::Attribute Attribute, StringRef Str); - bool applySubprogramDefinitionAttributes(const MDSubprogram *SP, DIE &SPDie); + bool applySubprogramDefinitionAttributes(const DISubprogram *SP, DIE &SPDie); public: virtual ~DwarfUnit(); @@ -143,7 +143,7 @@ public: AsmPrinter* getAsmPrinter() const { return Asm; } unsigned getUniqueID() const { return UniqueID; } uint16_t getLanguage() const { return CUNode->getSourceLanguage(); } - const MDCompileUnit *getCUNode() const { return CUNode; } + const DICompileUnit *getCUNode() const { return CUNode; } DIE &getUnitDie() { return UnitDie; } unsigned getDebugInfoOffset() const { return DebugInfoOffset; } @@ -159,15 +159,15 @@ public: /// metadata level because DIEs may not currently have been added to the /// parent context and walking the DIEs looking for names is more expensive /// than walking the metadata. - std::string getParentContextString(const MDScope *Context) const; + std::string getParentContextString(const DIScope *Context) const; /// Add a new global name to the compile unit. - virtual void addGlobalName(StringRef Name, DIE &Die, const MDScope *Context) { + virtual void addGlobalName(StringRef Name, DIE &Die, const DIScope *Context) { } /// Add a new global type to the compile unit. - virtual void addGlobalType(const MDType *Ty, const DIE &Die, - const MDScope *Context) {} + virtual void addGlobalType(const DIType *Ty, const DIE &Die, + const DIScope *Context) {} /// \brief Add a new name to the namespace accelerator table. void addAccelNamespace(StringRef Name, const DIE &Die); @@ -177,7 +177,7 @@ public: /// We delegate the request to DwarfDebug when the MDNode can be part of the /// type system, since DIEs for the type system can be shared across CUs and /// the mappings are kept in DwarfDebug. - DIE *getDIE(const DebugNode *D) const; + DIE *getDIE(const DINode *D) const; /// \brief Returns a fresh newly allocated DIELoc. DIELoc *getDIELoc() { return new (DIEValueAllocator) DIELoc(); } @@ -187,7 +187,7 @@ public: /// We delegate the request to DwarfDebug when the MDNode can be part of the /// type system, since DIEs for the type system can be shared across CUs and /// the mappings are kept in DwarfDebug. - void insertDIE(const DebugNode *Desc, DIE *D); + void insertDIE(const DINode *Desc, DIE *D); /// \brief Add a flag that is true to the DIE. void addFlag(DIE &Die, dwarf::Attribute Attribute); @@ -246,17 +246,17 @@ public: /// \brief Add location information to specified debug information entry. void addSourceLine(DIE &Die, unsigned Line, StringRef File, StringRef Directory); - void addSourceLine(DIE &Die, const MDLocalVariable *V); - void addSourceLine(DIE &Die, const MDGlobalVariable *G); - void addSourceLine(DIE &Die, const MDSubprogram *SP); - void addSourceLine(DIE &Die, const MDType *Ty); - void addSourceLine(DIE &Die, const MDNamespace *NS); - void addSourceLine(DIE &Die, const MDObjCProperty *Ty); + void addSourceLine(DIE &Die, const DILocalVariable *V); + void addSourceLine(DIE &Die, const DIGlobalVariable *G); + void addSourceLine(DIE &Die, const DISubprogram *SP); + void addSourceLine(DIE &Die, const DIType *Ty); + void addSourceLine(DIE &Die, const DINamespace *NS); + void addSourceLine(DIE &Die, const DIObjCProperty *Ty); /// \brief Add constant value entry in variable DIE. - void addConstantValue(DIE &Die, const MachineOperand &MO, const MDType *Ty); - void addConstantValue(DIE &Die, const ConstantInt *CI, const MDType *Ty); - void addConstantValue(DIE &Die, const APInt &Val, const MDType *Ty); + void addConstantValue(DIE &Die, const MachineOperand &MO, const DIType *Ty); + void addConstantValue(DIE &Die, const ConstantInt *CI, const DIType *Ty); + void addConstantValue(DIE &Die, const APInt &Val, const DIType *Ty); void addConstantValue(DIE &Die, const APInt &Val, bool Unsigned); void addConstantValue(DIE &Die, bool Unsigned, uint64_t Val); @@ -268,7 +268,7 @@ public: void addLinkageName(DIE &Die, StringRef LinkageName); /// \brief Add template parameters in buffer. - void addTemplateParams(DIE &Buffer, DebugNodeArray TParams); + void addTemplateParams(DIE &Buffer, DINodeArray TParams); /// \brief Add register operand. /// \returns false if the register does not exist, e.g., because it was never @@ -294,33 +294,33 @@ public: /// /// This takes and attribute parameter because DW_AT_friend attributes are /// also type references. - void addType(DIE &Entity, const MDType *Ty, + void addType(DIE &Entity, const DIType *Ty, dwarf::Attribute Attribute = dwarf::DW_AT_type); - DIE *getOrCreateNameSpace(const MDNamespace *NS); - DIE *getOrCreateSubprogramDIE(const MDSubprogram *SP, bool Minimal = false); + DIE *getOrCreateNameSpace(const DINamespace *NS); + DIE *getOrCreateSubprogramDIE(const DISubprogram *SP, bool Minimal = false); - void applySubprogramAttributes(const MDSubprogram *SP, DIE &SPDie, + void applySubprogramAttributes(const DISubprogram *SP, DIE &SPDie, bool Minimal = false); /// \brief Find existing DIE or create new DIE for the given type. DIE *getOrCreateTypeDIE(const MDNode *N); /// \brief Get context owner's DIE. - DIE *createTypeDIE(const MDCompositeType *Ty); + DIE *createTypeDIE(const DICompositeType *Ty); /// \brief Get context owner's DIE. - DIE *getOrCreateContextDIE(const MDScope *Context); + DIE *getOrCreateContextDIE(const DIScope *Context); /// \brief Construct DIEs for types that contain vtables. void constructContainingTypeDIEs(); /// \brief Construct function argument DIEs. - void constructSubprogramArguments(DIE &Buffer, MDTypeRefArray Args); + void constructSubprogramArguments(DIE &Buffer, DITypeRefArray Args); /// Create a DIE with the given Tag, add the DIE to its parent, and /// call insertDIE if MD is not null. - DIE &createAndAddDIE(unsigned Tag, DIE &Parent, const DebugNode *N = nullptr); + DIE &createAndAddDIE(unsigned Tag, DIE &Parent, const DINode *N = nullptr); /// Compute the size of a header for this unit, not including the initial /// length field. @@ -335,11 +335,11 @@ public: virtual DwarfCompileUnit &getCU() = 0; - void constructTypeDIE(DIE &Buffer, const MDCompositeType *CTy); + void constructTypeDIE(DIE &Buffer, const DICompositeType *CTy); protected: /// \brief Create new static data member DIE. - DIE *getOrCreateStaticMemberDIE(const MDDerivedType *DT); + DIE *getOrCreateStaticMemberDIE(const DIDerivedType *DT); /// Look up the source ID with the given directory and source file names. If /// none currently exists, create a new ID and insert it in the line table. @@ -347,22 +347,22 @@ protected: /// \brief Look in the DwarfDebug map for the MDNode that corresponds to the /// reference. - template <typename T> T *resolve(TypedDebugNodeRef<T> Ref) const { + template <typename T> T *resolve(TypedDINodeRef<T> Ref) const { return DD->resolve(Ref); } private: - void constructTypeDIE(DIE &Buffer, const MDBasicType *BTy); - void constructTypeDIE(DIE &Buffer, const MDDerivedType *DTy); - void constructTypeDIE(DIE &Buffer, const MDSubroutineType *DTy); - void constructSubrangeDIE(DIE &Buffer, const MDSubrange *SR, DIE *IndexTy); - void constructArrayTypeDIE(DIE &Buffer, const MDCompositeType *CTy); - void constructEnumTypeDIE(DIE &Buffer, const MDCompositeType *CTy); - void constructMemberDIE(DIE &Buffer, const MDDerivedType *DT); + void constructTypeDIE(DIE &Buffer, const DIBasicType *BTy); + void constructTypeDIE(DIE &Buffer, const DIDerivedType *DTy); + void constructTypeDIE(DIE &Buffer, const DISubroutineType *DTy); + void constructSubrangeDIE(DIE &Buffer, const DISubrange *SR, DIE *IndexTy); + void constructArrayTypeDIE(DIE &Buffer, const DICompositeType *CTy); + void constructEnumTypeDIE(DIE &Buffer, const DICompositeType *CTy); + void constructMemberDIE(DIE &Buffer, const DIDerivedType *DT); void constructTemplateTypeParameterDIE(DIE &Buffer, - const MDTemplateTypeParameter *TP); + const DITemplateTypeParameter *TP); void constructTemplateValueParameterDIE(DIE &Buffer, - const MDTemplateValueParameter *TVP); + const DITemplateValueParameter *TVP); /// \brief Return the default lower bound for an array. /// @@ -391,7 +391,7 @@ private: /// If this is a named finished type then include it in the list of types for /// the accelerator tables. - void updateAcceleratorTables(const MDScope *Context, const MDType *Ty, + void updateAcceleratorTables(const DIScope *Context, const DIType *Ty, const DIE &TyDIE); virtual bool isDwoUnit() const = 0; diff --git a/llvm/lib/CodeGen/AsmPrinter/WinCodeViewLineTables.cpp b/llvm/lib/CodeGen/AsmPrinter/WinCodeViewLineTables.cpp index ff217813eeb..f394aba9131 100644 --- a/llvm/lib/CodeGen/AsmPrinter/WinCodeViewLineTables.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/WinCodeViewLineTables.cpp @@ -20,11 +20,11 @@ namespace llvm { StringRef WinCodeViewLineTables::getFullFilepath(const MDNode *S) { assert(S); - assert((isa<MDCompileUnit>(S) || isa<MDFile>(S) || isa<MDSubprogram>(S) || - isa<MDLexicalBlockBase>(S)) && + assert((isa<DICompileUnit>(S) || isa<DIFile>(S) || isa<DISubprogram>(S) || + isa<DILexicalBlockBase>(S)) && "Unexpected scope info"); - auto *Scope = cast<MDScope>(S); + auto *Scope = cast<DIScope>(S); StringRef Dir = Scope->getDirectory(), Filename = Scope->getFilename(); char *&Result = DirAndFilenameToFilepathMap[std::make_pair(Dir, Filename)]; |