LLVM  8.0.1
Macros | Functions | Variables
LoopSimplifyCFG.cpp File Reference
#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/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/DomTreeUpdater.h"
#include "llvm/IR/Dominators.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"
Include dependency graph for LoopSimplifyCFG.cpp:

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 BasicBlockgetOnlyLiveSuccessor (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 bool constantFoldTerminators (Loop &L, DominatorTree &DT, LoopInfo &LI, ScalarEvolution &SE, MemorySSAUpdater *MSSAU)
 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)
 
 INITIALIZE_PASS_BEGIN (LoopSimplifyCFGLegacyPass, "loop-simplifycfg", "Simplify loop CFG", false, false) INITIALIZE_PASS_END(LoopSimplifyCFGLegacyPass
 

Variables

static cl::opt< boolEnableTermFolding ("enable-loop-simplifycfg-term-folding", cl::init(false))
 
loop simplifycfg
 
loop Simplify loop CFG
 
loop Simplify loop false
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "loop-simplifycfg"

Definition at line 42 of file LoopSimplifyCFG.cpp.

Function Documentation

◆ constantFoldTerminators()

static bool constantFoldTerminators ( Loop L,
DominatorTree DT,
LoopInfo LI,
ScalarEvolution SE,
MemorySSAUpdater MSSAU 
)
static

Turn branches and switches with known constant conditions into unconditional branches.

Definition at line 546 of file LoopSimplifyCFG.cpp.

References EnableTermFolding, and llvm::LoopBase< BlockT, LoopT >::getLoopLatch().

Referenced by simplifyLoopCFG().

◆ getOnlyLiveSuccessor()

static BasicBlock* getOnlyLiveSuccessor ( BasicBlock BB)
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 57 of file LoopSimplifyCFG.cpp.

References llvm::LoopBase< BlockT, LoopT >::addChildLoop(), llvm::LoopInfoBase< BlockT, LoopT >::addTopLevelLoop(), llvm::any_of(), assert(), llvm::SmallVectorTemplateCommon< T >::begin(), llvm::LoopBlocksDFS::beginPostorder(), llvm::LoopBlocksDFS::beginRPO(), llvm::LoopBase< BlockT, LoopT >::blocks(), llvm::LoopInfoBase< BlockT, LoopT >::changeLoopFor(), llvm::concat(), llvm::LoopBase< BlockT, LoopT >::contains(), llvm::SmallPtrSetImpl< PtrType >::count(), llvm::dbgs(), llvm::DeleteDeadBlock(), llvm::DomTreeUpdater::deleteEdge(), DFS(), llvm::dump(), llvm::dyn_cast(), E, llvm::DomTreeUpdater::Eager, llvm::SmallVectorBase::empty(), llvm::SmallVectorTemplateCommon< T >::end(), llvm::LoopBlocksDFS::endPostorder(), llvm::LoopBlocksDFS::endRPO(), llvm::LoopInfo::erase(), llvm::Instruction::eraseFromParent(), llvm::ScalarEvolution::forgetTopmostLoop(), From, 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::Value::getName(), llvm::LoopBase< BlockT, LoopT >::getNumBlocks(), llvm::BasicBlock::getParent(), llvm::LoopBase< BlockT, LoopT >::getParentLoop(), llvm::Instruction::getSuccessor(), llvm::BasicBlock::getTerminator(), I, llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::DomTreeUpdater::insertEdge(), llvm::LoopBlocksDFS::isComplete(), llvm::LoopInfoBase< BlockT, LoopT >::isLoopHeader(), llvm::DominatorTree::isReachableFromEntry(), llvm::ConstantInt::isZero(), LLVM_DEBUG, llvm::LoopBlocksDFS::perform(), llvm::SmallVectorTemplateBase< T >::push_back(), llvm::LoopInfoBase< BlockT, LoopT >::removeBlock(), llvm::MemorySSAUpdater::removeBlocks(), llvm::MemorySSAUpdater::removeDuplicatePhiEdgesBetween(), llvm::MemorySSAUpdater::removeEdge(), RPO, SI, llvm::SmallVectorBase::size(), llvm::SmallPtrSetImplBase::size(), llvm::BasicBlock::splitBasicBlock(), llvm::successors(), llvm::DominatorTreeBase< NodeT, IsPostDom >::verify(), and llvm::LoopInfoBase< BlockT, LoopT >::verify().

◆ INITIALIZE_PASS_BEGIN()

INITIALIZE_PASS_BEGIN ( LoopSimplifyCFGLegacyPass  ,
"loop-simplifycfg ,
"Simplify loop CFG ,
false  ,
false   
)

◆ mergeBlocksIntoPredecessors()

static bool mergeBlocksIntoPredecessors ( Loop L,
DominatorTree DT,
LoopInfo LI,
MemorySSAUpdater MSSAU 
)
static

◆ simplifyLoopCFG()

static bool simplifyLoopCFG ( Loop L,
DominatorTree DT,
LoopInfo LI,
ScalarEvolution SE,
MemorySSAUpdater MSSAU 
)
static

◆ STATISTIC() [1/3]

STATISTIC ( NumTerminatorsFolded  ,
"Number of terminators folded to unconditional branches  
)

◆ STATISTIC() [2/3]

STATISTIC ( NumLoopBlocksDeleted  ,
"Number of loop blocks deleted"   
)

◆ STATISTIC() [3/3]

STATISTIC ( NumLoopExitsDeleted  ,
"Number of loop exiting edges deleted"   
)

Variable Documentation

◆ CFG

loop Simplify loop CFG

Definition at line 660 of file LoopSimplifyCFG.cpp.

◆ EnableTermFolding

cl::opt<bool> EnableTermFolding("enable-loop-simplifycfg-term-folding", cl::init(false))
static

Referenced by constantFoldTerminators().

◆ false

loop Simplify loop false

Definition at line 660 of file LoopSimplifyCFG.cpp.

◆ simplifycfg

loop simplifycfg

Definition at line 660 of file LoopSimplifyCFG.cpp.