10 #ifndef LLVM_CODEGEN_FAULTMAPS_H 11 #define LLVM_CODEGEN_FAULTMAPS_H 43 FunctionInfos.clear();
47 static const char *WFMP;
51 const MCExpr *FaultingOffsetExpr =
nullptr;
52 const MCExpr *HandlerOffsetExpr =
nullptr;
54 FaultInfo() =
default;
57 const MCExpr *HandlerOffset)
58 :
Kind(Kind), FaultingOffsetExpr(FaultingOffset),
59 HandlerOffsetExpr(HandlerOffset) {}
62 using FunctionFaultInfos = std::vector<FaultInfo>;
66 struct MCSymbolComparator {
72 std::map<const MCSymbol *, FunctionFaultInfos, MCSymbolComparator>
76 void emitFunctionInfo(
const MCSymbol *FnLabel,
const FunctionFaultInfos &FFI);
84 using FaultMapVersionType = uint8_t;
85 using Reserved0Type = uint8_t;
86 using Reserved1Type = uint16_t;
89 static const size_t FaultMapVersionOffset = 0;
90 static const size_t Reserved0Offset =
91 FaultMapVersionOffset +
sizeof(FaultMapVersionType);
92 static const size_t Reserved1Offset = Reserved0Offset +
sizeof(Reserved0Type);
93 static const size_t NumFunctionsOffset =
94 Reserved1Offset +
sizeof(Reserved1Type);
95 static const size_t FunctionInfosOffset =
101 template <
typename T>
static T read(
const uint8_t *P,
const uint8_t *E) {
102 assert(P +
sizeof(
T) <= E &&
"out of bounds read!");
103 return support::endian::read<T, support::little, 1>(
P);
112 static const size_t FaultKindOffset = 0;
113 static const size_t FaultingPCOffsetOffset =
115 static const size_t HandlerPCOffsetOffset =
129 return read<FaultKindType>(P + FaultKindOffset,
E);
133 return read<FaultingPCOffsetType>(P + FaultingPCOffsetOffset,
E);
137 return read<HandlerPCOffsetType>(P + HandlerPCOffsetOffset,
E);
142 using FunctionAddrType = uint64_t;
146 static const size_t FunctionAddrOffset = 0;
147 static const size_t NumFaultingPCsOffset =
148 FunctionAddrOffset +
sizeof(FunctionAddrType);
149 static const size_t ReservedOffset =
151 static const size_t FunctionFaultInfosOffset =
153 static const size_t FunctionInfoHeaderSize = FunctionFaultInfosOffset;
155 const uint8_t *P =
nullptr;
156 const uint8_t *E =
nullptr;
165 return read<FunctionAddrType>(P + FunctionAddrOffset,
E);
169 return read<NumFaultingPCsType>(P + NumFaultingPCsOffset,
E);
173 assert(Index < getNumFaultingPCs() &&
"index out of bounds!");
174 const uint8_t *Begin = P + FunctionFaultInfosOffset +
180 size_t MySize = FunctionInfoHeaderSize +
183 const uint8_t *Begin = P + MySize;
184 assert(Begin < E &&
"out of bounds!");
190 : P(Begin), E(End) {}
193 auto Version = read<FaultMapVersionType>(P + FaultMapVersionOffset,
E);
199 return read<NumFunctionsType>(P + NumFunctionsOffset,
E);
203 const uint8_t *Begin = P + FunctionInfosOffset;
218 #endif // LLVM_CODEGEN_FAULTMAPS_H FaultingPCOffsetType getFaultingPCOffset() const
This class represents lattice values for constants.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
HandlerPCOffsetType getHandlerPCOffset() const
FunctionAddrType getFunctionAddr() const
FaultKindType getFaultKind() const
Base class for the full range of assembler expressions which are needed for parsing.
FunctionInfoAccessor getFirstFunctionInfo() const
void recordFaultingOp(FaultKind FaultTy, const MCSymbol *HandlerLabel)
FaultMapParser(const uint8_t *Begin, const uint8_t *End)
NumFunctionsType getNumFunctions() const
FaultMaps(AsmPrinter &AP)
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This class is intended to be used as a driving class for all asm writers.
FunctionFaultInfoAccessor getFunctionFaultInfoAt(uint32_t Index) const
A parser for the __llvm_faultmaps section generated by the FaultMaps class above. ...
void serializeToFaultMapSection()
FunctionFaultInfoAccessor(const uint8_t *P, const uint8_t *E)
static const char * faultTypeToString(FaultKind)
value_type read(const void *memory, endianness endian)
Read a value of a particular endianness from memory.
raw_ostream & operator<<(raw_ostream &OS, const APInt &I)
StringRef getName() const
getName - Get the symbol name.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
FaultMapVersionType getFaultMapVersion() const
This class implements an extremely fast bulk output stream that can only output to a stream...
NumFaultingPCsType getNumFaultingPCs() const
FunctionInfoAccessor getNextFunctionInfo() const
FunctionInfoAccessor(const uint8_t *P, const uint8_t *E)