LLVM 24.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 void recordFaultingOp(FaultKind FaultTy,
33 const MCSymbol *FaultingLabel,
34 const MCSymbol *HandlerLabel);
36 void reset() {
37 FunctionInfos.clear();
38 }
39
40private:
41 static const char *WFMP;
42
43 struct FaultInfo {
44 FaultKind Kind = FaultKindMax;
45 const MCExpr *FaultingOffsetExpr = nullptr;
46 const MCExpr *HandlerOffsetExpr = nullptr;
47
48 FaultInfo() = default;
49
50 explicit FaultInfo(FaultMaps::FaultKind Kind, const MCExpr *FaultingOffset,
51 const MCExpr *HandlerOffset)
52 : Kind(Kind), FaultingOffsetExpr(FaultingOffset),
53 HandlerOffsetExpr(HandlerOffset) {}
54 };
55
56 using FunctionFaultInfos = std::vector<FaultInfo>;
57
58 // We'd like to keep a stable iteration order for FunctionInfos to help
59 // FileCheck based testing.
60 struct MCSymbolComparator {
61 bool operator()(const MCSymbol *LHS, const MCSymbol *RHS) const {
62 return LHS->getName() < RHS->getName();
63 }
64 };
65
66 std::map<const MCSymbol *, FunctionFaultInfos, MCSymbolComparator>
67 FunctionInfos;
68 AsmPrinter &AP;
69
70 void emitFunctionInfo(const MCSymbol *FnLabel, const FunctionFaultInfos &FFI);
71};
72
73} // end namespace llvm
74
75#endif // LLVM_CODEGEN_FAULTMAPS_H
#define LLVM_ABI
Definition Compiler.h:211
Value * RHS
Value * LHS
This class is intended to be used as a driving class for all asm writers.
Definition AsmPrinter.h:95
LLVM_ABI void recordFaultingOp(FaultKind FaultTy, const MCSymbol *FaultingLabel, const MCSymbol *HandlerLabel)
Definition FaultMaps.cpp:27
LLVM_ABI void serializeToFaultMapSection()
Definition FaultMaps.cpp:44
LLVM_ABI FaultMaps(AsmPrinter &AP)
Definition FaultMaps.cpp:25
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.