LLVM  10.0.0svn
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 //===----------------------------------------------------------------------===//
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/Pass.h"
16 #include "llvm/Support/Compiler.h"
17 #include "llvm/Support/Debug.h"
20 using namespace llvm;
22 namespace llvm {
28 } // end namespace llvm
33  "Dominance Frontier Construction", true, true)
36  "Dominance Frontier Construction", true, true)
38 DominanceFrontierWrapperPass::DominanceFrontierWrapperPass()
39  : FunctionPass(ID), DF() {
41 }
44  DF.releaseMemory();
45 }
48  releaseMemory();
49  DF.analyze(getAnalysis<DominatorTreeWrapperPass>().getDomTree());
50  return false;
51 }
54  AU.setPreservesAll();
56 }
59  DF.print(OS);
60 }
62 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
64  print(dbgs());
65 }
66 #endif
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 }
78 AnalysisKey DominanceFrontierAnalysis::Key;
84  return DF;
85 }
88  : OS(OS) {}
92  OS << "DominanceFrontier for function: " << F.getName() << "\n";
95  return PreservedAnalyses::all();
96 }
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Definition: PassManager.h:777
This class represents lattice values for constants.
Definition: AllocatorList.h:23
Mark debug helper function definitions like dump() that should not be stripped from debug builds...
Definition: Compiler.h:484
INITIALIZE_PASS_BEGIN(DominanceFrontierWrapperPass, "domfrontier", "Dominance Frontier Construction", true, true) INITIALIZE_PASS_END(DominanceFrontierWrapperPass
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:66
Analysis pass which computes a DominatorTree.
Definition: Dominators.h:230
PreservedAnalysisChecker getChecker() const
Build a checker for this PreservedAnalyses and the specified analysis type.
Definition: PassManager.h:312
AnalysisUsage & addRequired()
Definition: PassSupport.h:50
void print(raw_ostream &OS) const
print - Convert to human readable form
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
Analysis pass which computes a DominanceFrontier.
Dominance Frontier Construction
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
A set of analyses that are preserved following a run of a transformation pass.
Definition: PassManager.h:154
Represent the analysis usage information of a pass.
FunctionPass class - This class is used to implement most global optimizations.
Definition: Pass.h:284
static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Definition: PassManager.h:160
INITIALIZE_PASS_END(RegBankSelect, DEBUG_TYPE, "Assign register bank of generic virtual registers", false, false) RegBankSelect
void initializeDominanceFrontierWrapperPassPass(PassRegistry &)
DominanceFrontier run(Function &F, FunctionAnalysisManager &AM)
Run the analysis pass over a function and produce a dominator tree.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:132
void print(raw_ostream &OS, const Module *=nullptr) const override
print - Print out the internal state of the pass.
bool runOnFunction(Function &) override
runOnFunction - Virtual method overriden by subclasses to do the per-function processing of the pass...
bool invalidate(Function &F, const PreservedAnalyses &PA, FunctionAnalysisManager::Invalidator &)
Handle invalidation explicitly.
void setPreservesAll()
Set by analyses that do not transform their input at all.
Represents analyses that only rely on functions&#39; control flow.
Definition: PassManager.h:115
void releaseMemory() override
releaseMemory() - This member can be implemented by a pass if it wants to be able to release its memo...
StringRef getName() const
Return a constant reference to the value&#39;s name.
Definition: Value.cpp:214
API to communicate dependencies between analyses during invalidation.
Definition: PassManager.h:649
This templated class represents "all analyses that operate over <a particular IR unit>" (e...
Definition: PassManager.h:92
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:45
Dominance Frontier true
A container for analyses that lazily runs them and caches their results.
Legacy analysis pass which computes a DominatorTree.
Definition: Dominators.h:259
This header defines various interfaces for pass management in LLVM.
A special type used by analysis passes to provide an address that identifies that particular analysis...
Definition: PassManager.h:71