8#ifndef LLVM_ANALYSIS_EHUTILS_H
9#define LLVM_ANALYSIS_EHUTILS_H
17template <
typename FunctionT,
typename BlockT>
26 auto GetStatus = [&](BlockT *BB) {
27 auto It = Statuses.
find(BB);
28 return It != Statuses.
end() ? It->second :
Unknown;
31 auto CheckPredecessors = [&](BlockT *BB,
Status Stat) {
33 Status PredStatus = GetStatus(PredBB);
36 if (PredStatus > Stat)
42 auto AddSuccesors = [&](BlockT *BB) {
44 if (!SuccBB->isEHPad())
50 BlockT *StartBlock = &
F.front();
51 Statuses[StartBlock] = NonEH;
52 AddSuccesors(StartBlock);
62 while (!WorkList.
empty()) {
63 auto *BB = *WorkList.
begin();
66 Status OldStatus = GetStatus(BB);
70 Status NewStatus = CheckPredecessors(BB, OldStatus);
73 bool Changed = OldStatus != NewStatus;
76 Statuses[BB] = NewStatus;
80 for (
auto Entry : Statuses) {
81 if (Entry.second == EH)
82 EHBlocks.
insert(Entry.first);
This file defines the DenseMap class.
This file defines the DenseSet and SmallDenseSet classes.
iterator find(const_arg_type_t< KeyT > Val)
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)