8#ifndef LLVM_ANALYSIS_EHUTILS_H
9#define LLVM_ANALYSIS_EHUTILS_H
17template <
typename FunctionT,
typename BlockT>
26 auto GetStatus = [&](BlockT *BB) {
33 auto CheckPredecessors = [&](BlockT *BB,
Status Stat) {
35 Status PredStatus = GetStatus(PredBB);
38 if (PredStatus > Stat)
44 auto AddSuccesors = [&](BlockT *BB) {
46 if (!SuccBB->isEHPad())
52 BlockT *StartBlock = &
F.front();
53 Statuses[StartBlock] = NonEH;
54 AddSuccesors(StartBlock);
64 while (!WorkList.
empty()) {
65 auto *BB = *WorkList.
begin();
68 Status OldStatus = GetStatus(BB);
72 Status NewStatus = CheckPredecessors(BB, OldStatus);
75 bool Changed = OldStatus != NewStatus;
78 Statuses[BB] = NewStatus;
82 for (
auto Entry : Statuses) {
83 if (Entry.second == EH)
84 EHBlocks.
insert(Entry.first);
This file defines the DenseMap class.
This file defines the DenseSet and SmallDenseSet classes.
bool contains(const_arg_type_t< KeyT > Val) const
Return true if the specified key is in the map, false otherwise.
Implements a dense probed hash-table based set.
std::pair< iterator, bool > insert(const ValueT &V)
bool erase(const ValueT &V)
This is an optimization pass for GlobalISel generic memory operations.
auto successors(const MachineBasicBlock *BB)
static void computeEHOnlyBlocks(FunctionT &F, DenseSet< BlockT * > &EHBlocks)
Compute a list of blocks that are only reachable via EH paths.
auto predecessors(const MachineBasicBlock *BB)