26#define DEBUG_TYPE "wasm-exception-info"
31 "WebAssembly Exception Information",
true,
true)
35 "WebAssembly Exception Information",
true,
true)
38 LLVM_DEBUG(
dbgs() <<
"********** Exception Info Calculation **********\n"
39 "********** Function: "
40 << MF.getName() <<
'\n');
42 if (MF.getTarget().getMCAsmInfo()->getExceptionHandlingType() !=
44 !MF.getFunction().hasPersonalityFn())
62 auto WE = std::make_unique<WebAssemblyException>(EHPad);
63 discoverAndMapException(WE.get(), MDT, MDF);
89 for (
auto &WE : Exceptions) {
91 if (WE->getParentException())
92 WE->getParentException()->getSubExceptions().push_back(std::move(WE));
99 for (
auto *WE : ExceptionPointers) {
101 std::reverse(WE->getSubExceptions().begin(), WE->getSubExceptions().end());
107 TopLevelExceptions.clear();
117void WebAssemblyExceptionInfo::discoverAndMapException(
120 unsigned NumBlocks = 0;
121 unsigned NumSubExceptions = 0;
127 while (!WL.
empty()) {
142 for (
auto &Frontier : MDF.
find(SubE->
getEHPad())->second)
181 OS <<
"%bb." <<
MBB->getNumber();
182 if (
const auto *BB =
MBB->getBasicBlock())
184 OS <<
"." << BB->getName();
187 OS <<
" (landing-pad)";
191 for (
auto &SubE : SubExceptions)
195#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
205 for (
auto &WE : TopLevelExceptions)
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
#define INITIALIZE_PASS_DEPENDENCY(depName)
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
This file builds on the ADT/GraphTraits.h file to build a generic graph post order iterator.
This file implements WebAssemblyException information analysis.
This file contains the declaration of the WebAssembly-specific utility functions.
Represent the analysis usage information of a pass.
AnalysisUsage & addRequired()
void setPreservesAll()
Set by analyses that do not transform their input at all.
bool isEHPad() const
Returns true if the block is a landing pad.
iterator_range< succ_iterator > successors()
Analysis pass which computes a MachineDominatorTree.
DominatorTree Class - Concrete subclass of DominatorTreeBase that is used to compute a normal dominat...
bool dominates(const MachineInstr *A, const MachineInstr *B) const
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
A Module instance is used to store all the information related to an LLVM module.
AnalysisType & getAnalysis() const
getAnalysis<AnalysisType>() - This function is used by subclasses to get to the analysis information ...
void reserve(size_type N)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
WebAssemblyExceptionInfo()
void changeExceptionFor(const MachineBasicBlock *MBB, WebAssemblyException *WE)
bool runOnMachineFunction(MachineFunction &) override
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
void addTopLevelException(std::unique_ptr< WebAssemblyException > WE)
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
void recalculate(MachineFunction &MF, MachineDominatorTree &MDT, const MachineDominanceFrontier &MDF)
WebAssemblyException * getExceptionFor(const MachineBasicBlock *MBB) const
void print(raw_ostream &OS, const Module *M=nullptr) const override
print - Print out the internal state of the pass.
void releaseMemory() override
releaseMemory() - This member can be implemented by a pass if it wants to be able to release its memo...
void print(raw_ostream &OS, unsigned Depth=0) const
MachineBasicBlock * getEHPad() const
void addToBlocksSet(MachineBasicBlock *MBB)
void reserveBlocks(unsigned Size)
const std::vector< std::unique_ptr< WebAssemblyException > > & getSubExceptions() const
ArrayRef< MachineBasicBlock * > getBlocks() const
std::vector< MachineBasicBlock * > & getBlocksVector()
WebAssemblyException * getParentException() const
unsigned getExceptionDepth() const
void setParentException(WebAssemblyException *WE)
void addToBlocksVector(MachineBasicBlock *MBB)
This class implements an extremely fast bulk output stream that can only output to a stream.
raw_ostream & indent(unsigned NumSpaces)
indent - Insert 'NumSpaces' spaces.
This is an optimization pass for GlobalISel generic memory operations.
void dump(const SparseBitVector< ElementSize > &LHS, raw_ostream &out)
@ Wasm
WebAssembly Exception Handling.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
auto post_order(const T &G)
Post-order traversal of a graph.
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)