DebugInfo: Remove DIDescriptor from the DebugInfo API

Stop using `DIDescriptor` and its subclasses in the `DebugInfoFinder`
API, as well as the rest of the API hanging around in `DebugInfo.h`.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235240 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Duncan P. N. Exon Smith
2015-04-17 23:20:10 +00:00
parent 166679ef06
commit 5d801364e2
7 changed files with 62 additions and 60 deletions

View File

@@ -419,15 +419,15 @@ SIMPLIFY_DESCRIPTOR(DIImportedEntity)
#undef SIMPLIFY_DESCRIPTOR #undef SIMPLIFY_DESCRIPTOR
/// \brief Find subprogram that is enclosing this scope. /// \brief Find subprogram that is enclosing this scope.
DISubprogram getDISubprogram(const MDNode *Scope); MDSubprogram *getDISubprogram(const MDNode *Scope);
/// \brief Find debug info for a given function. /// \brief Find debug info for a given function.
/// \returns a valid DISubprogram, if found. Otherwise, it returns an empty /// \returns a valid DISubprogram, if found. Otherwise, it returns an empty
/// DISubprogram. /// DISubprogram.
DISubprogram getDISubprogram(const Function *F); MDSubprogram *getDISubprogram(const Function *F);
/// \brief Find underlying composite type. /// \brief Find underlying composite type.
DICompositeType getDICompositeType(DIType T); MDCompositeTypeBase *getDICompositeType(MDType *T);
/// \brief Generate map by visiting all retained types. /// \brief Generate map by visiting all retained types.
DITypeIdentifierMap generateDITypeIdentifierMap(const NamedMDNode *CU_Nodes); DITypeIdentifierMap generateDITypeIdentifierMap(const NamedMDNode *CU_Nodes);
@@ -463,7 +463,7 @@ public:
/// \brief Process DbgValueInst. /// \brief Process DbgValueInst.
void processValue(const Module &M, const DbgValueInst *DVI); void processValue(const Module &M, const DbgValueInst *DVI);
/// \brief Process DILocation. /// \brief Process DILocation.
void processLocation(const Module &M, DILocation Loc); void processLocation(const Module &M, const MDLocation *Loc);
/// \brief Clear all lists. /// \brief Clear all lists.
void reset(); void reset();
@@ -471,22 +471,23 @@ public:
private: private:
void InitializeTypeMap(const Module &M); void InitializeTypeMap(const Module &M);
void processType(DIType DT); void processType(MDType *DT);
void processSubprogram(DISubprogram SP); void processSubprogram(MDSubprogram *SP);
void processScope(DIScope Scope); void processScope(MDScope *Scope);
bool addCompileUnit(DICompileUnit CU); bool addCompileUnit(MDCompileUnit *CU);
bool addGlobalVariable(DIGlobalVariable DIG); bool addGlobalVariable(MDGlobalVariable *DIG);
bool addSubprogram(DISubprogram SP); bool addSubprogram(MDSubprogram *SP);
bool addType(DIType DT); bool addType(MDType *DT);
bool addScope(DIScope Scope); bool addScope(MDScope *Scope);
public: public:
typedef SmallVectorImpl<DICompileUnit>::const_iterator compile_unit_iterator; typedef SmallVectorImpl<MDCompileUnit *>::const_iterator
typedef SmallVectorImpl<DISubprogram>::const_iterator subprogram_iterator; compile_unit_iterator;
typedef SmallVectorImpl<DIGlobalVariable>::const_iterator typedef SmallVectorImpl<MDSubprogram *>::const_iterator subprogram_iterator;
typedef SmallVectorImpl<MDGlobalVariable *>::const_iterator
global_variable_iterator; global_variable_iterator;
typedef SmallVectorImpl<DIType>::const_iterator type_iterator; typedef SmallVectorImpl<MDType *>::const_iterator type_iterator;
typedef SmallVectorImpl<DIScope>::const_iterator scope_iterator; typedef SmallVectorImpl<MDScope *>::const_iterator scope_iterator;
iterator_range<compile_unit_iterator> compile_units() const { iterator_range<compile_unit_iterator> compile_units() const {
return iterator_range<compile_unit_iterator>(CUs.begin(), CUs.end()); return iterator_range<compile_unit_iterator>(CUs.begin(), CUs.end());
@@ -515,19 +516,19 @@ public:
unsigned scope_count() const { return Scopes.size(); } unsigned scope_count() const { return Scopes.size(); }
private: private:
SmallVector<DICompileUnit, 8> CUs; SmallVector<MDCompileUnit *, 8> CUs;
SmallVector<DISubprogram, 8> SPs; SmallVector<MDSubprogram *, 8> SPs;
SmallVector<DIGlobalVariable, 8> GVs; SmallVector<MDGlobalVariable *, 8> GVs;
SmallVector<DIType, 8> TYs; SmallVector<MDType *, 8> TYs;
SmallVector<DIScope, 8> Scopes; SmallVector<MDScope *, 8> Scopes;
SmallPtrSet<MDNode *, 64> NodesSeen; SmallPtrSet<const MDNode *, 64> NodesSeen;
DITypeIdentifierMap TypeIdentifierMap; DITypeIdentifierMap TypeIdentifierMap;
/// \brief Specify if TypeIdentifierMap is initialized. /// \brief Specify if TypeIdentifierMap is initialized.
bool TypeMapInitialized; bool TypeMapInitialized;
}; };
DenseMap<const Function *, DISubprogram> makeSubprogramMap(const Module &M); DenseMap<const Function *, MDSubprogram *> makeSubprogramMap(const Module &M);
} // end namespace llvm } // end namespace llvm

