#include "llvm/Transforms/IPO/LoopExtractor.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/AssumptionCache.h"
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/IR/Dominators.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/PassManager.h"
#include "llvm/InitializePasses.h"
#include "llvm/Pass.h"
#include "llvm/Transforms/IPO.h"
#include "llvm/Transforms/Utils.h"
#include "llvm/Transforms/Utils/CodeExtractor.h"
usingnamespacellvm;
#define DEBUG_TYPE …
STATISTIC(NumExtracted, "Number of loops extracted");
namespace {
struct LoopExtractorLegacyPass : public ModulePass { … };
struct LoopExtractor { … };
}
char LoopExtractorLegacyPass::ID = …;
INITIALIZE_PASS_BEGIN(LoopExtractorLegacyPass, "loop-extract",
"Extract loops into new functions", false, false)
INITIALIZE_PASS_DEPENDENCY(BreakCriticalEdges)
INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass)
INITIALIZE_PASS_DEPENDENCY(LoopSimplify)
INITIALIZE_PASS_END(LoopExtractorLegacyPass, "loop-extract",
"Extract loops into new functions", false, false)
namespace {
struct SingleLoopExtractor : public LoopExtractorLegacyPass { … };
}
char SingleLoopExtractor::ID = …;
INITIALIZE_PASS(…)
Pass *llvm::createLoopExtractorPass() { … }
bool LoopExtractorLegacyPass::runOnModule(Module &M) { … }
bool LoopExtractor::runOnModule(Module &M) { … }
bool LoopExtractor::runOnFunction(Function &F) { … }
bool LoopExtractor::extractLoops(Loop::iterator From, Loop::iterator To,
LoopInfo &LI, DominatorTree &DT) { … }
bool LoopExtractor::extractLoop(Loop *L, LoopInfo &LI, DominatorTree &DT) { … }
Pass *llvm::createSingleLoopExtractorPass() { … }
PreservedAnalyses LoopExtractorPass::run(Module &M, ModuleAnalysisManager &AM) { … }
void LoopExtractorPass::printPipeline(
raw_ostream &OS, function_ref<StringRef(StringRef)> MapClassName2PassName) { … }