mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 03:02:36 +01:00
ae65e281f3
to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
129 lines
4.0 KiB
C++
129 lines
4.0 KiB
C++
//===- llvm/CodeGen/WinEHFuncInfo.h -----------------------------*- C++ -*-===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// Data structures and associated state for Windows exception handling schemes.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef LLVM_CODEGEN_WINEHFUNCINFO_H
|
|
#define LLVM_CODEGEN_WINEHFUNCINFO_H
|
|
|
|
#include "llvm/ADT/DenseMap.h"
|
|
#include "llvm/ADT/PointerUnion.h"
|
|
#include "llvm/ADT/SmallVector.h"
|
|
#include <cstdint>
|
|
#include <limits>
|
|
#include <utility>
|
|
|
|
namespace llvm {
|
|
|
|
class AllocaInst;
|
|
class BasicBlock;
|
|
class FuncletPadInst;
|
|
class Function;
|
|
class GlobalVariable;
|
|
class Instruction;
|
|
class InvokeInst;
|
|
class MachineBasicBlock;
|
|
class MCSymbol;
|
|
|
|
// The following structs respresent the .xdata tables for various
|
|
// Windows-related EH personalities.
|
|
|
|
using MBBOrBasicBlock = PointerUnion<const BasicBlock *, MachineBasicBlock *>;
|
|
|
|
struct CxxUnwindMapEntry {
|
|
int ToState;
|
|
MBBOrBasicBlock Cleanup;
|
|
};
|
|
|
|
/// Similar to CxxUnwindMapEntry, but supports SEH filters.
|
|
struct SEHUnwindMapEntry {
|
|
/// If unwinding continues through this handler, transition to the handler at
|
|
/// this state. This indexes into SEHUnwindMap.
|
|
int ToState = -1;
|
|
|
|
bool IsFinally = false;
|
|
|
|
/// Holds the filter expression function.
|
|
const Function *Filter = nullptr;
|
|
|
|
/// Holds the __except or __finally basic block.
|
|
MBBOrBasicBlock Handler;
|
|
};
|
|
|
|
struct WinEHHandlerType {
|
|
int Adjectives;
|
|
/// The CatchObj starts out life as an LLVM alloca and is eventually turned
|
|
/// frame index.
|
|
union {
|
|
const AllocaInst *Alloca;
|
|
int FrameIndex;
|
|
} CatchObj = {};
|
|
GlobalVariable *TypeDescriptor;
|
|
MBBOrBasicBlock Handler;
|
|
};
|
|
|
|
struct WinEHTryBlockMapEntry {
|
|
int TryLow = -1;
|
|
int TryHigh = -1;
|
|
int CatchHigh = -1;
|
|
SmallVector<WinEHHandlerType, 1> HandlerArray;
|
|
};
|
|
|
|
enum class ClrHandlerType { Catch, Finally, Fault, Filter };
|
|
|
|
struct ClrEHUnwindMapEntry {
|
|
MBBOrBasicBlock Handler;
|
|
uint32_t TypeToken;
|
|
int HandlerParentState; ///< Outer handler enclosing this entry's handler
|
|
int TryParentState; ///< Outer try region enclosing this entry's try region,
|
|
///< treating later catches on same try as "outer"
|
|
ClrHandlerType HandlerType;
|
|
};
|
|
|
|
struct WinEHFuncInfo {
|
|
DenseMap<const Instruction *, int> EHPadStateMap;
|
|
DenseMap<const FuncletPadInst *, int> FuncletBaseStateMap;
|
|
DenseMap<const InvokeInst *, int> InvokeStateMap;
|
|
DenseMap<MCSymbol *, std::pair<int, MCSymbol *>> LabelToStateMap;
|
|
SmallVector<CxxUnwindMapEntry, 4> CxxUnwindMap;
|
|
SmallVector<WinEHTryBlockMapEntry, 4> TryBlockMap;
|
|
SmallVector<SEHUnwindMapEntry, 4> SEHUnwindMap;
|
|
SmallVector<ClrEHUnwindMapEntry, 4> ClrEHUnwindMap;
|
|
int UnwindHelpFrameIdx = std::numeric_limits<int>::max();
|
|
int PSPSymFrameIdx = std::numeric_limits<int>::max();
|
|
|
|
int getLastStateNumber() const { return CxxUnwindMap.size() - 1; }
|
|
|
|
void addIPToStateRange(const InvokeInst *II, MCSymbol *InvokeBegin,
|
|
MCSymbol *InvokeEnd);
|
|
|
|
int EHRegNodeFrameIndex = std::numeric_limits<int>::max();
|
|
int EHRegNodeEndOffset = std::numeric_limits<int>::max();
|
|
int EHGuardFrameIndex = std::numeric_limits<int>::max();
|
|
int SEHSetFrameOffset = std::numeric_limits<int>::max();
|
|
|
|
WinEHFuncInfo();
|
|
};
|
|
|
|
/// Analyze the IR in ParentFn and it's handlers to build WinEHFuncInfo, which
|
|
/// describes the state numbers and tables used by __CxxFrameHandler3. This
|
|
/// analysis assumes that WinEHPrepare has already been run.
|
|
void calculateWinCXXEHStateNumbers(const Function *ParentFn,
|
|
WinEHFuncInfo &FuncInfo);
|
|
|
|
void calculateSEHStateNumbers(const Function *ParentFn,
|
|
WinEHFuncInfo &FuncInfo);
|
|
|
|
void calculateClrEHStateNumbers(const Function *Fn, WinEHFuncInfo &FuncInfo);
|
|
|
|
} // end namespace llvm
|
|
|
|
#endif // LLVM_CODEGEN_WINEHFUNCINFO_H
|