#include "llvm/Transforms/Utils/LCSSA.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/Analysis/BasicAliasAnalysis.h"
#include "llvm/Analysis/BranchProbabilityInfo.h"
#include "llvm/Analysis/GlobalsModRef.h"
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Analysis/LoopPass.h"
#include "llvm/Analysis/MemorySSA.h"
#include "llvm/Analysis/ScalarEvolution.h"
#include "llvm/Analysis/ScalarEvolutionAliasAnalysis.h"
#include "llvm/IR/DebugInfo.h"
#include "llvm/IR/Dominators.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/PredIteratorCache.h"
#include "llvm/InitializePasses.h"
#include "llvm/Pass.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Transforms/Utils.h"
#include "llvm/Transforms/Utils/LoopUtils.h"
#include "llvm/Transforms/Utils/SSAUpdater.h"
usingnamespacellvm;
#define DEBUG_TYPE …
STATISTIC(NumLCSSA, "Number of live out of a loop variables");
#ifdef EXPENSIVE_CHECKS
static bool VerifyLoopLCSSA = true;
#else
static bool VerifyLoopLCSSA = …;
#endif
static cl::opt<bool, true>
VerifyLoopLCSSAFlag("verify-loop-lcssa", cl::location(VerifyLoopLCSSA),
cl::Hidden,
cl::desc("Verify loop lcssa form (time consuming)"));
static bool isExitBlock(BasicBlock *BB,
const SmallVectorImpl<BasicBlock *> &ExitBlocks) { … }
LoopExitBlocksTy;
static bool
formLCSSAForInstructionsImpl(SmallVectorImpl<Instruction *> &Worklist,
const DominatorTree &DT, const LoopInfo &LI,
ScalarEvolution *SE,
SmallVectorImpl<PHINode *> *PHIsToRemove,
SmallVectorImpl<PHINode *> *InsertedPHIs,
LoopExitBlocksTy &LoopExitBlocks) { … }
bool llvm::formLCSSAForInstructions(SmallVectorImpl<Instruction *> &Worklist,
const DominatorTree &DT, const LoopInfo &LI,
ScalarEvolution *SE,
SmallVectorImpl<PHINode *> *PHIsToRemove,
SmallVectorImpl<PHINode *> *InsertedPHIs) { … }
static void computeBlocksDominatingExits(
Loop &L, const DominatorTree &DT, ArrayRef<BasicBlock *> ExitBlocks,
SmallSetVector<BasicBlock *, 8> &BlocksDominatingExits) { … }
static bool formLCSSAImpl(Loop &L, const DominatorTree &DT, const LoopInfo *LI,
ScalarEvolution *SE,
LoopExitBlocksTy &LoopExitBlocks) { … }
bool llvm::formLCSSA(Loop &L, const DominatorTree &DT, const LoopInfo *LI,
ScalarEvolution *SE) { … }
static bool formLCSSARecursivelyImpl(Loop &L, const DominatorTree &DT,
const LoopInfo *LI, ScalarEvolution *SE,
LoopExitBlocksTy &LoopExitBlocks) { … }
bool llvm::formLCSSARecursively(Loop &L, const DominatorTree &DT,
const LoopInfo *LI, ScalarEvolution *SE) { … }
static bool formLCSSAOnAllLoops(const LoopInfo *LI, const DominatorTree &DT,
ScalarEvolution *SE) { … }
namespace {
struct LCSSAWrapperPass : public FunctionPass { … };
}
char LCSSAWrapperPass::ID = …;
INITIALIZE_PASS_BEGIN(LCSSAWrapperPass, "lcssa", "Loop-Closed SSA Form Pass",
false, false)
INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass)
INITIALIZE_PASS_DEPENDENCY(LCSSAVerificationPass)
INITIALIZE_PASS_END(LCSSAWrapperPass, "lcssa", "Loop-Closed SSA Form Pass",
false, false)
Pass *llvm::createLCSSAPass() { … }
char &llvm::LCSSAID = …;
bool LCSSAWrapperPass::runOnFunction(Function &F) { … }
PreservedAnalyses LCSSAPass::run(Function &F, FunctionAnalysisManager &AM) { … }