LLVM 20.0.0git
|
This file implements a CFG stacking pass. More...
#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/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"
Go to the source code of this file.
Macros | |
#define | DEBUG_TYPE "wasm-cfg-stackify" |
Functions | |
STATISTIC (NumCallUnwindMismatches, "Number of call unwind mismatches found") | |
STATISTIC (NumCatchUnwindMismatches, "Number of catch unwind mismatches found") | |
INITIALIZE_PASS (WebAssemblyCFGStackify, DEBUG_TYPE, "Insert BLOCK/LOOP/TRY markers for WebAssembly scopes", false, false) FunctionPass *llvm | |
static bool | explicitlyBranchesTo (MachineBasicBlock *Pred, MachineBasicBlock *MBB) |
Test whether Pred has any terminators explicitly branching to MBB, as opposed to falling through. | |
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) |
static void | unstackifyVRegsUsedInSplitBB (MachineBasicBlock &MBB, MachineBasicBlock &Split) |
static void | appendEndToFunction (MachineFunction &MF, const WebAssemblyInstrInfo &TII) |
This file implements a CFG stacking pass.
This pass inserts BLOCK, LOOP, and TRY markers to mark the start of scopes, since scope boundaries serve as the labels for WebAssembly's control transfers.
This is sufficient to convert arbitrary CFGs into a form that works on WebAssembly, provided that all loops are single-entry.
In case we use exceptions, this pass also fixes mismatches in unwind destinations created during transforming CFG into wasm structured format.
Definition in file WebAssemblyCFGStackify.cpp.
#define DEBUG_TYPE "wasm-cfg-stackify" |
Definition at line 41 of file WebAssemblyCFGStackify.cpp.
|
static |
Definition at line 1530 of file WebAssemblyCFGStackify.cpp.
References llvm::MachineFunction::back(), llvm::BuildMI(), llvm::MachineBasicBlock::end(), llvm::MachineBasicBlock::findPrevDebugLoc(), and TII.
|
static |
Test whether Pred has any terminators explicitly branching to MBB, as opposed to falling through.
Note that it's possible (eg. in unoptimized code) for a branch instruction to both branch to a block and fallthrough to it, so we check the actual branch operands to see if there are any explicit mentions.
Definition at line 165 of file WebAssemblyCFGStackify.cpp.
References MBB, MI, and llvm::MachineBasicBlock::terminators().
|
static |
Definition at line 181 of file WebAssemblyCFGStackify.cpp.
References assert(), llvm::MachineBasicBlock::begin(), llvm::MachineBasicBlock::end(), and MBB.
|
static |
Definition at line 205 of file WebAssemblyCFGStackify.cpp.
References assert(), llvm::MachineBasicBlock::begin(), llvm::MachineBasicBlock::end(), and MBB.
INITIALIZE_PASS | ( | WebAssemblyCFGStackify | , |
DEBUG_TYPE | , | ||
"Insert BLOCK/LOOP/TRY markers for WebAssembly scopes" | , | ||
false | , | ||
false | |||
) |
Definition at line 152 of file WebAssemblyCFGStackify.cpp.
STATISTIC | ( | NumCallUnwindMismatches | , |
"Number of call unwind mismatches found" | |||
) |
STATISTIC | ( | NumCatchUnwindMismatches | , |
"Number of catch unwind mismatches found" | |||
) |
|
static |
Definition at line 787 of file WebAssemblyCFGStackify.cpp.
References llvm::MachineInstrBuilder::addReg(), llvm::BuildMI(), llvm::WebAssembly::getCopyOpcodeForRegClass(), llvm::MachineFunction::getInfo(), llvm::MachineBasicBlock::getParent(), llvm::MachineFunction::getRegInfo(), llvm::MachineFunction::getSubtarget(), llvm::WebAssembly::isTee(), llvm::make_early_inc_range(), MBB, MI, MRI, and TII.