| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
#ifndef LLVM_IR_DEBUGINFO_H |
| 17 |
#define LLVM_IR_DEBUGINFO_H |
| 18 |
|
| 19 |
#include "llvm/ADT/STLExtras.h" |
| 20 |
#include "llvm/ADT/SmallPtrSet.h" |
| 21 |
#include "llvm/ADT/SmallVector.h" |
| 22 |
#include "llvm/ADT/TinyPtrVector.h" |
| 23 |
#include "llvm/ADT/iterator_range.h" |
| 24 |
#include "llvm/IR/DebugInfoMetadata.h" |
| 25 |
|
| 26 |
namespace llvm { |
| 27 |
|
| 28 |
class DbgDeclareInst; |
| 29 |
class DbgValueInst; |
| 30 |
class DbgVariableIntrinsic; |
| 31 |
class Instruction; |
| 32 |
class Module; |
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
TinyPtrVector<DbgVariableIntrinsic *> FindDbgAddrUses(Value *V); |
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
TinyPtrVector<DbgDeclareInst *> FindDbgDeclareUses(Value *V); |
| 42 |
|
| 43 |
|
| 44 |
void findDbgValues(SmallVectorImpl<DbgValueInst *> &DbgValues, Value *V); |
| 45 |
|
| 46 |
|
| 47 |
void findDbgUsers(SmallVectorImpl<DbgVariableIntrinsic *> &DbgInsts, Value *V); |
| 48 |
|
| 49 |
|
| 50 |
DISubprogram *getDISubprogram(const MDNode *Scope); |
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
bool StripDebugInfo(Module &M); |
| 58 |
bool stripDebugInfo(Function &F); |
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
bool stripNonLineTableDebugInfo(Module &M); |
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
void updateLoopMetadataDebugLocations( |
| 77 |
Instruction &I, function_ref<Metadata *(Metadata *)> Updater); |
| 78 |
|
| 79 |
|
| 80 |
unsigned getDebugMetadataVersionFromModule(const Module &M); |
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
class DebugInfoFinder { |
| 91 |
public: |
| 92 |
|
| 93 |
void processModule(const Module &M); |
| 94 |
|
| 95 |
void processInstruction(const Module &M, const Instruction &I); |
| 96 |
|
| 97 |
|
| 98 |
void processVariable(const Module &M, const DbgVariableIntrinsic &DVI); |
| 99 |
|
| 100 |
void processLocation(const Module &M, const DILocation *Loc); |
| 101 |
|
| 102 |
|
| 103 |
void processSubprogram(DISubprogram *SP); |
| 104 |
|
| 105 |
|
| 106 |
void reset(); |
| 107 |
|
| 108 |
private: |
| 109 |
void processCompileUnit(DICompileUnit *CU); |
| 110 |
void processScope(DIScope *Scope); |
| 111 |
void processType(DIType *DT); |
| 112 |
bool addCompileUnit(DICompileUnit *CU); |
| 113 |
bool addGlobalVariable(DIGlobalVariableExpression *DIG); |
| 114 |
bool addScope(DIScope *Scope); |
| 115 |
bool addSubprogram(DISubprogram *SP); |
| 116 |
bool addType(DIType *DT); |
| 117 |
|
| 118 |
public: |
| 119 |
using compile_unit_iterator = |
| 120 |
SmallVectorImpl<DICompileUnit *>::const_iterator; |
| 121 |
using subprogram_iterator = SmallVectorImpl<DISubprogram *>::const_iterator; |
| 122 |
using global_variable_expression_iterator = |
| 123 |
SmallVectorImpl<DIGlobalVariableExpression *>::const_iterator; |
| 124 |
using type_iterator = SmallVectorImpl<DIType *>::const_iterator; |
| 125 |
using scope_iterator = SmallVectorImpl<DIScope *>::const_iterator; |
| 126 |
|
| 127 |
iterator_range<compile_unit_iterator> compile_units() const { |
| 128 |
return make_range(CUs.begin(), CUs.end()); |
| 129 |
} |
| 130 |
|
| 131 |
iterator_range<subprogram_iterator> subprograms() const { |
| 132 |
return make_range(SPs.begin(), SPs.end()); |
| 133 |
} |
| 134 |
|
| 135 |
iterator_range<global_variable_expression_iterator> global_variables() const { |
| 136 |
return make_range(GVs.begin(), GVs.end()); |
| 137 |
} |
| 138 |
|
| 139 |
iterator_range<type_iterator> types() const { |
| 140 |
return make_range(TYs.begin(), TYs.end()); |
| 141 |
} |
| 142 |
|
| 143 |
iterator_range<scope_iterator> scopes() const { |
| 144 |
return make_range(Scopes.begin(), Scopes.end()); |
| 145 |
} |
| 146 |
|
| 147 |
unsigned compile_unit_count() const { return CUs.size(); } |
| 148 |
unsigned global_variable_count() const { return GVs.size(); } |
| 149 |
unsigned subprogram_count() const { return SPs.size(); } |
| 150 |
unsigned type_count() const { return TYs.size(); } |
| 151 |
unsigned scope_count() const { return Scopes.size(); } |
| 152 |
|
| 153 |
private: |
| 154 |
SmallVector<DICompileUnit *, 8> CUs; |
| 155 |
SmallVector<DISubprogram *, 8> SPs; |
| 156 |
SmallVector<DIGlobalVariableExpression *, 8> GVs; |
| 157 |
SmallVector<DIType *, 8> TYs; |
| 158 |
SmallVector<DIScope *, 8> Scopes; |
| 159 |
SmallPtrSet<const MDNode *, 32> NodesSeen; |
| 160 |
}; |
| 161 |
|
| 162 |
} |
| 163 |
|
| 164 |
#endif |