|
LLVM
3.7.0
|
#include "llvm/Transforms/Scalar.h"#include "llvm/ADT/STLExtras.h"#include "llvm/ADT/SmallPtrSet.h"#include "llvm/ADT/Statistic.h"#include "llvm/Analysis/AssumptionCache.h"#include "llvm/Analysis/CodeMetrics.h"#include "llvm/Analysis/InstructionSimplify.h"#include "llvm/Analysis/LoopInfo.h"#include "llvm/Analysis/LoopPass.h"#include "llvm/Analysis/ScalarEvolution.h"#include "llvm/Analysis/TargetTransformInfo.h"#include "llvm/IR/Constants.h"#include "llvm/IR/DerivedTypes.h"#include "llvm/IR/Dominators.h"#include "llvm/IR/Function.h"#include "llvm/IR/Instructions.h"#include "llvm/IR/Module.h"#include "llvm/IR/MDBuilder.h"#include "llvm/Support/CommandLine.h"#include "llvm/Support/Debug.h"#include "llvm/Support/raw_ostream.h"#include "llvm/Transforms/Utils/BasicBlockUtils.h"#include "llvm/Transforms/Utils/Cloning.h"#include "llvm/Transforms/Utils/Local.h"#include <algorithm>#include <map>#include <set>Go to the source code of this file.
Macros | |
| #define | DEBUG_TYPE "loop-unswitch" |
Functions | |
| STATISTIC (NumBranches,"Number of branches unswitched") | |
| STATISTIC (NumSwitches,"Number of switches unswitched") | |
| STATISTIC (NumSelects,"Number of selects unswitched") | |
| STATISTIC (NumTrivial,"Number of unswitches that are trivial") | |
| STATISTIC (NumSimplify,"Number of simplifications of unswitched code") | |
| STATISTIC (TotalInsts,"Total number of instructions analyzed") | |
| INITIALIZE_PASS_BEGIN (LoopUnswitch,"loop-unswitch","Unswitch loops", false, false) INITIALIZE_PASS_END(LoopUnswitch | |
| static Value * | FindLIVLoopCondition (Value *Cond, Loop *L, bool &Changed) |
| FindLIVLoopCondition - Cond is a condition that occurs in L. More... | |
| static bool | isTrivialLoopExitBlockHelper (Loop *L, BasicBlock *BB, BasicBlock *&ExitBB, std::set< BasicBlock * > &Visited) |
| isTrivialLoopExitBlock - Check to see if all paths from BB exit the loop with no side effects (including infinite loops). More... | |
| static BasicBlock * | isTrivialLoopExitBlock (Loop *L, BasicBlock *BB) |
| isTrivialLoopExitBlock - Return true if the specified block unconditionally leads to an exit from the specified loop, and has no side-effects in the process. More... | |
| static Loop * | CloneLoop (Loop *L, Loop *PL, ValueToValueMapTy &VM, LoopInfo *LI, LPPassManager *LPM) |
| CloneLoop - Recursively clone the specified loop and all of its children, mapping the blocks with the specified map. More... | |
| static void | copyMetadata (Instruction *DstInst, const Instruction *SrcInst, bool Swapped) |
| static void | RemoveFromWorklist (Instruction *I, std::vector< Instruction * > &Worklist) |
| RemoveFromWorklist - Remove all instances of I from the worklist vector specified. More... | |
| static void | ReplaceUsesOfWith (Instruction *I, Value *V, std::vector< Instruction * > &Worklist, Loop *L, LPPassManager *LPM) |
| ReplaceUsesOfWith - When we find that I really equals V, remove I from the program, replacing all uses with V and update the worklist. More... | |
Variables | |
| static cl::opt< unsigned > | Threshold ("loop-unswitch-threshold", cl::desc("Max loop size to unswitch"), cl::init(100), cl::Hidden) |
| loop | unswitch |
| loop Unswitch | loops |
| loop Unswitch | false |
| #define DEBUG_TYPE "loop-unswitch" |
Definition at line 58 of file LoopUnswitch.cpp.
|
static |
CloneLoop - Recursively clone the specified loop and all of its children, mapping the blocks with the specified map.
Definition at line 700 of file LoopUnswitch.cpp.
References llvm::LoopBase< N, M >::addBasicBlockToLoop(), llvm::LoopBase< N, M >::begin(), llvm::LoopBase< N, M >::block_begin(), llvm::LoopBase< N, M >::block_end(), llvm::LoopBase< N, M >::end(), llvm::LoopInfoBase< N, M >::getLoopFor(), I, and llvm::LPPassManager::insertLoop().
|
static |
Definition at line 718 of file LoopUnswitch.cpp.
References llvm::Instruction::getAllMetadata(), llvm::BasicBlock::getContext(), llvm::Instruction::getParent(), llvm::MDString::getString(), llvm::Instruction::hasMetadata(), llvm::LLVMContext::MD_dbg, llvm::LLVMContext::MD_prof, and llvm::Instruction::setMetadata().
FindLIVLoopCondition - Cond is a condition that occurs in L.
If it is invariant in the loop, or has an invariant piece, return the invariant. Otherwise, return null.
Definition at line 373 of file LoopUnswitch.cpp.
References llvm::APIntOps::And(), llvm::Value::getType(), llvm::Type::isVectorTy(), llvm::Loop::makeLoopInvariant(), and llvm::APIntOps::Or().
|
static |
isTrivialLoopExitBlock - Return true if the specified block unconditionally leads to an exit from the specified loop, and has no side-effects in the process.
If so, return the block that is exited to, otherwise return null.
Definition at line 572 of file LoopUnswitch.cpp.
References llvm::LoopBase< N, M >::getHeader(), and isTrivialLoopExitBlockHelper().
|
static |
isTrivialLoopExitBlock - Check to see if all paths from BB exit the loop with no side effects (including infinite loops).
If true, we return true and set ExitBB to the block we exit through.
Definition at line 537 of file LoopUnswitch.cpp.
References llvm::BasicBlock::begin(), llvm::LoopBase< N, M >::contains(), llvm::BasicBlock::end(), I, llvm::succ_begin(), and llvm::succ_end().
Referenced by isTrivialLoopExitBlock().
|
static |
RemoveFromWorklist - Remove all instances of I from the worklist vector specified.
Definition at line 999 of file LoopUnswitch.cpp.
References I, and llvm::sys::fs::remove().
Referenced by ReplaceUsesOfWith().
|
static |
ReplaceUsesOfWith - When we find that I really equals V, remove I from the program, replacing all uses with V and update the worklist.
Definition at line 1008 of file LoopUnswitch.cpp.
References llvm::dbgs(), DEBUG, llvm::LPPassManager::deleteSimpleAnalysisValue(), llvm::Instruction::eraseFromParent(), llvm::User::getNumOperands(), llvm::User::getOperand(), RemoveFromWorklist(), llvm::Value::replaceAllUsesWith(), and llvm::Value::users().
| STATISTIC | ( | NumBranches | , |
| "Number of branches unswitched" | |||
| ) |
| STATISTIC | ( | NumSwitches | , |
| "Number of switches unswitched" | |||
| ) |
| STATISTIC | ( | NumSelects | , |
| "Number of selects unswitched" | |||
| ) |
| STATISTIC | ( | NumTrivial | , |
| "Number of unswitches that are trivial" | |||
| ) |
| STATISTIC | ( | NumSimplify | , |
| "Number of simplifications of unswitched code" | |||
| ) |
| STATISTIC | ( | TotalInsts | , |
| "Total number of instructions analyzed" | |||
| ) |
| loop Unswitch false |
Definition at line 363 of file LoopUnswitch.cpp.
| loop Unswitch loops |
Definition at line 363 of file LoopUnswitch.cpp.
|
static |
| loop unswitch |
Definition at line 363 of file LoopUnswitch.cpp.
1.8.6