[clang][NFC] simplify the unset check in `ParseLabeledStatement` (#117430)
[llvm-project.git] / llvm / lib / CodeGen / MachineDomTreeUpdater.cpp
bloba640fc0079038f4b009376a9b769b72b4516b961
1 //===- MachineDomTreeUpdater.cpp -----------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file implements the MachineDomTreeUpdater class, which provides a
10 // uniform way to update dominator tree related data structures.
12 //===----------------------------------------------------------------------===//
14 #include "llvm/CodeGen/MachineDomTreeUpdater.h"
15 #include "llvm/Analysis/GenericDomTreeUpdaterImpl.h"
16 #include "llvm/CodeGen/MachinePostDominators.h"
18 namespace llvm {
20 template class GenericDomTreeUpdater<
21 MachineDomTreeUpdater, MachineDominatorTree, MachinePostDominatorTree>;
23 template void
24 GenericDomTreeUpdater<MachineDomTreeUpdater, MachineDominatorTree,
25 MachinePostDominatorTree>::recalculate(MachineFunction
26 &MF);
28 bool MachineDomTreeUpdater::forceFlushDeletedBB() {
29 if (DeletedBBs.empty())
30 return false;
32 for (auto *BB : DeletedBBs) {
33 eraseDelBBNode(BB);
34 BB->eraseFromParent();
36 DeletedBBs.clear();
37 return true;
40 // The DT and PDT require the nodes related to updates
41 // are not deleted when update functions are called.
42 // So MachineBasicBlock deletions must be pended when the
43 // UpdateStrategy is Lazy. When the UpdateStrategy is
44 // Eager, the MachineBasicBlock will be deleted immediately.
45 void MachineDomTreeUpdater::deleteBB(MachineBasicBlock *DelBB) {
46 validateDeleteBB(DelBB);
47 if (Strategy == UpdateStrategy::Lazy) {
48 DeletedBBs.insert(DelBB);
49 return;
52 eraseDelBBNode(DelBB);
53 DelBB->eraseFromParent();
56 void MachineDomTreeUpdater::validateDeleteBB(MachineBasicBlock *DelBB) {
57 assert(DelBB && "Invalid push_back of nullptr DelBB.");
58 assert(DelBB->pred_empty() && "DelBB has one or more predecessors.");
61 } // namespace llvm