
## Purpose This patch is one in a series of code-mods that annotate LLVM’s public interface for export. This patch annotates the remaining LLVM CodeGen and CodeGenTypes library interfaces that were missed in, or modified since, previous patches. The annotations currently have no meaningful impact on the LLVM build; however, they are a prerequisite to support an LLVM Windows DLL (shared library) build. ## Background This effort is tracked in #109483. Additional context is provided in [this discourse](https://discourse.llvm.org/t/psa-annotating-llvm-public-interface/85307), and documentation for `LLVM_ABI` and related annotations is found in the LLVM repo [here](https://github.com/llvm/llvm-project/blob/main/llvm/docs/InterfaceExportAnnotations.rst). ## Overview The bulk of these changes were generated automatically using the [Interface Definition Scanner (IDS)](https://github.com/compnerd/ids) tool, followed formatting with `git clang-format`. The following manual adjustments were also applied after running IDS: - Explicitly instantiate `CallLowering::setArgFlags` template method instances in `CodeGen/GlobalISel/CallLowering.h` and annotate them with `LLVM_ABI`. These methods are already explicitly instantiated in `lib/CodeGen/GlobalISel/CallLowering.cpp` but were not `extern` declared in the header. - Annotate several explicit template instantiations with `LLVM_EXPORT_TEMPLATE`. - Include `llvm/CodeGen/Passes.h` from `llvm/lib/CodeGen/GlobalMergeFunctions.cpp` to pick up the declaration of `llvm::createGlobalMergeFuncPass` with the `LLVM_ABI` annotation (instead of adding `LLVM_ABI` to the function definition in this file) ## Validation Local builds and tests to validate cross-platform compatibility. This included llvm, clang, and lldb on the following configurations: - Windows with MSVC - Windows with Clang - Linux with GCC - Linux with Clang - Darwin with Clang
70 lines
2.5 KiB
C++
70 lines
2.5 KiB
C++
//===- MachineDomTreeUpdater.cpp -----------------------------------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This file implements the MachineDomTreeUpdater class, which provides a
|
|
// uniform way to update dominator tree related data structures.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "llvm/CodeGen/MachineDomTreeUpdater.h"
|
|
#include "llvm/Analysis/GenericDomTreeUpdaterImpl.h"
|
|
#include "llvm/CodeGen/MachinePostDominators.h"
|
|
#include "llvm/Support/Compiler.h"
|
|
|
|
namespace llvm {
|
|
|
|
template class LLVM_EXPORT_TEMPLATE GenericDomTreeUpdater<
|
|
MachineDomTreeUpdater, MachineDominatorTree, MachinePostDominatorTree>;
|
|
|
|
template LLVM_EXPORT_TEMPLATE void
|
|
GenericDomTreeUpdater<MachineDomTreeUpdater, MachineDominatorTree,
|
|
MachinePostDominatorTree>::recalculate(MachineFunction
|
|
&MF);
|
|
|
|
template LLVM_EXPORT_TEMPLATE void GenericDomTreeUpdater<
|
|
MachineDomTreeUpdater, MachineDominatorTree,
|
|
MachinePostDominatorTree>::applyUpdatesImpl</*IsForward=*/true>();
|
|
template LLVM_EXPORT_TEMPLATE void GenericDomTreeUpdater<
|
|
MachineDomTreeUpdater, MachineDominatorTree,
|
|
MachinePostDominatorTree>::applyUpdatesImpl</*IsForward=*/false>();
|
|
|
|
bool MachineDomTreeUpdater::forceFlushDeletedBB() {
|
|
if (DeletedBBs.empty())
|
|
return false;
|
|
|
|
for (auto *BB : DeletedBBs) {
|
|
eraseDelBBNode(BB);
|
|
BB->eraseFromParent();
|
|
}
|
|
DeletedBBs.clear();
|
|
return true;
|
|
}
|
|
|
|
// The DT and PDT require the nodes related to updates
|
|
// are not deleted when update functions are called.
|
|
// So MachineBasicBlock deletions must be pended when the
|
|
// UpdateStrategy is Lazy. When the UpdateStrategy is
|
|
// Eager, the MachineBasicBlock will be deleted immediately.
|
|
void MachineDomTreeUpdater::deleteBB(MachineBasicBlock *DelBB) {
|
|
validateDeleteBB(DelBB);
|
|
if (Strategy == UpdateStrategy::Lazy) {
|
|
DeletedBBs.insert(DelBB);
|
|
return;
|
|
}
|
|
|
|
eraseDelBBNode(DelBB);
|
|
DelBB->eraseFromParent();
|
|
}
|
|
|
|
void MachineDomTreeUpdater::validateDeleteBB(MachineBasicBlock *DelBB) {
|
|
assert(DelBB && "Invalid push_back of nullptr DelBB.");
|
|
assert(DelBB->pred_empty() && "DelBB has one or more predecessors.");
|
|
}
|
|
|
|
} // namespace llvm
|