| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
#ifndef LLVM_CODEGEN_WINEHFUNCINFO_H |
| 14 |
#define LLVM_CODEGEN_WINEHFUNCINFO_H |
| 15 |
|
| 16 |
#include "llvm/ADT/DenseMap.h" |
| 17 |
#include "llvm/ADT/PointerUnion.h" |
| 18 |
#include "llvm/ADT/SmallVector.h" |
| 19 |
#include <cstdint> |
| 20 |
#include <limits> |
| 21 |
#include <utility> |
| 22 |
|
| 23 |
namespace llvm { |
| 24 |
|
| 25 |
class AllocaInst; |
| 26 |
class BasicBlock; |
| 27 |
class FuncletPadInst; |
| 28 |
class Function; |
| 29 |
class GlobalVariable; |
| 30 |
class Instruction; |
| 31 |
class InvokeInst; |
| 32 |
class MachineBasicBlock; |
| 33 |
class MCSymbol; |
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
using MBBOrBasicBlock = PointerUnion<const BasicBlock *, MachineBasicBlock *>; |
| 39 |
|
| 40 |
struct CxxUnwindMapEntry { |
| 41 |
int ToState; |
| 42 |
MBBOrBasicBlock Cleanup; |
| 43 |
}; |
| 44 |
|
| 45 |
|
| 46 |
struct SEHUnwindMapEntry { |
| 47 |
|
| 48 |
|
| 49 |
int ToState = -1; |
| 50 |
|
| 51 |
bool IsFinally = false; |
| 52 |
|
| 53 |
|
| 54 |
const Function *Filter = nullptr; |
| 55 |
|
| 56 |
|
| 57 |
MBBOrBasicBlock Handler; |
| 58 |
}; |
| 59 |
|
| 60 |
struct WinEHHandlerType { |
| 61 |
int Adjectives; |
| 62 |
|
| 63 |
|
| 64 |
union { |
| 65 |
const AllocaInst *Alloca; |
| 66 |
int FrameIndex; |
| 67 |
} CatchObj = {}; |
| 68 |
GlobalVariable *TypeDescriptor; |
| 69 |
MBBOrBasicBlock Handler; |
| 70 |
}; |
| 71 |
|
| 72 |
struct WinEHTryBlockMapEntry { |
| 73 |
int TryLow = -1; |
| 74 |
int TryHigh = -1; |
| 75 |
int CatchHigh = -1; |
| 76 |
SmallVector<WinEHHandlerType, 1> HandlerArray; |
| 77 |
}; |
| 78 |
|
| 79 |
enum class ClrHandlerType { Catch, Finally, Fault, Filter }; |
| 80 |
|
| 81 |
struct ClrEHUnwindMapEntry { |
| 82 |
MBBOrBasicBlock Handler; |
| 83 |
uint32_t TypeToken; |
| 84 |
int HandlerParentState; |
| 85 |
int TryParentState; |
| 86 |
|
| 87 |
ClrHandlerType HandlerType; |
| 88 |
}; |
| 89 |
|
| 90 |
struct WinEHFuncInfo { |
| 91 |
DenseMap<const Instruction *, int> EHPadStateMap; |
| 92 |
DenseMap<const FuncletPadInst *, int> FuncletBaseStateMap; |
| 93 |
DenseMap<const InvokeInst *, int> InvokeStateMap; |
| 94 |
DenseMap<MCSymbol *, std::pair<int, MCSymbol *>> LabelToStateMap; |
| 95 |
SmallVector<CxxUnwindMapEntry, 4> CxxUnwindMap; |
| 96 |
SmallVector<WinEHTryBlockMapEntry, 4> TryBlockMap; |
| 97 |
SmallVector<SEHUnwindMapEntry, 4> SEHUnwindMap; |
| 98 |
SmallVector<ClrEHUnwindMapEntry, 4> ClrEHUnwindMap; |
| 99 |
int UnwindHelpFrameIdx = std::numeric_limits<int>::max(); |
| 100 |
int PSPSymFrameIdx = std::numeric_limits<int>::max(); |
| 101 |
|
| 102 |
int getLastStateNumber() const { return CxxUnwindMap.size() - 1; } |
| 103 |
|
| 104 |
void addIPToStateRange(const InvokeInst *II, MCSymbol *InvokeBegin, |
| 105 |
MCSymbol *InvokeEnd); |
| 106 |
|
| 107 |
int EHRegNodeFrameIndex = std::numeric_limits<int>::max(); |
| 108 |
int EHRegNodeEndOffset = std::numeric_limits<int>::max(); |
| 109 |
int EHGuardFrameIndex = std::numeric_limits<int>::max(); |
| 110 |
int SEHSetFrameOffset = std::numeric_limits<int>::max(); |
| 111 |
|
| 112 |
WinEHFuncInfo(); |
| 113 |
}; |
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
void calculateWinCXXEHStateNumbers(const Function *ParentFn, |
| 119 |
WinEHFuncInfo &FuncInfo); |
| 120 |
|
| 121 |
void calculateSEHStateNumbers(const Function *ParentFn, |
| 122 |
WinEHFuncInfo &FuncInfo); |
| 123 |
|
| 124 |
void calculateClrEHStateNumbers(const Function *Fn, WinEHFuncInfo &FuncInfo); |
| 125 |
|
| 126 |
} |
| 127 |
|
| 128 |
#endif |