LLVM 20.0.0git
|
This file implements a CFG stacking pass. More...
#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"
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/TRY_TABLE 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 | splitEndLoopBB (MachineBasicBlock *UnwindDest) |
static MachineBasicBlock * | getSingleUnwindDest (const MachineInstr *TryTable) |
static void | appendEndToFunction (MachineFunction &MF, const WebAssemblyInstrInfo &TII) |
This file implements a CFG stacking pass.
This pass inserts BLOCK, LOOP, TRY, and TRY_TABLE 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 43 of file WebAssemblyCFGStackify.cpp.
|
static |
Definition at line 2368 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 194 of file WebAssemblyCFGStackify.cpp.
References MBB, MI, and llvm::MachineBasicBlock::terminators().
|
static |
Definition at line 210 of file WebAssemblyCFGStackify.cpp.
References assert(), llvm::MachineBasicBlock::begin(), llvm::MachineBasicBlock::end(), and MBB.
|
static |
Definition at line 234 of file WebAssemblyCFGStackify.cpp.
References assert(), llvm::MachineBasicBlock::begin(), llvm::MachineBasicBlock::end(), and MBB.
|
static |
Definition at line 1991 of file WebAssemblyCFGStackify.cpp.
References llvm::MachineOperand::getImm(), llvm::MachineOperand::getMBB(), llvm::MachineInstr::getOperand(), llvm_unreachable, llvm::wasm::WASM_OPCODE_CATCH, llvm::wasm::WASM_OPCODE_CATCH_ALL, llvm::wasm::WASM_OPCODE_CATCH_ALL_REF, and llvm::wasm::WASM_OPCODE_CATCH_REF.
INITIALIZE_PASS | ( | WebAssemblyCFGStackify | , |
DEBUG_TYPE | , | ||
"Insert BLOCK/LOOP/TRY/TRY_TABLE markers for WebAssembly scopes" | , | ||
false | , | ||
false | |||
) |
Definition at line 180 of file WebAssemblyCFGStackify.cpp.
|
static |
Definition at line 1541 of file WebAssemblyCFGStackify.cpp.
References llvm::MachineBasicBlock::begin(), llvm::MachineFunction::CreateMachineBasicBlock(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::MachineBasicBlock::getParent(), llvm::MachineFunction::insert(), MI, and llvm::reverse().
STATISTIC | ( | NumCallUnwindMismatches | , |
"Number of call unwind mismatches found" | |||
) |
STATISTIC | ( | NumCatchUnwindMismatches | , |
"Number of catch unwind mismatches found" | |||
) |
|
static |
Definition at line 1106 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.