LLVM 23.0.0git
FaultMaps.h
Go to the documentation of this file.
1//===- FaultMaps.h - The "FaultMaps" section --------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_CODEGEN_FAULTMAPS_H
10#define LLVM_CODEGEN_FAULTMAPS_H
11
12#include "llvm/MC/MCSymbol.h"
13#include <map>
14#include <vector>
15
16namespace llvm {
17
18class AsmPrinter;
19class MCExpr;
20
21class FaultMaps {
22public:
29
30 LLVM_ABI explicit FaultMaps(AsmPrinter &AP);
31
32 LLVM_ABI static const char *faultTypeToString(FaultKind);
33
34 LLVM_ABI void recordFaultingOp(FaultKind FaultTy,
35 const MCSymbol *FaultingLabel,
36 const MCSymbol *HandlerLabel);
38 void reset() {
39 FunctionInfos.clear();
40 }
41
42private:
43 static const char *WFMP;
44
45 struct FaultInfo {
46 FaultKind Kind = FaultKindMax;
47 const MCExpr *FaultingOffsetExpr = nullptr;
48 const MCExpr *HandlerOffsetExpr = nullptr;
49
50 FaultInfo() = default;
51
52 explicit FaultInfo(FaultMaps::FaultKind Kind, const MCExpr *FaultingOffset,
53 const MCExpr *HandlerOffset)
54 : Kind(Kind), FaultingOffsetExpr(FaultingOffset),
55 HandlerOffsetExpr(HandlerOffset) {}
56 };
57
58 using FunctionFaultInfos = std::vector<FaultInfo>;
59
60 // We'd like to keep a stable iteration order for FunctionInfos to help
61 // FileCheck based testing.
62 struct MCSymbolComparator {
63 bool operator()(const MCSymbol *LHS, const MCSymbol *RHS) const {
64 return LHS->getName() < RHS->getName();
65 }
66 };
67
68 std::map<const MCSymbol *, FunctionFaultInfos, MCSymbolComparator>
69 FunctionInfos;
70 AsmPrinter &AP;
71
72 void emitFunctionInfo(const MCSymbol *FnLabel, const FunctionFaultInfos &FFI);
73};
74
75} // end namespace llvm
76
77#endif // LLVM_CODEGEN_FAULTMAPS_H
#define LLVM_ABI
Definition Compiler.h:213
Value * RHS
Value * LHS
This class is intended to be used as a driving class for all asm writers.
Definition AsmPrinter.h:91
LLVM_ABI void recordFaultingOp(FaultKind FaultTy, const MCSymbol *FaultingLabel, const MCSymbol *HandlerLabel)
Definition FaultMaps.cpp:28
LLVM_ABI void serializeToFaultMapSection()
Definition FaultMaps.cpp:45
LLVM_ABI FaultMaps(AsmPrinter &AP)
Definition FaultMaps.cpp:26
static LLVM_ABI const char * faultTypeToString(FaultKind)
Definition FaultMaps.cpp:95
Base class for the full range of assembler expressions which are needed for parsing.
Definition MCExpr.h:34
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition MCSymbol.h:42
This is an optimization pass for GlobalISel generic memory operations.