21#define DEBUG_TYPE "faultmaps"
24const char *FaultMaps::WFMP =
"Fault Maps: ";
41 FunctionInfos[AP.
CurrentFnSym].emplace_back(FaultTy, FaultingOffset,
46 if (FunctionInfos.empty())
55 OS.switchSection(FaultMapSection);
64 OS.emitIntValue(0, 1);
67 LLVM_DEBUG(
dbgs() << WFMP <<
"#functions = " << FunctionInfos.size() <<
"\n");
68 OS.emitInt32(FunctionInfos.size());
72 for (
const auto &FFI : FunctionInfos)
73 emitFunctionInfo(FFI.first, FFI.second);
76void FaultMaps::emitFunctionInfo(
const MCSymbol *FnLabel,
77 const FunctionFaultInfos &FFI) {
80 LLVM_DEBUG(
dbgs() << WFMP <<
" function addr: " << *FnLabel <<
"\n");
81 OS.emitSymbolValue(FnLabel, 8);
83 LLVM_DEBUG(
dbgs() << WFMP <<
" #faulting PCs: " << FFI.size() <<
"\n");
84 OS.emitInt32(FFI.size());
88 for (
const auto &
Fault : FFI) {
94 << *
Fault.FaultingOffsetExpr <<
"\n");
95 OS.emitValue(
Fault.FaultingOffsetExpr, 4);
98 << *
Fault.HandlerOffsetExpr <<
"\n");
99 OS.emitValue(
Fault.HandlerOffsetExpr, 4);
108 return "FaultingLoad";
110 return "FaultingLoadStore";
112 return "FaultingStore";
static const int FaultMapVersion
This class is intended to be used as a driving class for all asm writers.
MCSymbol * CurrentFnSym
The symbol for the current function.
std::unique_ptr< MCStreamer > OutStreamer
This is the MCStreamer object for the file we are generating.
MCSymbol * CurrentFnSymForSize
The symbol used to represent the start of the current function for the purpose of calculating its siz...
void recordFaultingOp(FaultKind FaultTy, const MCSymbol *FaultingLabel, const MCSymbol *HandlerLabel)
void serializeToFaultMapSection()
FaultMaps(AsmPrinter &AP)
static const char * faultTypeToString(FaultKind)
static const MCBinaryExpr * createSub(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Context object for machine code objects.
const MCObjectFileInfo * getObjectFileInfo() const
MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
Base class for the full range of assembler expressions which are needed for parsing.
MCSection * getFaultMapSection() const
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Streaming machine code generation interface.
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This is an optimization pass for GlobalISel generic memory operations.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.