LLVM
8.0.1
|
This file implements a CFG stacking pass. More...
#include "MCTargetDesc/WebAssemblyMCTargetDesc.h"
#include "WebAssembly.h"
#include "WebAssemblyExceptionInfo.h"
#include "WebAssemblyMachineFunctionInfo.h"
#include "WebAssemblySubtarget.h"
#include "WebAssemblyUtilities.h"
#include "llvm/CodeGen/MachineDominators.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/MachineLoopInfo.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/CodeGen/Passes.h"
#include "llvm/CodeGen/WasmEHFuncInfo.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
Go to the source code of this file.
Macros | |
#define | DEBUG_TYPE "wasm-cfg-stackify" |
Functions | |
INITIALIZE_PASS (WebAssemblyCFGStackify, DEBUG_TYPE, "Insert BLOCK and LOOP 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. More... | |
static MachineBasicBlock::iterator | GetEarliestInsertPos (MachineBasicBlock *MBB, const SmallPtrSet< const MachineInstr *, 4 > &BeforeSet, const SmallPtrSet< const MachineInstr *, 4 > &AfterSet) |
static MachineBasicBlock::iterator | GetLatestInsertPos (MachineBasicBlock *MBB, const SmallPtrSet< const MachineInstr *, 4 > &BeforeSet, const SmallPtrSet< const MachineInstr *, 4 > &AfterSet) |
static unsigned | GetDepth (const SmallVectorImpl< const MachineBasicBlock *> &Stack, const MachineBasicBlock *MBB) |
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 43 of file WebAssemblyCFGStackify.cpp.
|
static |
Definition at line 669 of file WebAssemblyCFGStackify.cpp.
References llvm::MachineInstr::addOperand(), assert(), llvm::SmallVectorTemplateCommon< T >::back(), llvm::MachineFunction::back(), llvm::BuildMI(), llvm::MachineOperand::CreateImm(), llvm::dbgs(), E, llvm::SmallVectorBase::empty(), llvm::MachineBasicBlock::end(), llvm::bitc::END_BLOCK, llvm::MachineInstr::eraseFromParent(), llvm::MachineBasicBlock::findPrevDebugLoc(), llvm::MachineInstr::getDebugLoc(), GetDepth(), llvm::MCAsmInfo::getExceptionHandlingType(), llvm::MachineOperand::getMBB(), llvm::TargetMachine::getMCAsmInfo(), llvm::MachineFunction::getName(), llvm::MachineBasicBlock::getNumber(), llvm::MachineFunction::getNumBlockIDs(), llvm::MachineInstr::getNumOperands(), llvm::MachineInstr::getOpcode(), llvm::MachineInstr::getOperand(), getParent(), llvm::MachineFunction::getRegInfo(), llvm::MachineFunction::getSubtarget(), llvm::MachineFunction::getTarget(), llvm::WebAssemblySubtarget::getTargetTriple(), I, llvm::MachineRegisterInfo::invalidateLiveness(), llvm::WebAssembly::isCatchAllTerminatePad(), llvm::Triple::isOSBinFormatELF(), llvm::MachineInstr::isTerminator(), LLVM_DEBUG, llvm::AMDGPUISD::LOOP, MI, llvm::MachineInstr::operands(), llvm::SmallVectorTemplateBase< T >::pop_back(), llvm::SmallVectorTemplateBase< T >::push_back(), llvm::MachineBasicBlock::rbegin(), llvm::MachineInstr::RemoveOperand(), llvm::MachineBasicBlock::rend(), llvm::reverse(), llvm::SmallVectorBase::size(), TII, and llvm::Wasm.
|
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 111 of file WebAssemblyCFGStackify.cpp.
References llvm::WebAssembly::isRethrow(), MI, and llvm::MachineBasicBlock::terminators().
|
static |
Definition at line 594 of file WebAssemblyCFGStackify.cpp.
References assert(), llvm::Depth, llvm::bitc::END_BLOCK, llvm::MVT::ExceptRef, llvm::WebAssembly::ExceptRef, llvm::MVT::f32, llvm::WebAssembly::F32, llvm::MVT::f64, llvm::WebAssembly::F64, llvm::MachineFunction::getInfo(), llvm::MVT::i32, llvm::WebAssembly::I32, llvm::MVT::i64, llvm::WebAssembly::I64, llvm_unreachable, MI, llvm::reverse(), llvm::SmallVectorBase::size(), llvm::WebAssembly::V128, llvm::MVT::v16i8, llvm::MVT::v2f64, llvm::MVT::v2i64, llvm::MVT::v4f32, llvm::MVT::v4i32, llvm::MVT::v8i16, and X.
Referenced by AppendEndToFunction().
|
static |
Definition at line 128 of file WebAssemblyCFGStackify.cpp.
References assert(), llvm::MachineBasicBlock::begin(), llvm::SmallPtrSetImpl< PtrType >::count(), E, and llvm::MachineBasicBlock::end().
|
static |
Definition at line 152 of file WebAssemblyCFGStackify.cpp.
References assert(), llvm::MachineBasicBlock::begin(), llvm::SmallPtrSetImpl< PtrType >::count(), E, and llvm::MachineBasicBlock::end().
INITIALIZE_PASS | ( | WebAssemblyCFGStackify | , |
DEBUG_TYPE | , | ||
"Insert BLOCK and LOOP markers for WebAssembly scopes" | , | ||
false | , | ||
false | |||
) |
Definition at line 98 of file WebAssemblyCFGStackify.cpp.