LLVM 20.0.0git
DominanceFrontier.cpp
Go to the documentation of this file.
1//===- DominanceFrontier.cpp - Dominance Frontier 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
11#include "llvm/Config/llvm-config.h"
12#include "llvm/IR/Dominators.h"
13#include "llvm/IR/Function.h"
14#include "llvm/IR/PassManager.h"
16#include "llvm/Pass.h"
19
20using namespace llvm;
21
22namespace llvm {
23
27
28} // end namespace llvm
29
31
33 "Dominance Frontier Construction", true, true)
36 "Dominance Frontier Construction", true, true)
37
39 : FunctionPass(ID) {
41}
42
44 DF.releaseMemory();
45}
46
49 DF.analyze(getAnalysis<DominatorTreeWrapperPass>().getDomTree());
50 return false;
51}
52
54 AU.setPreservesAll();
56}
57
59 DF.print(OS);
60}
61
62#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
64 print(dbgs());
65}
66#endif
67
68/// Handle invalidation explicitly.
71 // Check whether the analysis, all analyses on functions, or the function's
72 // CFG have been preserved.
74 return !(PAC.preserved() || PAC.preservedSet<AllAnalysesOn<Function>>() ||
75 PAC.preservedSet<CFGAnalyses>());
76}
77
78AnalysisKey DominanceFrontierAnalysis::Key;
79
83 DF.analyze(AM.getResult<DominatorTreeAnalysis>(F));
84 return DF;
85}
86
88 : OS(OS) {}
89
92 OS << "DominanceFrontier for function: " << F.getName() << "\n";
94
96}
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
Definition: Compiler.h:533
static RegisterPass< DebugifyFunctionPass > DF("debugify-function", "Attach debug info to a function")
Dominance Frontier Construction
Dominance Frontier true
#define F(x, y, z)
Definition: MD5.cpp:55
This header defines various interfaces for pass management in LLVM.
#define INITIALIZE_PASS_DEPENDENCY(depName)
Definition: PassSupport.h:55
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
Definition: PassSupport.h:57
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
Definition: PassSupport.h:52
raw_pwrite_stream & OS
This templated class represents "all analyses that operate over <a particular IR unit>" (e....
Definition: Analysis.h:49
API to communicate dependencies between analyses during invalidation.
Definition: PassManager.h:292
A container for analyses that lazily runs them and caches their results.
Definition: PassManager.h:253
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Definition: PassManager.h:405
Represent the analysis usage information of a pass.
AnalysisUsage & addRequired()
void setPreservesAll()
Set by analyses that do not transform their input at all.
Represents analyses that only rely on functions' control flow.
Definition: Analysis.h:72
Analysis pass which computes a DominanceFrontier.
DominanceFrontier run(Function &F, FunctionAnalysisManager &AM)
Run the analysis pass over a function and produce a dominator tree.
DominanceFrontierBase - Common base class for computing forward and inverse dominance frontiers for a...
void print(raw_ostream &OS) const
print - Convert to human readable form
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
bool runOnFunction(Function &) override
runOnFunction - Virtual method overriden by subclasses to do the per-function processing of the pass.
void print(raw_ostream &OS, const Module *=nullptr) const override
print - Print out the internal state of the pass.
void releaseMemory() override
releaseMemory() - This member can be implemented by a pass if it wants to be able to release its memo...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
bool invalidate(Function &F, const PreservedAnalyses &PA, FunctionAnalysisManager::Invalidator &)
Handle invalidation explicitly.
Analysis pass which computes a DominatorTree.
Definition: Dominators.h:279
Legacy analysis pass which computes a DominatorTree.
Definition: Dominators.h:317
DominanceFrontier Class - Concrete subclass of DominanceFrontierBase that is used to compute a forwar...
FunctionPass class - This class is used to implement most global optimizations.
Definition: Pass.h:310
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
A set of analyses that are preserved following a run of a transformation pass.
Definition: Analysis.h:111
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Definition: Analysis.h:117
PreservedAnalysisChecker getChecker() const
Build a checker for this PreservedAnalyses and the specified analysis type.
Definition: Analysis.h:264
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
Printable print(const GCNRegPressure &RP, const GCNSubtarget *ST=nullptr)
void initializeDominanceFrontierWrapperPassPass(PassRegistry &)
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:163
A special type used by analysis passes to provide an address that identifies that particular analysis...
Definition: Analysis.h:28