#include "llvm/Analysis/RegionInfo.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/DominanceFrontier.h"
#include "llvm/InitializePasses.h"
#ifndef NDEBUG
#include "llvm/Analysis/RegionPrinter.h"
#endif
#include "llvm/Analysis/Passes.h"
#include "llvm/Analysis/RegionInfoImpl.h"
#include "llvm/Config/llvm-config.h"
#include "llvm/IR/Function.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Compiler.h"
usingnamespacellvm;
#define DEBUG_TYPE …
namespace llvm {
template class RegionBase<RegionTraits<Function>>;
template class RegionNodeBase<RegionTraits<Function>>;
template class RegionInfoBase<RegionTraits<Function>>;
}
STATISTIC(numRegions, "The # of regions");
STATISTIC(numSimpleRegions, "The # of simple regions");
static cl::opt<bool,true>
VerifyRegionInfoX(
"verify-region-info",
cl::location(RegionInfoBase<RegionTraits<Function>>::VerifyRegionInfo),
cl::desc("Verify region info (time consuming)"));
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")));
Region::Region(BasicBlock *Entry, BasicBlock *Exit,
RegionInfo* RI,
DominatorTree *DT, Region *Parent) : … { … }
Region::~Region() = default;
RegionInfo::RegionInfo() = default;
RegionInfo::~RegionInfo() = default;
bool RegionInfo::invalidate(Function &F, const PreservedAnalyses &PA,
FunctionAnalysisManager::Invalidator &) { … }
void RegionInfo::updateStatistics(Region *R) { … }
void RegionInfo::recalculate(Function &F, DominatorTree *DT_,
PostDominatorTree *PDT_, DominanceFrontier *DF_) { … }
#ifndef NDEBUG
void RegionInfo::view() { viewRegion(this); }
void RegionInfo::viewOnly() { viewRegionOnly(this); }
#endif
RegionInfoPass::RegionInfoPass() : … { … }
RegionInfoPass::~RegionInfoPass() = default;
bool RegionInfoPass::runOnFunction(Function &F) { … }
void RegionInfoPass::releaseMemory() { … }
void RegionInfoPass::verifyAnalysis() const { … }
void RegionInfoPass::getAnalysisUsage(AnalysisUsage &AU) const { … }
void RegionInfoPass::print(raw_ostream &OS, const Module *) const { … }
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void RegionInfoPass::dump() const {
RI.dump();
}
#endif
char RegionInfoPass::ID = …;
INITIALIZE_PASS_BEGIN(RegionInfoPass, "regions",
"Detect single entry single exit regions", true, true)
INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
INITIALIZE_PASS_DEPENDENCY(PostDominatorTreeWrapperPass)
INITIALIZE_PASS_DEPENDENCY(DominanceFrontierWrapperPass)
INITIALIZE_PASS_END(RegionInfoPass, "regions",
"Detect single entry single exit regions", true, true)
namespace llvm {
FunctionPass *createRegionInfoPass() { … }
}
AnalysisKey RegionInfoAnalysis::Key;
RegionInfo RegionInfoAnalysis::run(Function &F, FunctionAnalysisManager &AM) { … }
RegionInfoPrinterPass::RegionInfoPrinterPass(raw_ostream &OS)
: … { … }
PreservedAnalyses RegionInfoPrinterPass::run(Function &F,
FunctionAnalysisManager &AM) { … }
PreservedAnalyses RegionInfoVerifierPass::run(Function &F,
FunctionAnalysisManager &AM) { … }