LLVM 19.0.0git
WinEHFuncInfo.h
Go to the documentation of this file.
1//===- llvm/CodeGen/WinEHFuncInfo.h -----------------------------*- 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// Data structures and associated state for Windows exception handling schemes.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_CODEGEN_WINEHFUNCINFO_H
14#define LLVM_CODEGEN_WINEHFUNCINFO_H
15
16#include "llvm/ADT/DenseMap.h"
19#include <cstdint>
20#include <limits>
21#include <utility>
22
23namespace llvm {
24
25class AllocaInst;
26class BasicBlock;
27class FuncletPadInst;
28class Function;
29class GlobalVariable;
30class Instruction;
31class InvokeInst;
32class MachineBasicBlock;
33class MCSymbol;
34
35// The following structs respresent the .xdata tables for various
36// Windows-related EH personalities.
37
39
43};
44
45/// Similar to CxxUnwindMapEntry, but supports SEH filters.
47 /// If unwinding continues through this handler, transition to the handler at
48 /// this state. This indexes into SEHUnwindMap.
49 int ToState = -1;
50
51 bool IsFinally = false;
52
53 /// Holds the filter expression function.
54 const Function *Filter = nullptr;
55
56 /// Holds the __except or __finally basic block.
58};
59
62 /// The CatchObj starts out life as an LLVM alloca and is eventually turned
63 /// frame index.
64 union {
67 } CatchObj = {};
70};
71
73 int TryLow = -1;
74 int TryHigh = -1;
75 int CatchHigh = -1;
77};
78
80
84 int HandlerParentState; ///< Outer handler enclosing this entry's handler
85 int TryParentState; ///< Outer try region enclosing this entry's try region,
86 ///< treating later catches on same try as "outer"
88};
89
100 int UnwindHelpFrameIdx = std::numeric_limits<int>::max();
101 int PSPSymFrameIdx = std::numeric_limits<int>::max();
102
103 int getLastStateNumber() const { return CxxUnwindMap.size() - 1; }
104
105 void addIPToStateRange(const InvokeInst *II, MCSymbol *InvokeBegin,
106 MCSymbol *InvokeEnd);
107
108 void addIPToStateRange(int State, MCSymbol *InvokeBegin, MCSymbol *InvokeEnd);
109
110 int EHRegNodeFrameIndex = std::numeric_limits<int>::max();
111 int EHRegNodeEndOffset = std::numeric_limits<int>::max();
112 int EHGuardFrameIndex = std::numeric_limits<int>::max();
113 int SEHSetFrameOffset = std::numeric_limits<int>::max();
114
116};
117
118/// Analyze the IR in ParentFn and it's handlers to build WinEHFuncInfo, which
119/// describes the state numbers and tables used by __CxxFrameHandler3. This
120/// analysis assumes that WinEHPrepare has already been run.
121void calculateWinCXXEHStateNumbers(const Function *ParentFn,
122 WinEHFuncInfo &FuncInfo);
123
124void calculateSEHStateNumbers(const Function *ParentFn,
125 WinEHFuncInfo &FuncInfo);
126
127void calculateClrEHStateNumbers(const Function *Fn, WinEHFuncInfo &FuncInfo);
128
129// For AsynchEH (VC++ option -EHa)
130void calculateCXXStateForAsynchEH(const BasicBlock *BB, int State,
131 WinEHFuncInfo &FuncInfo);
132void calculateSEHStateForAsynchEH(const BasicBlock *BB, int State,
133 WinEHFuncInfo &FuncInfo);
134
135} // end namespace llvm
136
137#endif // LLVM_CODEGEN_WINEHFUNCINFO_H
This file defines the DenseMap class.
This file defines the PointerUnion class, which is a discriminated union of pointer types.
This file defines the SmallVector class.
an instruction to allocate memory on the stack
Definition: Instructions.h:60
LLVM Basic Block Representation.
Definition: BasicBlock.h:60
Invoke instruction.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:40
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1209
@ BasicBlock
Various leaf nodes.
Definition: ISDOpcodes.h:71
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
void calculateWinCXXEHStateNumbers(const Function *ParentFn, WinEHFuncInfo &FuncInfo)
Analyze the IR in ParentFn and it's handlers to build WinEHFuncInfo, which describes the state number...
void calculateSEHStateForAsynchEH(const BasicBlock *BB, int State, WinEHFuncInfo &FuncInfo)
void calculateCXXStateForAsynchEH(const BasicBlock *BB, int State, WinEHFuncInfo &FuncInfo)
void calculateSEHStateNumbers(const Function *ParentFn, WinEHFuncInfo &FuncInfo)
ClrHandlerType
Definition: WinEHFuncInfo.h:79
void calculateClrEHStateNumbers(const Function *Fn, WinEHFuncInfo &FuncInfo)
int TryParentState
Outer try region enclosing this entry's try region, treating later catches on same try as "outer".
Definition: WinEHFuncInfo.h:85
int HandlerParentState
Outer handler enclosing this entry's handler.
Definition: WinEHFuncInfo.h:84
MBBOrBasicBlock Handler
Definition: WinEHFuncInfo.h:82
ClrHandlerType HandlerType
Definition: WinEHFuncInfo.h:87
MBBOrBasicBlock Cleanup
Definition: WinEHFuncInfo.h:42
Similar to CxxUnwindMapEntry, but supports SEH filters.
Definition: WinEHFuncInfo.h:46
int ToState
If unwinding continues through this handler, transition to the handler at this state.
Definition: WinEHFuncInfo.h:49
MBBOrBasicBlock Handler
Holds the __except or __finally basic block.
Definition: WinEHFuncInfo.h:57
const Function * Filter
Holds the filter expression function.
Definition: WinEHFuncInfo.h:54
void addIPToStateRange(const InvokeInst *II, MCSymbol *InvokeBegin, MCSymbol *InvokeEnd)
SmallVector< SEHUnwindMapEntry, 4 > SEHUnwindMap
Definition: WinEHFuncInfo.h:98
SmallVector< ClrEHUnwindMapEntry, 4 > ClrEHUnwindMap
Definition: WinEHFuncInfo.h:99
DenseMap< const FuncletPadInst *, int > FuncletBaseStateMap
Definition: WinEHFuncInfo.h:92
DenseMap< const BasicBlock *, int > BlockToStateMap
Definition: WinEHFuncInfo.h:95
DenseMap< const InvokeInst *, int > InvokeStateMap
Definition: WinEHFuncInfo.h:93
SmallVector< WinEHTryBlockMapEntry, 4 > TryBlockMap
Definition: WinEHFuncInfo.h:97
DenseMap< const Instruction *, int > EHPadStateMap
Definition: WinEHFuncInfo.h:91
DenseMap< MCSymbol *, std::pair< int, MCSymbol * > > LabelToStateMap
Definition: WinEHFuncInfo.h:94
SmallVector< CxxUnwindMapEntry, 4 > CxxUnwindMap
Definition: WinEHFuncInfo.h:96
int getLastStateNumber() const
union llvm::WinEHHandlerType::@242 CatchObj
The CatchObj starts out life as an LLVM alloca and is eventually turned frame index.
GlobalVariable * TypeDescriptor
Definition: WinEHFuncInfo.h:68
const AllocaInst * Alloca
Definition: WinEHFuncInfo.h:65
MBBOrBasicBlock Handler
Definition: WinEHFuncInfo.h:69
SmallVector< WinEHHandlerType, 1 > HandlerArray
Definition: WinEHFuncInfo.h:76