Files
clang-r547379/include/llvm/CodeGen/MachinePostDominators.h
Ryan Prichard 6024e5c395 Update prebuilt Clang to r547379 (20.0.0).
clang 20.0.0 (based on r547379) from build 12806354.

Bug: http://b/379133546
Test: N/A
Change-Id: I2eb8938af55d809de674be63cb30cf27e801862b

Upstream-Commit: ad834e67b1105d15ef907f6255d4c96e8e733f57
2025-11-26 14:59:46 -05:00

110 lines
4.0 KiB
C++

//===- llvm/CodeGen/MachinePostDominators.h ----------------------*- C++ -*-==//
//
// 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 exposes interfaces to post dominance information for
// target-specific code.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CODEGEN_MACHINEPOSTDOMINATORS_H
#define LLVM_CODEGEN_MACHINEPOSTDOMINATORS_H
#include "llvm/CodeGen/MachineDominators.h"
namespace llvm {
extern template class DominatorTreeBase<MachineBasicBlock, true>; // PostDomTree
namespace DomTreeBuilder {
using MBBPostDomTree = PostDomTreeBase<MachineBasicBlock>;
using MBBPostDomTreeGraphDiff = GraphDiff<MachineBasicBlock *, true>;
extern template void Calculate<MBBPostDomTree>(MBBPostDomTree &DT);
extern template void InsertEdge<MBBPostDomTree>(MBBPostDomTree &DT,
MachineBasicBlock *From,
MachineBasicBlock *To);
extern template void DeleteEdge<MBBPostDomTree>(MBBPostDomTree &DT,
MachineBasicBlock *From,
MachineBasicBlock *To);
extern template void ApplyUpdates<MBBPostDomTree>(MBBPostDomTree &DT,
MBBPostDomTreeGraphDiff &,
MBBPostDomTreeGraphDiff *);
extern template bool
Verify<MBBPostDomTree>(const MBBPostDomTree &DT,
MBBPostDomTree::VerificationLevel VL);
} // namespace DomTreeBuilder
///
/// MachinePostDominatorTree - an analysis pass wrapper for DominatorTree
/// used to compute the post-dominator tree for MachineFunctions.
///
class MachinePostDominatorTree : public PostDomTreeBase<MachineBasicBlock> {
using Base = PostDomTreeBase<MachineBasicBlock>;
public:
MachinePostDominatorTree() = default;
explicit MachinePostDominatorTree(MachineFunction &MF) { recalculate(MF); }
/// Handle invalidation explicitly.
bool invalidate(MachineFunction &, const PreservedAnalyses &PA,
MachineFunctionAnalysisManager::Invalidator &);
/// Make findNearestCommonDominator(const NodeT *A, const NodeT *B) available.
using Base::findNearestCommonDominator;
/// Returns the nearest common dominator of the given blocks.
/// If that tree node is a virtual root, a nullptr will be returned.
MachineBasicBlock *
findNearestCommonDominator(ArrayRef<MachineBasicBlock *> Blocks) const;
};
class MachinePostDominatorTreeAnalysis
: public AnalysisInfoMixin<MachinePostDominatorTreeAnalysis> {
friend AnalysisInfoMixin<MachinePostDominatorTreeAnalysis>;
static AnalysisKey Key;
public:
using Result = MachinePostDominatorTree;
Result run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM);
};
class MachinePostDominatorTreePrinterPass
: public PassInfoMixin<MachinePostDominatorTreePrinterPass> {
raw_ostream &OS;
public:
explicit MachinePostDominatorTreePrinterPass(raw_ostream &OS) : OS(OS) {}
PreservedAnalyses run(MachineFunction &MF,
MachineFunctionAnalysisManager &MFAM);
static bool isRequired() { return true; }
};
class MachinePostDominatorTreeWrapperPass : public MachineFunctionPass {
std::optional<MachinePostDominatorTree> PDT;
public:
static char ID;
MachinePostDominatorTreeWrapperPass();
MachinePostDominatorTree &getPostDomTree() { return *PDT; }
const MachinePostDominatorTree &getPostDomTree() const { return *PDT; }
bool runOnMachineFunction(MachineFunction &MF) override;
void getAnalysisUsage(AnalysisUsage &AU) const override;
void releaseMemory() override { PDT.reset(); }
void verifyAnalysis() const override;
void print(llvm::raw_ostream &OS, const Module *M = nullptr) const override;
};
} //end of namespace llvm
#endif