LLVM 20.0.0git
|
This file implements a CFG sorting pass. More...
#include "MCTargetDesc/WebAssemblyMCTargetDesc.h"
#include "WebAssembly.h"
#include "WebAssemblyExceptionInfo.h"
#include "WebAssemblySortRegion.h"
#include "WebAssemblySubtarget.h"
#include "WebAssemblyUtilities.h"
#include "llvm/ADT/PriorityQueue.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/CodeGen/MachineDominators.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineLoopInfo.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/CodeGen/Passes.h"
#include "llvm/CodeGen/WasmEHFuncInfo.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-sort" |
Functions | |
INITIALIZE_PASS (WebAssemblyCFGSort, DEBUG_TYPE, "Reorders blocks in topological order", false, false) FunctionPass *llvm | |
static void | maybeUpdateTerminator (MachineBasicBlock *MBB) |
static void | sortBlocks (MachineFunction &MF, const MachineLoopInfo &MLI, const WebAssemblyExceptionInfo &WEI, MachineDominatorTree &MDT) |
Sort the blocks, taking special care to make sure that regions are not interrupted by blocks not dominated by their header. | |
Variables | |
static cl::opt< bool > | WasmDisableEHPadSort ("wasm-disable-ehpad-sort", cl::ReallyHidden, cl::desc("WebAssembly: Disable EH pad-first sort order. Testing purpose only."), cl::init(false)) |
This file implements a CFG sorting pass.
This pass reorders the blocks in a function to put them into topological order, ignoring loop backedges, and without any loop or exception being interrupted by a block not dominated by the its header, with special care to keep the order as similar as possible to the original order.
Definition in file WebAssemblyCFGSort.cpp.
#define DEBUG_TYPE "wasm-cfg-sort" |
Definition at line 39 of file WebAssemblyCFGSort.cpp.
INITIALIZE_PASS | ( | WebAssemblyCFGSort | , |
DEBUG_TYPE | , | ||
"Reorders blocks in topological order" | , | ||
false | , | ||
false | |||
) |
Definition at line 74 of file WebAssemblyCFGSort.cpp.
|
static |
Definition at line 81 of file WebAssemblyCFGSort.cpp.
References assert(), llvm::MachineFunction::getBlockNumbered(), llvm::MachineBasicBlock::getNumber(), llvm::MachineFunction::getNumBlockIDs(), llvm::MachineBasicBlock::getParent(), MBB, llvm::MachineBasicBlock::terminators(), and llvm::MachineBasicBlock::updateTerminator().
Referenced by sortBlocks().
|
static |
Sort the blocks, taking special care to make sure that regions are not interrupted by blocks not dominated by their header.
TODO: There are many opportunities for improving the heuristics here. Explore them.
Definition at line 187 of file WebAssemblyCFGSort.cpp.
References assert(), llvm::SetVector< T, Vector, Set, N >::back(), llvm::RegionBase< Tr >::contains(), llvm::SetVector< T, Vector, Set, N >::count(), llvm::SmallPtrSetImpl< PtrType >::count(), llvm::MachineDominatorTree::dominates(), llvm::SetVector< T, Vector, Set, N >::empty(), llvm::MachineFunction::front(), llvm::WebAssembly::SortRegionInfo::getBottom(), llvm::LoopInfoBase< BlockT, LoopT >::getLoopFor(), llvm::MachineBasicBlock::getNumber(), llvm::MachineFunction::getNumBlockIDs(), llvm::WebAssembly::SortRegionInfo::getRegionFor(), llvm::MachineFunction::getWasmEHFuncInfo(), llvm::SetVector< T, Vector, Set, N >::insert(), llvm::MachineBasicBlock::isEHPad(), maybeUpdateTerminator(), MBB, llvm::MachineBasicBlock::moveAfter(), N, llvm::SetVector< T, Vector, Set, N >::pop_back(), llvm::SetVector< T, Vector, Set, N >::pop_back_val(), llvm::MachineBasicBlock::pred_size(), llvm::MachineBasicBlock::predecessors(), llvm::MachineFunction::RenumberBlocks(), llvm::SetVector< T, Vector, Set, N >::size(), llvm::MachineBasicBlock::successors(), llvm::DominatorTreeBase< NodeT, IsPostDom >::updateBlockNumbers(), and WasmDisableEHPadSort.
|
static |
Referenced by sortBlocks().