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/Analysis/GenericDomTreeUpdaterImpl.h"
16 #include "llvm/CodeGen/MachinePostDominators.h"
20 template class GenericDomTreeUpdater
<
21 MachineDomTreeUpdater
, MachineDominatorTree
, MachinePostDominatorTree
>;
24 GenericDomTreeUpdater
<MachineDomTreeUpdater
, MachineDominatorTree
,
25 MachinePostDominatorTree
>::recalculate(MachineFunction
28 bool MachineDomTreeUpdater::forceFlushDeletedBB() {
29 if (DeletedBBs
.empty())
32 for (auto *BB
: DeletedBBs
) {
34 BB
->eraseFromParent();
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
);
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.");