LLVM  8.0.1
WinEHFuncInfo.h
Go to the documentation of this file.
1 //===- llvm/CodeGen/WinEHFuncInfo.h -----------------------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // Data structures and associated state for Windows exception handling schemes.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_CODEGEN_WINEHFUNCINFO_H
15 #define LLVM_CODEGEN_WINEHFUNCINFO_H
16 
17 #include "llvm/ADT/DenseMap.h"
18 #include "llvm/ADT/PointerUnion.h"
19 #include "llvm/ADT/SmallVector.h"
20 #include <cstdint>
21 #include <limits>
22 #include <utility>
23 
24 namespace llvm {
25 
26 class AllocaInst;
27 class BasicBlock;
28 class FuncletPadInst;
29 class Function;
30 class GlobalVariable;
31 class Instruction;
32 class InvokeInst;
33 class MachineBasicBlock;
34 class MCSymbol;
35 
36 // The following structs respresent the .xdata tables for various
37 // Windows-related EH personalities.
38 
40 
42  int ToState;
44 };
45 
46 /// Similar to CxxUnwindMapEntry, but supports SEH filters.
48  /// If unwinding continues through this handler, transition to the handler at
49  /// this state. This indexes into SEHUnwindMap.
50  int ToState = -1;
51 
52  bool IsFinally = false;
53 
54  /// Holds the filter expression function.
55  const Function *Filter = nullptr;
56 
57  /// Holds the __except or __finally basic block.
59 };
60 
63  /// The CatchObj starts out life as an LLVM alloca and is eventually turned
64  /// frame index.
65  union {
68  } CatchObj = {};
71 };
72 
74  int TryLow = -1;
75  int TryHigh = -1;
76  int CatchHigh = -1;
78 };
79 
81 
85  int HandlerParentState; ///< Outer handler enclosing this entry's handler
86  int TryParentState; ///< Outer try region enclosing this entry's try region,
87  ///< treating later catches on same try as "outer"
89 };
90 
91 struct WinEHFuncInfo {
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  int EHRegNodeFrameIndex = std::numeric_limits<int>::max();
109  int EHRegNodeEndOffset = std::numeric_limits<int>::max();
110  int EHGuardFrameIndex = std::numeric_limits<int>::max();
111  int SEHSetFrameOffset = std::numeric_limits<int>::max();
112 
113  WinEHFuncInfo();
114 };
115 
116 /// Analyze the IR in ParentFn and it's handlers to build WinEHFuncInfo, which
117 /// describes the state numbers and tables used by __CxxFrameHandler3. This
118 /// analysis assumes that WinEHPrepare has already been run.
119 void calculateWinCXXEHStateNumbers(const Function *ParentFn,
120  WinEHFuncInfo &FuncInfo);
121 
122 void calculateSEHStateNumbers(const Function *ParentFn,
123  WinEHFuncInfo &FuncInfo);
124 
125 void calculateClrEHStateNumbers(const Function *Fn, WinEHFuncInfo &FuncInfo);
126 
127 } // end namespace llvm
128 
129 #endif // LLVM_CODEGEN_WINEHFUNCINFO_H
MBBOrBasicBlock Handler
Definition: WinEHFuncInfo.h:83
SmallVector< WinEHHandlerType, 1 > HandlerArray
Definition: WinEHFuncInfo.h:77
int getLastStateNumber() const
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
DenseMap< MCSymbol *, std::pair< int, MCSymbol * > > LabelToStateMap
Definition: WinEHFuncInfo.h:95
MBBOrBasicBlock Cleanup
Definition: WinEHFuncInfo.h:43
This class represents lattice values for constants.
Definition: AllocatorList.h:24
Various leaf nodes.
Definition: ISDOpcodes.h:60
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:42
SmallVector< SEHUnwindMapEntry, 4 > SEHUnwindMap
Definition: WinEHFuncInfo.h:98
DenseMap< const FuncletPadInst *, int > FuncletBaseStateMap
Definition: WinEHFuncInfo.h:93
const AllocaInst * Alloca
Definition: WinEHFuncInfo.h:66
MBBOrBasicBlock Handler
Holds the __except or __finally basic block.
Definition: WinEHFuncInfo.h:58
void calculateSEHStateNumbers(const Function *ParentFn, WinEHFuncInfo &FuncInfo)
int TryParentState
Outer try region enclosing this entry&#39;s try region, treating later catches on same try as "outer"...
Definition: WinEHFuncInfo.h:86
ClrHandlerType
Definition: WinEHFuncInfo.h:80
Similar to CxxUnwindMapEntry, but supports SEH filters.
Definition: WinEHFuncInfo.h:47
SmallVector< ClrEHUnwindMapEntry, 4 > ClrEHUnwindMap
Definition: WinEHFuncInfo.h:99
DenseMap< const Instruction *, int > EHPadStateMap
Definition: WinEHFuncInfo.h:92
DenseMap< const InvokeInst *, int > InvokeStateMap
Definition: WinEHFuncInfo.h:94
void calculateClrEHStateNumbers(const Function *Fn, WinEHFuncInfo &FuncInfo)
size_t size() const
Definition: SmallVector.h:53
MBBOrBasicBlock Handler
Definition: WinEHFuncInfo.h:70
void calculateWinCXXEHStateNumbers(const Function *ParentFn, WinEHFuncInfo &FuncInfo)
Analyze the IR in ParentFn and it&#39;s handlers to build WinEHFuncInfo, which describes the state number...
SmallVector< CxxUnwindMapEntry, 4 > CxxUnwindMap
Definition: WinEHFuncInfo.h:96
This is a &#39;vector&#39; (really, a variable-sized array), optimized for the case when the array is small...
Definition: SmallVector.h:847
int HandlerParentState
Outer handler enclosing this entry&#39;s handler.
Definition: WinEHFuncInfo.h:85
SmallVector< WinEHTryBlockMapEntry, 4 > TryBlockMap
Definition: WinEHFuncInfo.h:97
GlobalVariable * TypeDescriptor
Definition: WinEHFuncInfo.h:69
ClrHandlerType HandlerType
Definition: WinEHFuncInfo.h:88
Invoke instruction.
an instruction to allocate memory on the stack
Definition: Instructions.h:60
A discriminated union of two pointer types, with the discriminator in the low bit of the pointer...
Definition: PointerUnion.h:87