LLVM
15.0.0git
|
#include "llvm/Transforms/Scalar/LoopSimplifyCFG.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/DependenceAnalysis.h"
#include "llvm/Analysis/DomTreeUpdater.h"
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Analysis/LoopIterator.h"
#include "llvm/Analysis/LoopPass.h"
#include "llvm/Analysis/MemorySSA.h"
#include "llvm/Analysis/MemorySSAUpdater.h"
#include "llvm/Analysis/ScalarEvolution.h"
#include "llvm/IR/Dominators.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/InitializePasses.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Transforms/Scalar.h"
#include "llvm/Transforms/Scalar/LoopPassManager.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include "llvm/Transforms/Utils/LoopUtils.h"
Go to the source code of this file.
Macros | |
#define | DEBUG_TYPE "loop-simplifycfg" |
Functions | |
STATISTIC (NumTerminatorsFolded, "Number of terminators folded to unconditional branches") | |
STATISTIC (NumLoopBlocksDeleted, "Number of loop blocks deleted") | |
STATISTIC (NumLoopExitsDeleted, "Number of loop exiting edges deleted") | |
static BasicBlock * | getOnlyLiveSuccessor (BasicBlock *BB) |
If BB is a switch or a conditional branch, but only one of its successors can be reached from this block in runtime, return this successor. More... | |
static void | removeBlockFromLoops (BasicBlock *BB, Loop *FirstLoop, Loop *LastLoop=nullptr) |
Removes BB from all loops from [FirstLoop, LastLoop) in parent chain. More... | |
static Loop * | getInnermostLoopFor (SmallPtrSetImpl< BasicBlock * > &BBs, Loop &L, LoopInfo &LI) |
Find innermost loop that contains at least one block from BBs and contains the header of loop L . More... | |
static bool | constantFoldTerminators (Loop &L, DominatorTree &DT, LoopInfo &LI, ScalarEvolution &SE, MemorySSAUpdater *MSSAU, bool &IsLoopDeleted) |
Turn branches and switches with known constant conditions into unconditional branches. More... | |
static bool | mergeBlocksIntoPredecessors (Loop &L, DominatorTree &DT, LoopInfo &LI, MemorySSAUpdater *MSSAU) |
static bool | simplifyLoopCFG (Loop &L, DominatorTree &DT, LoopInfo &LI, ScalarEvolution &SE, MemorySSAUpdater *MSSAU, bool &IsLoopDeleted) |
INITIALIZE_PASS_BEGIN (LoopSimplifyCFGLegacyPass, "loop-simplifycfg", "Simplify loop CFG", false, false) INITIALIZE_PASS_END(LoopSimplifyCFGLegacyPass | |
Variables | |
static cl::opt< bool > | EnableTermFolding ("enable-loop-simplifycfg-term-folding", cl::init(true)) |
loop | simplifycfg |
loop Simplify loop | CFG |
loop Simplify loop | false |
#define DEBUG_TYPE "loop-simplifycfg" |
Definition at line 37 of file LoopSimplifyCFG.cpp.
|
static |
Turn branches and switches with known constant conditions into unconditional branches.
Definition at line 627 of file LoopSimplifyCFG.cpp.
References EnableTermFolding, and llvm::LoopBase< BlockT, LoopT >::getLoopLatch().
Referenced by simplifyLoopCFG().
|
static |
Find innermost loop that contains at least one block from BBs
and contains the header of loop L
.
Definition at line 91 of file LoopSimplifyCFG.cpp.
References BB, llvm::LoopBase< BlockT, LoopT >::contains(), llvm::LoopBase< BlockT, LoopT >::getHeader(), llvm::LoopBase< BlockT, LoopT >::getLoopDepth(), llvm::LoopInfoBase< BlockT, LoopT >::getLoopFor(), and llvm::LoopBase< BlockT, LoopT >::getParentLoop().
|
static |
If BB
is a switch or a conditional branch, but only one of its successors can be reached from this block in runtime, return this successor.
Otherwise, return nullptr.
Definition at line 52 of file LoopSimplifyCFG.cpp.
INITIALIZE_PASS_BEGIN | ( | LoopSimplifyCFGLegacyPass | , |
"loop-simplifycfg" | , | ||
"Simplify loop CFG" | , | ||
false | , | ||
false | |||
) |
|
static |
Definition at line 645 of file LoopSimplifyCFG.cpp.
References llvm::LoopBase< BlockT, LoopT >::blocks(), llvm::DomTreeUpdater::Eager, llvm::LoopInfoBase< BlockT, LoopT >::getLoopFor(), llvm::MemorySSAUpdater::getMemorySSA(), llvm::BasicBlock::getSinglePredecessor(), llvm::BasicBlock::getSingleSuccessor(), llvm::MergeBlockIntoPredecessor(), llvm::MemorySSA::verifyMemorySSA(), and llvm::VerifyMemorySSA.
Referenced by simplifyLoopCFG().
|
static |
Removes BB
from all loops from [FirstLoop, LastLoop) in parent chain.
Definition at line 79 of file LoopSimplifyCFG.cpp.
References assert(), BB, llvm::LoopBase< BlockT, LoopT >::contains(), llvm::LoopBase< BlockT, LoopT >::getHeader(), and llvm::LoopBase< BlockT, LoopT >::getParentLoop().
|
static |
Definition at line 676 of file LoopSimplifyCFG.cpp.
References constantFoldTerminators(), llvm::ScalarEvolution::forgetTopmostLoop(), and mergeBlocksIntoPredecessors().
Referenced by llvm::LoopSimplifyCFGPass::run().
Definition at line 760 of file LoopSimplifyCFG.cpp.
|
static |
Referenced by constantFoldTerminators().
Definition at line 760 of file LoopSimplifyCFG.cpp.
loop simplifycfg |
Definition at line 759 of file LoopSimplifyCFG.cpp.