LLVM 17.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"
#include <optional>
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. | |
static void | removeBlockFromLoops (BasicBlock *BB, Loop *FirstLoop, Loop *LastLoop=nullptr) |
Removes BB from all loops from [FirstLoop, LastLoop) in parent chain. | |
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 . | |
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. | |
static bool | mergeBlocksIntoPredecessors (Loop &L, DominatorTree &DT, LoopInfo &LI, MemorySSAUpdater *MSSAU, ScalarEvolution &SE) |
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 38 of file LoopSimplifyCFG.cpp.
|
static |
Turn branches and switches with known constant conditions into unconditional branches.
Definition at line 645 of file LoopSimplifyCFG.cpp.
References EnableTermFolding.
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 92 of file LoopSimplifyCFG.cpp.
References llvm::LoopBase< BlockT, LoopT >::contains(), 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 53 of file LoopSimplifyCFG.cpp.
References Cond, llvm::Instruction::getSuccessor(), llvm::BasicBlock::getTerminator(), and SI.
INITIALIZE_PASS_BEGIN | ( | LoopSimplifyCFGLegacyPass | , |
"loop-simplifycfg" | , | ||
"Simplify loop CFG" | , | ||
false | , | ||
false | |||
) |
|
static |
Definition at line 663 of file LoopSimplifyCFG.cpp.
References Blocks, llvm::ScalarEvolution::forgetBlockAndLoopDispositions(), 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 80 of file LoopSimplifyCFG.cpp.
References assert(), llvm::LoopBase< BlockT, LoopT >::contains(), llvm::LoopBase< BlockT, LoopT >::getHeader(), and llvm::LoopBase< BlockT, LoopT >::getParentLoop().
|
static |
Definition at line 698 of file LoopSimplifyCFG.cpp.
References constantFoldTerminators(), llvm::ScalarEvolution::forgetTopmostLoop(), and mergeBlocksIntoPredecessors().
Referenced by llvm::LoopSimplifyCFGPass::run().
STATISTIC | ( | NumLoopBlocksDeleted | , |
"Number of loop blocks deleted" | |||
) |
STATISTIC | ( | NumLoopExitsDeleted | , |
"Number of loop exiting edges deleted" | |||
) |
STATISTIC | ( | NumTerminatorsFolded | , |
"Number of terminators folded to unconditional branches" | |||
) |
loop Simplify loop CFG |
Definition at line 781 of file LoopSimplifyCFG.cpp.
|
static |
Referenced by constantFoldTerminators().
loop Simplify loop false |
Definition at line 781 of file LoopSimplifyCFG.cpp.
loop simplifycfg |
Definition at line 780 of file LoopSimplifyCFG.cpp.