LLVM  14.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"
18 #include "llvm/Support/Debug.h"
20 
21 using namespace llvm;
22 
23 namespace llvm {
24 
28 
29 } // end namespace llvm
30 
32 
34  "Dominance Frontier Construction", true, true)
37  "Dominance Frontier Construction", true, true)
38 
40  : FunctionPass(ID), DF() {
42 }
43 
45  DF.releaseMemory();
46 }
47 
49  releaseMemory();
50  DF.analyze(getAnalysis<DominatorTreeWrapperPass>().getDomTree());
51  return false;
52 }
53 
55  AU.setPreservesAll();
57 }
58 
60  DF.print(OS);
61 }
62 
63 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
65  print(dbgs());
66 }
67 #endif
68 
69 /// Handle invalidation explicitly.
72  // Check whether the analysis, all analyses on functions, or the function's
73  // CFG have been preserved.
74  auto PAC = PA.getChecker<DominanceFrontierAnalysis>();
75  return !(PAC.preserved() || PAC.preservedSet<AllAnalysesOn<Function>>() ||
76  PAC.preservedSet<CFGAnalyses>());
77 }
78 
79 AnalysisKey DominanceFrontierAnalysis::Key;
80 
84  DF.analyze(AM.getResult<DominatorTreeAnalysis>(F));
85  return DF;
86 }
87 
89  : OS(OS) {}
90 
93  OS << "DominanceFrontier for function: " << F.getName() << "\n";
95 
96  return PreservedAnalyses::all();
97 }
llvm::PreservedAnalyses
A set of analyses that are preserved following a run of a transformation pass.
Definition: PassManager.h:155
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:506
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AllocatorList.h:23
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:48
true
Dominance Frontier true
Definition: DominanceFrontier.cpp:37
print
static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)
Definition: ArchiveWriter.cpp:147
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:783
llvm::Function
Definition: Function.h:62
Pass.h
llvm::initializeDominanceFrontierWrapperPassPass
void initializeDominanceFrontierWrapperPassPass(PassRegistry &)
llvm::DominanceFrontierPrinterPass::DominanceFrontierPrinterPass
DominanceFrontierPrinterPass(raw_ostream &OS)
Definition: DominanceFrontier.cpp:88
llvm::DominanceFrontierWrapperPass::dump
void dump() const
Definition: DominanceFrontier.cpp:64
llvm::AllAnalysesOn
This templated class represents "all analyses that operate over <a particular IR unit>" (e....
Definition: PassManager.h:93
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:44
domfrontier
domfrontier
Definition: DominanceFrontier.cpp:36
Construction
Dominance Frontier Construction
Definition: DominanceFrontier.cpp:37
llvm::DominanceFrontier::invalidate
bool invalidate(Function &F, const PreservedAnalyses &PA, FunctionAnalysisManager::Invalidator &)
Handle invalidation explicitly.
Definition: DominanceFrontier.cpp:70
F
#define F(x, y, z)
Definition: MD5.cpp:56
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:287
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:53
llvm::AnalysisManager::Invalidator
API to communicate dependencies between analyses during invalidation.
Definition: PassManager.h:670
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:81
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:59
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:54
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:72
llvm::DominanceFrontierPrinterPass::run
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
Definition: DominanceFrontier.cpp:92
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:67
llvm::DominanceFrontierBase< BasicBlock, false >
llvm::DominanceFrontierBase::print
void print(raw_ostream &OS) const
print - Convert to human readable form
Definition: DominanceFrontierImpl.h:129
llvm::CFGAnalyses
Represents analyses that only rely on functions' control flow.
Definition: PassManager.h:116
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:161
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:252
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:313
llvm::AnalysisManager
A container for analyses that lazily runs them and caches their results.
Definition: InstructionSimplify.h:44
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:298
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
Debug.h
llvm::Intrinsic::ID
unsigned ID
Definition: TargetTransformInfo.h:38