LLVM 23.0.0git
MachineDominators.cpp
Go to the documentation of this file.
1//===- MachineDominators.cpp - Machine Dominator Calculation --------------===//
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 simple dominator construction algorithms for finding
10// forward dominators on machine functions.
11//
12//===----------------------------------------------------------------------===//
13
15#include "llvm/CodeGen/Passes.h"
17#include "llvm/Pass.h"
21
22using namespace llvm;
23
24namespace llvm {
25// Always verify dominfo if expensive checking is enabled.
26#ifdef EXPENSIVE_CHECKS
27bool VerifyMachineDomInfo = true;
28#else
30#endif
31} // namespace llvm
32
34 "verify-machine-dom-info", cl::location(VerifyMachineDomInfo), cl::Hidden,
35 cl::desc("Verify machine dominator info (time consuming)"));
36
37namespace llvm {
39template class LLVM_EXPORT_TEMPLATE
41
42namespace DomTreeBuilder {
43template LLVM_EXPORT_TEMPLATE void Calculate<MBBDomTree>(MBBDomTree &DT);
44template LLVM_EXPORT_TEMPLATE void
45CalculateWithUpdates<MBBDomTree>(MBBDomTree &DT, MBBUpdates U);
46
47template LLVM_EXPORT_TEMPLATE void
48InsertEdge<MBBDomTree>(MBBDomTree &DT, MachineBasicBlock *From,
50
51template LLVM_EXPORT_TEMPLATE void
52DeleteEdge<MBBDomTree>(MBBDomTree &DT, MachineBasicBlock *From,
54
55template LLVM_EXPORT_TEMPLATE void
56ApplyUpdates<MBBDomTree>(MBBDomTree &DT, MBBDomTreeGraphDiff &,
57 MBBDomTreeGraphDiff *);
58
59template LLVM_EXPORT_TEMPLATE bool
60Verify<MBBDomTree>(const MBBDomTree &DT, MBBDomTree::VerificationLevel VL);
61} // namespace DomTreeBuilder
62}
63
66 MachineFunctionAnalysisManager::Invalidator &) {
67 // Check whether the analysis, all analyses on machine functions, or the
68 // machine function's CFG have been preserved.
70 return !PAC.preserved() &&
71 !PAC.preservedSet<AllAnalysesOn<MachineFunction>>() &&
72 !PAC.preservedSet<CFGAnalyses>();
73}
74
75AnalysisKey MachineDominatorTreeAnalysis::Key;
76
82
86 OS << "MachineDominatorTree for machine function: " << MF.getName() << '\n';
89}
90
92
94 "MachineDominator Tree Construction", true, true)
95
98
100
102 if (F.empty()) {
103 assert(F.getProperties().hasFailedISel() &&
104 "Machine function should not be empty unless ISel failed.");
105 return false;
106 }
107
109 return false;
110}
111
113
115 if (VerifyMachineDomInfo && DT)
116 if (!DT->verify(MachineDominatorTree::VerificationLevel::Basic))
117 report_fatal_error("MachineDominatorTree verification failed!");
118}
119
121 const Module *) const {
122 if (DT)
123 DT->print(OS);
124}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
#define LLVM_EXPORT_TEMPLATE
Definition Compiler.h:215
Generic dominator tree construction - this file provides routines to construct immediate dominator in...
#define F(x, y, z)
Definition MD5.cpp:54
static cl::opt< bool, true > VerifyMachineDomInfoX("verify-machine-dom-info", cl::location(VerifyMachineDomInfo), cl::Hidden, cl::desc("Verify machine dominator info (time consuming)"))
ppc ctr loops PowerPC CTR Loops Verify
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
Definition PassSupport.h:56
This templated class represents "all analyses that operate over <aparticular IR unit>" (e....
Definition Analysis.h:50
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Represents analyses that only rely on functions' control flow.
Definition Analysis.h:73
Base class for the actual dominator tree node.
Core dominator tree base class.
Analysis pass which computes a MachineDominatorTree.
LLVM_ABI Result run(MachineFunction &MF, MachineFunctionAnalysisManager &)
LLVM_ABI PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
Analysis pass which computes a MachineDominatorTree.
void verifyAnalysis() const override
verifyAnalysis() - This member can be implemented by a analysis pass to check state of analysis infor...
void print(raw_ostream &OS, const Module *M=nullptr) const override
print - Print out the internal state of the pass.
bool runOnMachineFunction(MachineFunction &MF) override
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
void releaseMemory() override
releaseMemory() - This member can be implemented by a pass if it wants to be able to release its memo...
DominatorTree Class - Concrete subclass of DominatorTreeBase that is used to compute a normal dominat...
LLVM_ABI bool invalidate(MachineFunction &, const PreservedAnalyses &PA, MachineFunctionAnalysisManager::Invalidator &)
Handle invalidation explicitly.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:67
A set of analyses that are preserved following a run of a transformation pass.
Definition Analysis.h:112
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Definition Analysis.h:118
PreservedAnalysisChecker getChecker() const
Build a checker for this PreservedAnalyses and the specified analysis type.
Definition Analysis.h:275
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition CallingConv.h:24
LocationClass< Ty > location(Ty &L)
This is an optimization pass for GlobalISel generic memory operations.
Definition Types.h:26
Printable print(const GCNRegPressure &RP, const GCNSubtarget *ST=nullptr, unsigned DynamicVGPRBlockSize=0)
LLVM_ABI char & MachineDominatorsID
MachineDominators - This pass is a machine dominators analysis pass.
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
Definition Error.cpp:163
bool VerifyMachineDomInfo
A special type used by analysis passes to provide an address that identifies that particular analysis...
Definition Analysis.h:29