#include "MCTargetDesc/WebAssemblyMCTargetDesc.h"
#include "Utils/WebAssemblyTypeUtilities.h"
#include "WebAssembly.h"
#include "WebAssemblyExceptionInfo.h"
#include "WebAssemblyMachineFunctionInfo.h"
#include "WebAssemblySortRegion.h"
#include "WebAssemblySubtarget.h"
#include "WebAssemblyUtilities.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/BinaryFormat/Wasm.h"
#include "llvm/CodeGen/MachineDominators.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/MachineLoopInfo.h"
#include "llvm/CodeGen/WasmEHFuncInfo.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/Target/TargetMachine.h"
usingnamespacellvm;
SortRegionInfo;
#define DEBUG_TYPE …
STATISTIC(NumCallUnwindMismatches, "Number of call unwind mismatches found");
STATISTIC(NumCatchUnwindMismatches, "Number of catch unwind mismatches found");
namespace {
class WebAssemblyCFGStackify final : public MachineFunctionPass { … };
}
char WebAssemblyCFGStackify::ID = …;
INITIALIZE_PASS(…)
FunctionPass *llvm::createWebAssemblyCFGStackify() { … }
static bool explicitlyBranchesTo(MachineBasicBlock *Pred,
MachineBasicBlock *MBB) { … }
template <typename Container>
static MachineBasicBlock::iterator
getEarliestInsertPos(MachineBasicBlock *MBB, const Container &BeforeSet,
const Container &AfterSet) { … }
template <typename Container>
static MachineBasicBlock::iterator
getLatestInsertPos(MachineBasicBlock *MBB, const Container &BeforeSet,
const Container &AfterSet) { … }
void WebAssemblyCFGStackify::registerScope(MachineInstr *Begin,
MachineInstr *End) { … }
void WebAssemblyCFGStackify::registerTryScope(MachineInstr *Begin,
MachineInstr *End,
MachineBasicBlock *EHPad) { … }
void WebAssemblyCFGStackify::unregisterScope(MachineInstr *Begin) { … }
void WebAssemblyCFGStackify::placeBlockMarker(MachineBasicBlock &MBB) { … }
void WebAssemblyCFGStackify::placeLoopMarker(MachineBasicBlock &MBB) { … }
void WebAssemblyCFGStackify::placeTryMarker(MachineBasicBlock &MBB) { … }
void WebAssemblyCFGStackify::placeTryTableMarker(MachineBasicBlock &MBB) { … }
void WebAssemblyCFGStackify::removeUnnecessaryInstrs(MachineFunction &MF) { … }
static void unstackifyVRegsUsedInSplitBB(MachineBasicBlock &MBB,
MachineBasicBlock &Split) { … }
void WebAssemblyCFGStackify::addNestedTryDelegate(
MachineInstr *RangeBegin, MachineInstr *RangeEnd,
MachineBasicBlock *UnwindDest) { … }
bool WebAssemblyCFGStackify::fixCallUnwindMismatches(MachineFunction &MF) { … }
bool WebAssemblyCFGStackify::fixCatchUnwindMismatches(MachineFunction &MF) { … }
void WebAssemblyCFGStackify::recalculateScopeTops(MachineFunction &MF) { … }
void WebAssemblyCFGStackify::fixEndsAtEndOfFunction(MachineFunction &MF) { … }
static void appendEndToFunction(MachineFunction &MF,
const WebAssemblyInstrInfo &TII) { … }
void WebAssemblyCFGStackify::placeMarkers(MachineFunction &MF) { … }
unsigned WebAssemblyCFGStackify::getBranchDepth(
const SmallVectorImpl<EndMarkerInfo> &Stack, const MachineBasicBlock *MBB) { … }
unsigned WebAssemblyCFGStackify::getDelegateDepth(
const SmallVectorImpl<EndMarkerInfo> &Stack, const MachineBasicBlock *MBB) { … }
unsigned WebAssemblyCFGStackify::getRethrowDepth(
const SmallVectorImpl<EndMarkerInfo> &Stack,
const SmallVectorImpl<const MachineBasicBlock *> &EHPadStack) { … }
void WebAssemblyCFGStackify::rewriteDepthImmediates(MachineFunction &MF) { … }
void WebAssemblyCFGStackify::cleanupFunctionData(MachineFunction &MF) { … }
void WebAssemblyCFGStackify::releaseMemory() { … }
bool WebAssemblyCFGStackify::runOnMachineFunction(MachineFunction &MF) { … }