29#define DEBUG_TYPE "wasm-exception-info"
34 "WebAssembly Exception Information",
true,
true)
38 "WebAssembly Exception Information",
true,
true)
43 LLVM_DEBUG(
dbgs() <<
"********** Exception Info Calculation **********\n"
44 "********** Function: "
45 << MF.getName() <<
'\n');
46 if (MF.getTarget().getMCAsmInfo().getExceptionHandlingType() !=
48 !MF.getFunction().hasPersonalityFn())
52 WEI.recalculate(MF, MDT, MDF);
59 WasmExceptionInfo, MF,
95 auto WE = std::make_unique<WebAssemblyException>(EHPad);
96 discoverAndMapException(WE.get(), MDT, MDF);
122 for (
auto &WE : Exceptions) {
124 if (WE->getParentException())
125 WE->getParentException()->getSubExceptions().push_back(std::move(WE));
132 for (
auto *WE : ExceptionPointers) {
134 std::reverse(WE->getSubExceptions().begin(), WE->getSubExceptions().end());
140 TopLevelExceptions.clear();
151void WebAssemblyExceptionInfo::discoverAndMapException(
154 unsigned NumBlocks = 0;
155 unsigned NumSubExceptions = 0;
161 while (!WL.
empty()) {
176 for (
auto &Frontier : MDF.
find(SubE->
getEHPad())->second)
215 OS <<
"%bb." <<
MBB->getNumber();
216 if (
const auto *BB =
MBB->getBasicBlock())
218 OS <<
"." << BB->getName();
221 OS <<
" (landing-pad)";
225 for (
auto &SubE : SubExceptions)
229#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
239 for (
auto &WE : TopLevelExceptions)
245 MachineFunctionAnalysisManager::Invalidator &) {
249 return !PAC.preserved() &&
#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.
WebAssembly Exception static true void computeWEI(WebAssemblyExceptionInfo &WEI, MachineFunction &MF, function_ref< MachineDominatorTree &()> GetMDT, function_ref< MachineDominanceFrontier &()> GetMDF)
This file implements WebAssemblyException information analysis.
This file contains the declaration of the WebAssembly-specific utility functions.
This templated class represents "all analyses that operate over <aparticular IR unit>" (e....
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Represent the analysis usage information of a pass.
AnalysisUsage & addRequired()
void setPreservesAll()
Set by analyses that do not transform their input at all.
Represents analyses that only rely on functions' control flow.
bool isEHPad() const
Returns true if the block is a landing pad.
iterator_range< succ_iterator > successors()
Analysis pass which computes a MachineDominatorTree.
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 ...
A set of analyses that are preserved following a run of a transformation pass.
PreservedAnalysisChecker getChecker() const
Build a checker for this PreservedAnalyses and the specified analysis type.
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.
LLVM_ABI Result run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
WebAssemblyExceptionInfo Result
bool runOnMachineFunction(MachineFunction &MF) override
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
void releaseMemory() override
releaseMemory() - This member can be implemented by a pass if it wants to be able to release its memo...
void changeExceptionFor(const MachineBasicBlock *MBB, WebAssemblyException *WE)
void addTopLevelException(std::unique_ptr< WebAssemblyException > WE)
void recalculate(MachineFunction &MF, MachineDominatorTree &MDT, const MachineDominanceFrontier &MDF)
void print(raw_ostream &OS, const Module *M) const
WebAssemblyException * getExceptionFor(const MachineBasicBlock *MBB) const
bool invalidate(MachineFunction &MF, const PreservedAnalyses &PA, MachineFunctionAnalysisManager::Invalidator &)
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)
An efficient, type-erasing, non-owning reference to a callable.
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.
Pass manager infrastructure for declaring and invalidating analyses.
This is an optimization pass for GlobalISel generic memory operations.
@ Wasm
WebAssembly Exception Handling.
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
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)
A special type used by analysis passes to provide an address that identifies that particular analysis...