|
LLVM
10.0.0
|
#include "llvm/Transforms/Scalar/LoopSimplifyCFG.h"#include "llvm/ADT/SmallVector.h"#include "llvm/ADT/Statistic.h"#include "llvm/Analysis/AliasAnalysis.h"#include "llvm/Analysis/AssumptionCache.h"#include "llvm/Analysis/BasicAliasAnalysis.h"#include "llvm/Analysis/DependenceAnalysis.h"#include "llvm/Analysis/DomTreeUpdater.h"#include "llvm/Analysis/GlobalsModRef.h"#include "llvm/Analysis/LoopInfo.h"#include "llvm/Analysis/LoopPass.h"#include "llvm/Analysis/MemorySSA.h"#include "llvm/Analysis/MemorySSAUpdater.h"#include "llvm/Analysis/ScalarEvolution.h"#include "llvm/Analysis/ScalarEvolutionAliasAnalysis.h"#include "llvm/Analysis/TargetTransformInfo.h"#include "llvm/IR/Dominators.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.h"#include "llvm/Transforms/Utils/BasicBlockUtils.h"#include "llvm/Transforms/Utils/Local.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 43 of file LoopSimplifyCFG.cpp.
|
static |
Turn branches and switches with known constant conditions into unconditional branches.
Definition at line 625 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 97 of file LoopSimplifyCFG.cpp.
References llvm::LoopBase< BlockT, LoopT >::addChildLoop(), llvm::LoopInfoBase< BlockT, LoopT >::addTopLevelLoop(), llvm::any_of(), llvm::DomTreeUpdater::applyUpdates(), llvm::MemorySSAUpdater::applyUpdates(), assert(), llvm::SmallVectorTemplateCommon< T >::begin(), llvm::LoopBlocksDFS::beginPostorder(), llvm::LoopBlocksDFS::beginRPO(), llvm::LoopBase< BlockT, LoopT >::blocks(), llvm::SmallVectorImpl< T >::clear(), llvm::LoopBase< BlockT, LoopT >::contains(), llvm::SmallPtrSetImpl< PtrType >::count(), llvm::dbgs(), llvm::DominatorTreeBase< BasicBlock, false >::Delete, llvm::DomTreeUpdater::deleteBB(), llvm::DetatchDeadBlocks(), DFS(), llvm::dump(), E, llvm::DomTreeUpdater::Eager, llvm::SmallVectorBase::empty(), llvm::SmallVectorTemplateCommon< T >::end(), llvm::LoopBlocksDFS::endPostorder(), llvm::LoopBlocksDFS::endRPO(), llvm::LoopInfo::erase(), llvm::Instruction::eraseFromParent(), llvm::CallingConv::Fast, llvm::ScalarEvolution::forgetTopmostLoop(), llvm::formLCSSARecursively(), From, llvm::JumpTable::Full, llvm::UndefValue::get(), llvm::LoopBase< BlockT, LoopT >::getExitBlocks(), llvm::LoopBase< BlockT, LoopT >::getHeader(), llvm::LoopBase< BlockT, LoopT >::getLoopDepth(), llvm::LoopInfoBase< BlockT, LoopT >::getLoopFor(), llvm::LoopBase< BlockT, LoopT >::getLoopLatch(), llvm::LoopBase< BlockT, LoopT >::getLoopPreheader(), llvm::MemorySSAUpdater::getMemorySSA(), llvm::Value::getName(), llvm::LoopBase< BlockT, LoopT >::getNumBlocks(), getOnlyLiveSuccessor(), llvm::BasicBlock::getParent(), llvm::LoopBase< BlockT, LoopT >::getParentLoop(), llvm::BasicBlock::getTerminator(), I, llvm::DominatorTreeBase< BasicBlock, false >::Insert, llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::LoopBlocksDFS::isComplete(), llvm::LoopInfoBase< BlockT, LoopT >::isLoopHeader(), llvm::DominatorTree::isReachableFromEntry(), LLVM_DEBUG, llvm::LoopBlocksDFS::perform(), llvm::AArch64CC::PL, llvm::SmallVectorTemplateBase< T >::push_back(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::LoopInfoBase< BlockT, LoopT >::removeBlock(), removeBlockFromLoops(), llvm::MemorySSAUpdater::removeBlocks(), llvm::MemorySSAUpdater::removeDuplicatePhiEdgesBetween(), llvm::MemorySSAUpdater::removeEdge(), RPO, llvm::SmallVectorBase::size(), llvm::SmallPtrSetImplBase::size(), llvm::SplitBlock(), llvm::successors(), llvm::DominatorTreeBase< NodeT, IsPostDom >::verify(), llvm::LoopInfoBase< BlockT, LoopT >::verify(), llvm::VerifyMemorySSA, and llvm::MemorySSA::verifyMemorySSA().
|
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 58 of file LoopSimplifyCFG.cpp.
References llvm::Instruction::getSuccessor(), and llvm::BasicBlock::getTerminator().
Referenced by getInnermostLoopFor().
| INITIALIZE_PASS_BEGIN | ( | LoopSimplifyCFGLegacyPass | , |
| "loop-simplifycfg" | , | ||
| "Simplify loop CFG" | , | ||
| false | , | ||
| false | |||
| ) |
Referenced by llvm::LoopSimplifyCFGPass::run().
|
static |
Definition at line 643 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::VerifyMemorySSA, and llvm::MemorySSA::verifyMemorySSA().
Referenced by simplifyLoopCFG().
|
static |
Removes BB from all loops from [FirstLoop, LastLoop) in parent chain.
Definition at line 85 of file LoopSimplifyCFG.cpp.
References assert(), llvm::LoopBase< BlockT, LoopT >::contains(), llvm::LoopBase< BlockT, LoopT >::getHeader(), and llvm::LoopBase< BlockT, LoopT >::getParentLoop().
Referenced by getInnermostLoopFor().
|
static |
Definition at line 674 of file LoopSimplifyCFG.cpp.
References constantFoldTerminators(), llvm::ScalarEvolution::forgetTopmostLoop(), and mergeBlocksIntoPredecessors().
Referenced by llvm::LoopSimplifyCFGPass::run().
| STATISTIC | ( | NumTerminatorsFolded | , |
| "Number of terminators folded to unconditional branches" | |||
| ) |
| STATISTIC | ( | NumLoopBlocksDeleted | , |
| "Number of loop blocks deleted" | |||
| ) |
| STATISTIC | ( | NumLoopExitsDeleted | , |
| "Number of loop exiting edges deleted" | |||
| ) |
| loop Simplify loop CFG |
Definition at line 762 of file LoopSimplifyCFG.cpp.
|
static |
Referenced by constantFoldTerminators().
| loop Simplify loop false |
Definition at line 762 of file LoopSimplifyCFG.cpp.
| loop simplifycfg |
Definition at line 762 of file LoopSimplifyCFG.cpp.
1.8.13