| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
#ifndef LLVM_CODEGEN_DEBUGHANDLERBASE_H |
| 15 |
#define LLVM_CODEGEN_DEBUGHANDLERBASE_H |
| 16 |
|
| 17 |
#include "llvm/ADT/Optional.h" |
| 18 |
#include "llvm/CodeGen/AsmPrinterHandler.h" |
| 19 |
#include "llvm/CodeGen/DbgEntityHistoryCalculator.h" |
| 20 |
#include "llvm/CodeGen/LexicalScopes.h" |
| 21 |
#include "llvm/IR/DebugInfoMetadata.h" |
| 22 |
#include "llvm/IR/DebugLoc.h" |
| 23 |
|
| 24 |
namespace llvm { |
| 25 |
|
| 26 |
class AsmPrinter; |
| 27 |
class MachineInstr; |
| 28 |
class MachineModuleInfo; |
| 29 |
|
| 30 |
|
| 31 |
struct DbgVariableLocation { |
| 32 |
|
| 33 |
unsigned Register; |
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
SmallVector<int64_t, 1> LoadChain; |
| 38 |
|
| 39 |
|
| 40 |
llvm::Optional<llvm::DIExpression::FragmentInfo> FragmentInfo; |
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
static Optional<DbgVariableLocation> |
| 48 |
extractFromMachineInstruction(const MachineInstr &Instruction); |
| 49 |
}; |
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
class DebugHandlerBase : public AsmPrinterHandler { |
| 54 |
protected: |
| 55 |
DebugHandlerBase(AsmPrinter *A); |
| 56 |
|
| 57 |
|
| 58 |
AsmPrinter *Asm; |
| 59 |
|
| 60 |
|
| 61 |
MachineModuleInfo *MMI; |
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
DebugLoc PrevInstLoc; |
| 68 |
MCSymbol *PrevLabel = nullptr; |
| 69 |
const MachineBasicBlock *PrevInstBB = nullptr; |
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
DebugLoc PrologEndLoc; |
| 74 |
|
| 75 |
|
| 76 |
const MachineInstr *CurMI = nullptr; |
| 77 |
|
| 78 |
LexicalScopes LScopes; |
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
DbgValueHistoryMap DbgValues; |
| 83 |
|
| 84 |
|
| 85 |
DbgLabelInstrMap DbgLabels; |
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
DenseMap<const MachineInstr *, MCSymbol *> LabelsBeforeInsn; |
| 91 |
|
| 92 |
|
| 93 |
DenseMap<const MachineInstr *, MCSymbol *> LabelsAfterInsn; |
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
void identifyScopeMarkers(); |
| 98 |
|
| 99 |
|
| 100 |
void requestLabelBeforeInsn(const MachineInstr *MI) { |
| 101 |
LabelsBeforeInsn.insert(std::make_pair(MI, nullptr)); |
| 102 |
} |
| 103 |
|
| 104 |
|
| 105 |
void requestLabelAfterInsn(const MachineInstr *MI) { |
| 106 |
LabelsAfterInsn.insert(std::make_pair(MI, nullptr)); |
| 107 |
} |
| 108 |
|
| 109 |
virtual void beginFunctionImpl(const MachineFunction *MF) = 0; |
| 110 |
virtual void endFunctionImpl(const MachineFunction *MF) = 0; |
| 111 |
virtual void skippedNonDebugFunction() {} |
| 112 |
|
| 113 |
private: |
| 114 |
InstructionOrdering InstOrdering; |
| 115 |
|
| 116 |
|
| 117 |
public: |
| 118 |
void beginModule(Module *M) override; |
| 119 |
|
| 120 |
void beginInstruction(const MachineInstr *MI) override; |
| 121 |
void endInstruction() override; |
| 122 |
|
| 123 |
void beginFunction(const MachineFunction *MF) override; |
| 124 |
void endFunction(const MachineFunction *MF) override; |
| 125 |
|
| 126 |
void beginBasicBlock(const MachineBasicBlock &MBB) override; |
| 127 |
void endBasicBlock(const MachineBasicBlock &MBB) override; |
| 128 |
|
| 129 |
|
| 130 |
MCSymbol *getLabelBeforeInsn(const MachineInstr *MI); |
| 131 |
|
| 132 |
|
| 133 |
MCSymbol *getLabelAfterInsn(const MachineInstr *MI); |
| 134 |
|
| 135 |
|
| 136 |
static uint64_t getBaseTypeSize(const DIType *Ty); |
| 137 |
|
| 138 |
|
| 139 |
static bool isUnsignedDIType(const DIType *Ty); |
| 140 |
|
| 141 |
const InstructionOrdering &getInstOrdering() const { return InstOrdering; } |
| 142 |
}; |
| 143 |
|
| 144 |
} |
| 145 |
|
| 146 |
#endif |