Revert " [LoongArch][ISel] Check the number of sign bits in `PatGprGpr_32` (#107432)"
[llvm-project.git] / llvm / lib / CodeGen / MachineDomTreeUpdater.cpp
blobafffafb245e672710fe8ffaa4e9fcf1c1dac7982
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/ADT/SmallSet.h"
16 #include "llvm/Analysis/GenericDomTreeUpdaterImpl.h"
17 #include "llvm/CodeGen/MachinePostDominators.h"
18 #include "llvm/Support/GenericDomTree.h"
19 #include <algorithm>
20 #include <functional>
21 #include <utility>
23 namespace llvm {
25 template class GenericDomTreeUpdater<
26 MachineDomTreeUpdater, MachineDominatorTree, MachinePostDominatorTree>;
28 template void
29 GenericDomTreeUpdater<MachineDomTreeUpdater, MachineDominatorTree,
30 MachinePostDominatorTree>::recalculate(MachineFunction
31 &MF);
33 bool MachineDomTreeUpdater::forceFlushDeletedBB() {
34 if (DeletedBBs.empty())
35 return false;
37 for (auto *BB : DeletedBBs) {
38 eraseDelBBNode(BB);
39 BB->eraseFromParent();
41 DeletedBBs.clear();
42 return true;
45 // The DT and PDT require the nodes related to updates
46 // are not deleted when update functions are called.
47 // So MachineBasicBlock deletions must be pended when the
48 // UpdateStrategy is Lazy. When the UpdateStrategy is
49 // Eager, the MachineBasicBlock will be deleted immediately.
50 void MachineDomTreeUpdater::deleteBB(MachineBasicBlock *DelBB) {
51 validateDeleteBB(DelBB);
52 if (Strategy == UpdateStrategy::Lazy) {
53 DeletedBBs.insert(DelBB);
54 return;
57 eraseDelBBNode(DelBB);
58 DelBB->eraseFromParent();
61 void MachineDomTreeUpdater::validateDeleteBB(MachineBasicBlock *DelBB) {
62 assert(DelBB && "Invalid push_back of nullptr DelBB.");
63 assert(DelBB->pred_empty() && "DelBB has one or more predecessors.");
66 } // namespace llvm