View File

@@ -321,7 +321,7 @@ class DwarfDebug : public AsmPrinterHandler {
DwarfAccelTable AccelNamespace; DwarfAccelTable AccelNamespace;
DwarfAccelTable AccelTypes; DwarfAccelTable AccelTypes;
DenseMap<const Function *, DISubprogram> FunctionDIs; DenseMap<const Function *, MDSubprogram *> FunctionDIs;
MCDwarfDwoLineTable *getDwoLineTable(const DwarfCompileUnit &); MCDwarfDwoLineTable *getDwoLineTable(const DwarfCompileUnit &);

View File

@@ -33,7 +33,8 @@ class VirtRegMap;
class LiveDebugVariables : public MachineFunctionPass { class LiveDebugVariables : public MachineFunctionPass {
void *pImpl; void *pImpl;
DenseMap<const Function*, DISubprogram> FunctionDIs; DenseMap<const Function *, MDSubprogram *> FunctionDIs;
public: public:
static char ID; // Pass identification, replacement for typeid static char ID; // Pass identification, replacement for typeid

View File

@@ -33,13 +33,13 @@
using namespace llvm; using namespace llvm;
using namespace llvm::dwarf; using namespace llvm::dwarf;
DISubprogram llvm::getDISubprogram(const MDNode *Scope) { MDSubprogram *llvm::getDISubprogram(const MDNode *Scope) {
if (auto *LocalScope = dyn_cast_or_null<MDLocalScope>(Scope)) if (auto *LocalScope = dyn_cast_or_null<MDLocalScope>(Scope))
return LocalScope->getSubprogram(); return LocalScope->getSubprogram();
return nullptr; return nullptr;
} }
DISubprogram llvm::getDISubprogram(const Function *F) { MDSubprogram *llvm::getDISubprogram(const Function *F) {
// We look for the first instr that has a debug annotation leading back to F. // We look for the first instr that has a debug annotation leading back to F.
for (auto &BB : *F) { for (auto &BB : *F) {
auto Inst = std::find_if(BB.begin(), BB.end(), [](const Instruction &Inst) { auto Inst = std::find_if(BB.begin(), BB.end(), [](const Instruction &Inst) {
@@ -49,14 +49,14 @@ DISubprogram llvm::getDISubprogram(const Function *F) {
continue; continue;
DebugLoc DLoc = Inst->getDebugLoc(); DebugLoc DLoc = Inst->getDebugLoc();
const MDNode *Scope = DLoc.getInlinedAtScope(); const MDNode *Scope = DLoc.getInlinedAtScope();
DISubprogram Subprogram = getDISubprogram(Scope); auto *Subprogram = getDISubprogram(Scope);
return Subprogram->describes(F) ? Subprogram : DISubprogram(); return Subprogram->describes(F) ? Subprogram : nullptr;
} }
return DISubprogram(); return nullptr;
} }
DICompositeType llvm::getDICompositeType(DIType T) { MDCompositeTypeBase *llvm::getDICompositeType(MDType *T) {
if (auto *C = dyn_cast_or_null<MDCompositeTypeBase>(T)) if (auto *C = dyn_cast_or_null<MDCompositeTypeBase>(T))
return C; return C;
@@ -123,9 +123,9 @@ void DebugInfoFinder::processModule(const Module &M) {
InitializeTypeMap(M); InitializeTypeMap(M);
if (NamedMDNode *CU_Nodes = M.getNamedMetadata("llvm.dbg.cu")) { if (NamedMDNode *CU_Nodes = M.getNamedMetadata("llvm.dbg.cu")) {
for (unsigned i = 0, e = CU_Nodes->getNumOperands(); i != e; ++i) { for (unsigned i = 0, e = CU_Nodes->getNumOperands(); i != e; ++i) {
DICompileUnit CU = cast<MDCompileUnit>(CU_Nodes->getOperand(i)); auto *CU = cast<MDCompileUnit>(CU_Nodes->getOperand(i));
addCompileUnit(CU); addCompileUnit(CU);
for (DIGlobalVariable DIG : CU->getGlobalVariables()) { for (auto *DIG : CU->getGlobalVariables()) {
if (addGlobalVariable(DIG)) { if (addGlobalVariable(DIG)) {
processScope(DIG->getScope()); processScope(DIG->getScope());
processType(DIG->getType().resolve(TypeIdentifierMap)); processType(DIG->getType().resolve(TypeIdentifierMap));
@@ -137,7 +137,7 @@ void DebugInfoFinder::processModule(const Module &M) {
processType(ET); processType(ET);
for (auto *RT : CU->getRetainedTypes()) for (auto *RT : CU->getRetainedTypes())
processType(RT); processType(RT);
for (DIImportedEntity Import : CU->getImportedEntities()) { for (auto *Import : CU->getImportedEntities()) {
auto *Entity = Import->getEntity().resolve(TypeIdentifierMap); auto *Entity = Import->getEntity().resolve(TypeIdentifierMap);
if (auto *T = dyn_cast<MDType>(Entity)) if (auto *T = dyn_cast<MDType>(Entity))
processType(T); processType(T);
@@ -150,7 +150,7 @@ void DebugInfoFinder::processModule(const Module &M) {
} }
} }
void DebugInfoFinder::processLocation(const Module &M, DILocation Loc) { void DebugInfoFinder::processLocation(const Module &M, const MDLocation *Loc) {
if (!Loc) if (!Loc)
return; return;
InitializeTypeMap(M); InitializeTypeMap(M);
@@ -158,7 +158,7 @@ void DebugInfoFinder::processLocation(const Module &M, DILocation Loc) {
processLocation(M, Loc->getInlinedAt()); processLocation(M, Loc->getInlinedAt());
} }
void DebugInfoFinder::processType(DIType DT) { void DebugInfoFinder::processType(MDType *DT) {
if (!addType(DT)) if (!addType(DT))
return; return;
processScope(DT->getScope().resolve(TypeIdentifierMap)); processScope(DT->getScope().resolve(TypeIdentifierMap));
@@ -172,7 +172,7 @@ void DebugInfoFinder::processType(DIType DT) {
for (Metadata *D : DCT->getElements()) { for (Metadata *D : DCT->getElements()) {
if (auto *T = dyn_cast<MDType>(D)) if (auto *T = dyn_cast<MDType>(D))
processType(T); processType(T);
else if (DISubprogram SP = dyn_cast<MDSubprogram>(D)) else if (auto *SP = dyn_cast<MDSubprogram>(D))
processSubprogram(SP); processSubprogram(SP);
} }
} else if (auto *DDT = dyn_cast<MDDerivedTypeBase>(DT)) { } else if (auto *DDT = dyn_cast<MDDerivedTypeBase>(DT)) {
@@ -180,18 +180,18 @@ void DebugInfoFinder::processType(DIType DT) {
} }
} }
void DebugInfoFinder::processScope(DIScope Scope) { void DebugInfoFinder::processScope(MDScope *Scope) {
if (!Scope) if (!Scope)
return; return;
if (DIType Ty = dyn_cast<MDType>(Scope)) { if (auto *Ty = dyn_cast<MDType>(Scope)) {
processType(Ty); processType(Ty);
return; return;
} }
if (DICompileUnit CU = dyn_cast<MDCompileUnit>(Scope)) { if (auto *CU = dyn_cast<MDCompileUnit>(Scope)) {
addCompileUnit(CU); addCompileUnit(CU);
return; return;
} }
if (DISubprogram SP = dyn_cast<MDSubprogram>(Scope)) { if (auto *SP = dyn_cast<MDSubprogram>(Scope)) {
processSubprogram(SP); processSubprogram(SP);
return; return;
} }
@@ -204,7 +204,7 @@ void DebugInfoFinder::processScope(DIScope Scope) {
} }
} }
void DebugInfoFinder::processSubprogram(DISubprogram SP) { void DebugInfoFinder::processSubprogram(MDSubprogram *SP) {
if (!addSubprogram(SP)) if (!addSubprogram(SP))
return; return;
processScope(SP->getScope().resolve(TypeIdentifierMap)); processScope(SP->getScope().resolve(TypeIdentifierMap));
@@ -220,12 +220,12 @@ void DebugInfoFinder::processSubprogram(DISubprogram SP) {
void DebugInfoFinder::processDeclare(const Module &M, void DebugInfoFinder::processDeclare(const Module &M,
const DbgDeclareInst *DDI) { const DbgDeclareInst *DDI) {
MDNode *N = dyn_cast<MDNode>(DDI->getVariable()); auto *N = dyn_cast<MDNode>(DDI->getVariable());
if (!N) if (!N)
return; return;
InitializeTypeMap(M); InitializeTypeMap(M);
DIVariable DV = dyn_cast<MDLocalVariable>(N); auto *DV = dyn_cast<MDLocalVariable>(N);
if (!DV) if (!DV)
return; return;
@@ -236,12 +236,12 @@ void DebugInfoFinder::processDeclare(const Module &M,
} }
void DebugInfoFinder::processValue(const Module &M, const DbgValueInst *DVI) { void DebugInfoFinder::processValue(const Module &M, const DbgValueInst *DVI) {
MDNode *N = dyn_cast<MDNode>(DVI->getVariable()); auto *N = dyn_cast<MDNode>(DVI->getVariable());
if (!N) if (!N)
return; return;
InitializeTypeMap(M); InitializeTypeMap(M);
DIVariable DV = dyn_cast<MDLocalVariable>(N); auto *DV = dyn_cast<MDLocalVariable>(N);
if (!DV) if (!DV)
return; return;
@@ -251,18 +251,18 @@ void DebugInfoFinder::processValue(const Module &M, const DbgValueInst *DVI) {
processType(DV->getType().resolve(TypeIdentifierMap)); processType(DV->getType().resolve(TypeIdentifierMap));
} }
bool DebugInfoFinder::addType(DIType DT) { bool DebugInfoFinder::addType(MDType *DT) {
if (!DT) if (!DT)
return false; return false;
if (!NodesSeen.insert(DT).second) if (!NodesSeen.insert(DT).second)
return false; return false;
TYs.push_back(DT); TYs.push_back(const_cast<MDType *>(DT));
return true; return true;
} }
bool DebugInfoFinder::addCompileUnit(DICompileUnit CU) { bool DebugInfoFinder::addCompileUnit(MDCompileUnit *CU) {
if (!CU) if (!CU)
return false; return false;
if (!NodesSeen.insert(CU).second) if (!NodesSeen.insert(CU).second)
@@ -272,7 +272,7 @@ bool DebugInfoFinder::addCompileUnit(DICompileUnit CU) {
return true; return true;
} }
bool DebugInfoFinder::addGlobalVariable(DIGlobalVariable DIG) { bool DebugInfoFinder::addGlobalVariable(MDGlobalVariable *DIG) {
if (!DIG) if (!DIG)
return false; return false;
@@ -283,7 +283,7 @@ bool DebugInfoFinder::addGlobalVariable(DIGlobalVariable DIG) {
return true; return true;
} }
bool DebugInfoFinder::addSubprogram(DISubprogram SP) { bool DebugInfoFinder::addSubprogram(MDSubprogram *SP) {
if (!SP) if (!SP)
return false; return false;
@@ -294,7 +294,7 @@ bool DebugInfoFinder::addSubprogram(DISubprogram SP) {
return true; return true;
} }
bool DebugInfoFinder::addScope(DIScope Scope) { bool DebugInfoFinder::addScope(MDScope *Scope) {
if (!Scope) if (!Scope)
return false; return false;
// FIXME: Ocaml binding generates a scope with no content, we treat it // FIXME: Ocaml binding generates a scope with no content, we treat it
@@ -369,17 +369,17 @@ unsigned llvm::getDebugMetadataVersionFromModule(const Module &M) {
return 0; return 0;
} }
llvm::DenseMap<const llvm::Function *, llvm::DISubprogram> DenseMap<const llvm::Function *, MDSubprogram *>
llvm::makeSubprogramMap(const Module &M) { llvm::makeSubprogramMap(const Module &M) {
DenseMap<const Function *, DISubprogram> R; DenseMap<const Function *, MDSubprogram *> R;
NamedMDNode *CU_Nodes = M.getNamedMetadata("llvm.dbg.cu"); NamedMDNode *CU_Nodes = M.getNamedMetadata("llvm.dbg.cu");
if (!CU_Nodes) if (!CU_Nodes)
return R; return R;
for (MDNode *N : CU_Nodes->operands()) { for (MDNode *N : CU_Nodes->operands()) {
DICompileUnit CUNode = cast<MDCompileUnit>(N); auto *CUNode = cast<MDCompileUnit>(N);
for (DISubprogram SP : CUNode->getSubprograms()) { for (auto *SP : CUNode->getSubprograms()) {
if (Function *F = SP->getFunction()) if (Function *F = SP->getFunction())
R.insert(std::make_pair(F, SP)); R.insert(std::make_pair(F, SP));
} }

View File

@@ -89,7 +89,7 @@ namespace {
bool doInitialization(CallGraph &CG) override; bool doInitialization(CallGraph &CG) override;
/// The maximum number of elements to expand, or 0 for unlimited. /// The maximum number of elements to expand, or 0 for unlimited.
unsigned maxElements; unsigned maxElements;
DenseMap<const Function *, DISubprogram> FunctionDIs; DenseMap<const Function *, MDSubprogram *> FunctionDIs;
}; };
} }

View File

@@ -127,7 +127,7 @@ namespace {
// As the code generation for module is finished (and DIBuilder is // As the code generation for module is finished (and DIBuilder is
// finalized) we assume that subprogram descriptors won't be changed, and // finalized) we assume that subprogram descriptors won't be changed, and
// they are stored in map for short duration anyway. // they are stored in map for short duration anyway.
DenseMap<const Function *, DISubprogram> FunctionDIs; DenseMap<const Function *, MDSubprogram *> FunctionDIs;
protected: protected:
// DAH uses this to specify a different ID. // DAH uses this to specify a different ID.

View File

@@ -248,7 +248,7 @@ class DataFlowSanitizer : public ModulePass {
DFSanABIList ABIList; DFSanABIList ABIList;
DenseMap<Value *, Function *> UnwrappedFnMap; DenseMap<Value *, Function *> UnwrappedFnMap;
AttributeSet ReadOnlyNoneAttrs; AttributeSet ReadOnlyNoneAttrs;
DenseMap<const Function *, DISubprogram> FunctionDIs; DenseMap<const Function *, MDSubprogram *> FunctionDIs;
Value *getShadowAddress(Value *Addr, Instruction *Pos); Value *getShadowAddress(Value *Addr, Instruction *Pos);
bool isInstrumented(const Function *F); bool isInstrumented(const Function *F);