1 //===- MachineDomTreeUpdater.cpp -----------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
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"
25 template class GenericDomTreeUpdater
<
26 MachineDomTreeUpdater
, MachineDominatorTree
, MachinePostDominatorTree
>;
29 GenericDomTreeUpdater
<MachineDomTreeUpdater
, MachineDominatorTree
,
30 MachinePostDominatorTree
>::recalculate(MachineFunction
33 bool MachineDomTreeUpdater::forceFlushDeletedBB() {
34 if (DeletedBBs
.empty())
37 for (auto *BB
: DeletedBBs
) {
39 BB
->eraseFromParent();
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
);
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.");