LLVM  15.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"
15 #include "llvm/InitializePasses.h"
16 #include "llvm/Pass.h"
17 #include "llvm/Support/Compiler.h"
19 
20 using namespace llvm;
21 
22 namespace 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 
48  releaseMemory();
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.
73  auto PAC = PA.getChecker<DominanceFrontierAnalysis>();
74  return !(PAC.preserved() || PAC.preservedSet<AllAnalysesOn<Function>>() ||
75  PAC.preservedSet<CFGAnalyses>());
76 }
77 
78 AnalysisKey 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 
95  return PreservedAnalyses::all();
96 }
llvm::PreservedAnalyses
A set of analyses that are preserved following a run of a transformation pass.
Definition: PassManager.h:152
LLVM_DUMP_METHOD
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
Definition: Compiler.h:494
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:17
DominanceFrontier.h
llvm::DominanceFrontierWrapperPass::runOnFunction
bool runOnFunction(Function &) override
runOnFunction - Virtual method overriden by subclasses to do the per-function processing of the pass.
Definition: DominanceFrontier.cpp:47
true
Dominance Frontier true
Definition: DominanceFrontier.cpp:36
print
static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)
Definition: ArchiveWriter.cpp:189
llvm::AnalysisManager::getResult
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Definition: PassManager.h:780
llvm::Function
Definition: Function.h:60
Pass.h
llvm::initializeDominanceFrontierWrapperPassPass
void initializeDominanceFrontierWrapperPassPass(PassRegistry &)
llvm::DominanceFrontierPrinterPass::DominanceFrontierPrinterPass
DominanceFrontierPrinterPass(raw_ostream &OS)
Definition: DominanceFrontier.cpp:87
llvm::DominanceFrontierWrapperPass::dump
void dump() const
Definition: DominanceFrontier.cpp:63
llvm::AllAnalysesOn
This templated class represents "all analyses that operate over <a particular IR unit>" (e....
Definition: PassManager.h:90
llvm::DominanceFrontierWrapperPass::releaseMemory
void releaseMemory() override
releaseMemory() - This member can be implemented by a pass if it wants to be able to release its memo...
Definition: DominanceFrontier.cpp:43
domfrontier
domfrontier
Definition: DominanceFrontier.cpp:35
Construction
Dominance Frontier Construction
Definition: DominanceFrontier.cpp:36
llvm::DominanceFrontier::invalidate
bool invalidate(Function &F, const PreservedAnalyses &PA, FunctionAnalysisManager::Invalidator &)
Handle invalidation explicitly.
Definition: DominanceFrontier.cpp:69
F
#define F(x, y, z)
Definition: MD5.cpp:55
llvm::dbgs
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:163
llvm::PassRegistry::getPassRegistry
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
Definition: PassRegistry.cpp:31
llvm::AnalysisUsage
Represent the analysis usage information of a pass.
Definition: PassAnalysisSupport.h:47
llvm::DominatorTreeWrapperPass
Legacy analysis pass which computes a DominatorTree.
Definition: Dominators.h:302
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:54
llvm::AnalysisManager::Invalidator
API to communicate dependencies between analyses during invalidation.
Definition: PassManager.h:667
llvm::CallingConv::ID
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition: CallingConv.h:24
DF
static RegisterPass< DebugifyFunctionPass > DF("debugify-function", "Attach debug info to a function")
INITIALIZE_PASS_END
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
Definition: PassSupport.h:58
llvm::DominanceFrontierBase::releaseMemory
void releaseMemory()
Definition: DominanceFrontier.h:71
llvm::DominanceFrontierAnalysis::run
DominanceFrontier run(Function &F, FunctionAnalysisManager &AM)
Run the analysis pass over a function and produce a dominator tree.
Definition: DominanceFrontier.cpp:80
llvm::DominanceFrontierWrapperPass::print
void print(raw_ostream &OS, const Module *=nullptr) const override
print - Print out the internal state of the pass.
Definition: DominanceFrontier.cpp:58
DominanceFrontierImpl.h
llvm::ForwardDominanceFrontierBase< BasicBlock >
llvm::DominanceFrontierWrapperPass::getAnalysisUsage
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
Definition: DominanceFrontier.cpp:53
INITIALIZE_PASS_DEPENDENCY
INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
llvm::AnalysisKey
A special type used by analysis passes to provide an address that identifies that particular analysis...
Definition: PassManager.h:69
llvm::DominanceFrontierPrinterPass::run
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
Definition: DominanceFrontier.cpp:91
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
llvm::DominanceFrontierBase< BasicBlock, false >
llvm::DominanceFrontierBase::print
void print(raw_ostream &OS) const
print - Convert to human readable form
Definition: DominanceFrontierImpl.h:128
llvm::CFGAnalyses
Represents analyses that only rely on functions' control flow.
Definition: PassManager.h:113
Compiler.h
llvm::DominanceFrontierAnalysis
Analysis pass which computes a DominanceFrontier.
Definition: DominanceFrontier.h:182
llvm::AnalysisUsage::setPreservesAll
void setPreservesAll()
Set by analyses that do not transform their input at all.
Definition: PassAnalysisSupport.h:130
llvm::PreservedAnalyses::all
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Definition: PassManager.h:158
Function.h
PassManager.h
llvm::DominanceFrontierWrapperPass::ID
static char ID
Definition: DominanceFrontier.h:159
llvm::DominatorTreeAnalysis
Analysis pass which computes a DominatorTree.
Definition: Dominators.h:267
llvm::DominanceFrontier
Definition: DominanceFrontier.h:141
Dominators.h
llvm::PreservedAnalyses::getChecker
PreservedAnalysisChecker getChecker() const
Build a checker for this PreservedAnalyses and the specified analysis type.
Definition: PassManager.h:310
llvm::AnalysisManager
A container for analyses that lazily runs them and caches their results.
Definition: InstructionSimplify.h:42
llvm::ForwardDominanceFrontierBase::analyze
void analyze(DomTreeT &DT)
Definition: DominanceFrontier.h:131
llvm::FunctionPass
FunctionPass class - This class is used to implement most global optimizations.
Definition: Pass.h:308
llvm::AnalysisUsage::addRequired
AnalysisUsage & addRequired()
Definition: PassAnalysisSupport.h:75
llvm::DominanceFrontierWrapperPass
Definition: DominanceFrontier.h:155
INITIALIZE_PASS_BEGIN
INITIALIZE_PASS_BEGIN(DominanceFrontierWrapperPass, "domfrontier", "Dominance Frontier Construction", true, true) INITIALIZE_PASS_END(DominanceFrontierWrapperPass
raw_ostream.h
InitializePasses.h