18 #include "llvm/Config/llvm-config.h" 28 #define DEBUG_TYPE "region" 38 STATISTIC(numRegions,
"The # of regions");
39 STATISTIC(numSimpleRegions,
"The # of simple regions");
47 cl::desc(
"Verify region info (time consuming)"));
52 cl::desc(
"style of printing regions"),
56 "print regions in detail with block_iterator"),
58 "print regions in detail with element_iterator")));
106 updateStatistics(TopLevelRegion);
129 auto DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree();
130 auto PDT = &getAnalysis<PostDominatorTreeWrapperPass>().getPostDomTree();
131 auto DF = &getAnalysis<DominanceFrontierWrapperPass>().getDominanceFrontier();
156 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) 165 "Detect single entry single exit regions",
true,
true)
205 OS <<
"Region Tree for function: " << F.
getName() <<
"\n";
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
void viewRegion(llvm::RegionInfo *RI)
Open a viewer to display the GraphViz vizualization of the analysis result.
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
This class represents lattice values for constants.
A Module instance is used to store all the information related to an LLVM module. ...
static RegionT::PrintStyle printStyle
INITIALIZE_PASS_BEGIN(RegionInfoPass, "regions", "Detect single entry single exit regions", true, true) INITIALIZE_PASS_END(RegionInfoPass
void print(raw_ostream &OS) const
void print(raw_ostream &OS, const Module *) const override
print - Print out the internal state of the pass.
FunctionPass * createRegionInfoPass()
STATISTIC(NumFunctions, "Total number of functions")
Analysis pass which computes a DominatorTree.
void recalculate(Function &F, DominatorTree *DT, PostDominatorTree *PDT, DominanceFrontier *DF)
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
void initializeRegionInfoPassPass(PassRegistry &)
Analysis that detects all canonical Regions.
void viewRegionOnly(llvm::RegionInfo *RI)
Open a viewer to display the GraphViz vizualization of the analysis result.
bool invalidate(Function &F, const PreservedAnalyses &PA, FunctionAnalysisManager::Invalidator &)
Handle invalidation explicitly.
PreservedAnalysisChecker getChecker() const
Build a checker for this PreservedAnalyses and the specified analysis type.
void view()
Opens a viewer to show the GraphViz visualization of the regions.
AnalysisUsage & addRequired()
#define INITIALIZE_PASS_DEPENDENCY(depName)
Detect single entry single exit true
Analysis pass which computes a DominanceFrontier.
A RegionNode represents a subregion or a BasicBlock that is part of a Region.
RegionInfoPrinterPass(raw_ostream &OS)
void verifyAnalysis() const
Region(BasicBlock *Entry, BasicBlock *Exit, RegionInfo *RI, DominatorTree *DT, Region *Parent=nullptr)
void verifyAnalysis() const override
verifyAnalysis() - This member can be implemented by a analysis pass to check state of analysis infor...
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree...
bool isSimple() const
Is this a simple region?
const BasicBlock & getEntryBlock() const
A set of analyses that are preserved following a run of a transformation pass.
LLVM Basic Block Representation.
ValuesClass values(OptsTy... Options)
Helper to build a ValuesClass by forwarding a variable number of arguments as an initializer list to ...
Represent the analysis usage information of a pass.
FunctionPass class - This class is used to implement most global optimizations.
RegionInfo run(Function &F, FunctionAnalysisManager &AM)
static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)
void viewOnly()
Opens a viewer to show the GraphViz visualization of this region without instructions in the BasicBlo...
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
INITIALIZE_PASS_END(RegBankSelect, DEBUG_TYPE, "Assign register bank of generic virtual registers", false, false) RegBankSelect
~RegionInfoPass() override
Analysis pass which computes a PostDominatorTree.
void releaseMemory() override
releaseMemory() - This member can be implemented by a pass if it wants to be able to release its memo...
A single entry single exit Region.
Analysis pass that exposes the RegionInfo for a function.
void setPreservesAll()
Set by analyses that do not transform their input at all.
PostDominatorTree Class - Concrete subclass of DominatorTree that is used to compute the post-dominat...
Represents analyses that only rely on functions' control flow.
#define clEnumValN(ENUMVAL, FLAGNAME, DESC)
StringRef getName() const
Return a constant reference to the value's name.
static cl::opt< Region::PrintStyle, true > printStyleX("print-region-style", cl::location(RegionInfo::printStyle), cl::Hidden, cl::desc("style of printing regions"), cl::values(clEnumValN(Region::PrintNone, "none", "print no details"), clEnumValN(Region::PrintBB, "bb", "print regions in detail with block_iterator"), clEnumValN(Region::PrintRN, "rn", "print regions in detail with element_iterator")))
AnalysisUsage & addRequiredTransitive()
API to communicate dependencies between analyses during invalidation.
This templated class represents "all analyses that operate over <a particular IR unit>" (e...
bool runOnFunction(Function &F) override
runOnFunction - Virtual method overriden by subclasses to do the per-function processing of the pass...
void updateStatistics(Region *R) final
This class implements an extremely fast bulk output stream that can only output to a stream...
print Instructions which execute on loop entry
A container for analyses that lazily runs them and caches their results.
Legacy analysis pass which computes a DominatorTree.
This header defines various interfaces for pass management in LLVM.
static cl::opt< bool, true > VerifyRegionInfoX("verify-region-info", cl::location(RegionInfoBase< RegionTraits< Function >>::VerifyRegionInfo), cl::desc("Verify region info (time consuming)"))
A special type used by analysis passes to provide an address that identifies that particular analysis...
LocationClass< Ty > location(Ty &L)