LLVM: lib/Transforms/Instrumentation/ControlHeightReduction.cpp File Reference (original) (raw)

Go to the source code of this file.

Namespaces
namespace llvm
This is an optimization pass for GlobalISel generic memory operations.
Functions
static void parseCHRFilterFiles ()
static raw_ostream LLVM_ATTRIBUTE_UNUSED & operator<< (raw_ostream &OS, const CHRStats &Stats)
static raw_ostream & operator<< (raw_ostream &OS, const CHRScope &Scope)
static bool shouldApply (Function &F, ProfileSummaryInfo &PSI)
static void LLVM_ATTRIBUTE_UNUSED dumpIR (Function &F, const char *Label, CHRStats *Stats)
static bool isHoistableInstructionType (Instruction *I)
static bool isHoistable (Instruction *I, DominatorTree &DT)
static const std::set< Value * > & getBaseValues (Value *V, DominatorTree &DT, DenseMap< Value *, std::set< Value * > > &Visited)
static bool checkHoistValue (Value *V, Instruction *InsertPoint, DominatorTree &DT, DenseSet< Instruction * > &Unhoistables, DenseSet< Instruction * > *HoistStops, DenseMap< Instruction *, bool > &Visited)
static bool extractBranchProbabilities (Instruction *I, BranchProbability &TrueProb, BranchProbability &FalseProb)
static BranchProbability getCHRBiasThreshold ()
template<typename K , typename S , typename M >
static bool checkBias (K *Key, BranchProbability TrueProb, BranchProbability FalseProb, S &TrueSet, S &FalseSet, M &BiasMap)
static bool checkBiasedBranch (BranchInst *BI, Region *R, DenseSet< Region * > &TrueBiasedRegionsGlobal, DenseSet< Region * > &FalseBiasedRegionsGlobal, DenseMap< Region *, BranchProbability > &BranchBiasMap)
static bool checkBiasedSelect (SelectInst *SI, Region *R, DenseSet< SelectInst * > &TrueBiasedSelectsGlobal, DenseSet< SelectInst * > &FalseBiasedSelectsGlobal, DenseMap< SelectInst *, BranchProbability > &SelectBiasMap)
static Instruction * getBranchInsertPoint (RegInfo &RI)
static DenseSet< Value * > getCHRConditionValuesForRegion (RegInfo &RI)
static bool shouldSplit (Instruction *InsertPoint, DenseSet< Value * > &PrevConditionValues, DenseSet< Value * > &ConditionValues, DominatorTree &DT, DenseSet< Instruction * > &Unhoistables)
static void getSelectsInScope (CHRScope *Scope, DenseSet< Instruction * > &Output)
static bool hasAtLeastTwoBiasedBranches (CHRScope *Scope)
static bool CHRScopeSorter (CHRScope *Scope1, CHRScope *Scope2)
static void hoistValue (Value *V, Instruction *HoistPoint, Region *R, HoistStopMapTy &HoistStopMap, DenseSet< Instruction * > &HoistedSet, DenseSet< PHINode * > &TrivialPHIs, DominatorTree &DT)
static void hoistScopeConditions (CHRScope *Scope, Instruction *HoistPoint, DenseSet< PHINode * > &TrivialPHIs, DominatorTree &DT)
static bool negateICmpIfUsedByBranchOrSelectOnly (ICmpInst *ICmp, Instruction *ExcludedUser, CHRScope *Scope)
static void insertTrivialPHIs (CHRScope *Scope, BasicBlock *EntryBlock, BasicBlock *ExitBlock, DenseSet< PHINode * > &TrivialPHIs)
static void LLVM_ATTRIBUTE_UNUSED assertCHRRegionsHaveBiasedBranchOrSelect (CHRScope *Scope)
static void LLVM_ATTRIBUTE_UNUSED assertBranchOrSelectConditionHoisted (CHRScope *Scope, BasicBlock *PreEntryBlock)
static void LLVM_ATTRIBUTE_UNUSED dumpScopes (SmallVectorImpl< CHRScope * > &Scopes, const char *Label)
Variables
static cl::opt< bool > DisableCHR ("disable-chr", cl::init(false), cl::Hidden, cl::desc("Disable CHR for all functions"))
static cl::opt< bool > ForceCHR ("force-chr", cl::init(false), cl::Hidden, cl::desc("Apply CHR for all functions"))
static cl::opt< double > CHRBiasThreshold ("chr-bias-threshold", cl::init(0.99), cl::Hidden, cl::desc("CHR considers a branch bias greater than this ratio as biased"))
static cl::opt< unsigned > CHRMergeThreshold ("chr-merge-threshold", cl::init(2), cl::Hidden, cl::desc("CHR merges a group of N branches/selects where N >= this value"))
static cl::opt< std::string > CHRModuleList ("chr-module-list", cl::init(""), cl::Hidden, cl::desc("Specify file to retrieve the list of modules to apply CHR to"))
static cl::opt< std::string > CHRFunctionList ("chr-function-list", cl::init(""), cl::Hidden, cl::desc("Specify file to retrieve the list of functions to apply CHR to"))
static cl::opt< unsigned > CHRDupThreshsold ("chr-dup-threshold", cl::init(3), cl::Hidden, cl::desc("Max number of duplications by CHR for a region"))
static StringSet CHRModules
static StringSet CHRFunctions

CHR_DEBUG

DEBUG_TYPE

assertBranchOrSelectConditionHoisted()

assertCHRRegionsHaveBiasedBranchOrSelect()

checkBias()

template<typename K , typename S , typename M >

checkBiasedBranch()

checkBiasedSelect()

checkHoistValue()

Definition at line 525 of file ControlHeightReduction.cpp.

References assert(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::begin(), checkHoistValue(), CHR_DEBUG, llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::count(), llvm::dbgs(), llvm::DominatorTree::dominates(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::end(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::end(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::find(), llvm::DominatorTreeBase< NodeT, IsPostDom >::getNode(), llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(), I, llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::insert(), and isHoistable().

Referenced by checkHoistValue(), and shouldSplit().

CHRScopeSorter()

static bool CHRScopeSorter ( CHRScope * Scope1, CHRScope * Scope2 ) static

dumpIR()

dumpScopes()

extractBranchProbabilities()

getBaseValues()

getBranchInsertPoint()

getCHRBiasThreshold()

getCHRConditionValuesForRegion()

getSelectsInScope()

hasAtLeastTwoBiasedBranches()

static bool hasAtLeastTwoBiasedBranches ( CHRScope * Scope) static

hoistScopeConditions()

hoistValue()

Definition at line 1431 of file ControlHeightReduction.cpp.

References assert(), CHR_DEBUG, llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::count(), llvm::dbgs(), llvm::DominatorTree::dominates(), llvm::DominatorTreeBase< NodeT, IsPostDom >::getNode(), llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(), hoistValue(), I, llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::insert(), isHoistableInstructionType(), and IT.

Referenced by hoistScopeConditions(), and hoistValue().

insertTrivialPHIs()

Definition at line 1554 of file ControlHeightReduction.cpp.

References llvm::PHINode::addIncoming(), llvm::BasicBlock::begin(), CHR_DEBUG, llvm::SetVector< T, Vector, Set, N >::contains(), llvm::PHINode::Create(), llvm::dbgs(), I, llvm::SetVector< T, Vector, Set, N >::insert(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::insert(), llvm::Instruction::insertBefore(), llvm::pred_size(), llvm::predecessors(), and Users.

isHoistable()

isHoistableInstructionType()

negateICmpIfUsedByBranchOrSelectOnly()

static bool negateICmpIfUsedByBranchOrSelectOnly ( ICmpInst * ICmp, Instruction * ExcludedUser, CHRScope * Scope ) static

operator<<() [1/2]

operator<<() [2/2]

parseCHRFilterFiles()

static void parseCHRFilterFiles ( ) static

shouldApply()

shouldSplit()

CHRBiasThreshold

cl::opt< double > CHRBiasThreshold("chr-bias-threshold", cl::init(0.99), cl::Hidden, cl::desc("CHR considers a branch bias greater than this ratio as biased")) ( "chr-bias-threshold" , cl::init(0.99) , cl::Hidden , cl::desc("CHR considers a branch bias greater than this ratio as biased") ) static

CHRDupThreshsold

cl::opt< unsigned > CHRDupThreshsold("chr-dup-threshold", cl::init(3), cl::Hidden, cl::desc("Max number of duplications by CHR for a region")) ( "chr-dup-threshold" , cl::init(3) , cl::Hidden , cl::desc("Max number of duplications by CHR for a region") ) static

CHRFunctionList

CHRFunctions

CHRMergeThreshold

CHRModuleList

cl::opt< std::string > CHRModuleList("chr-module-list", cl::init(""), cl::Hidden, cl::desc("Specify file to retrieve the list of modules to apply CHR to")) ( "chr-module-list" , cl::init("") , cl::Hidden , cl::desc("Specify file to retrieve the list of modules to apply CHR to") ) static

CHRModules

DisableCHR

cl::opt< bool > DisableCHR("disable-chr", cl::init(false), cl::Hidden, cl::desc("Disable CHR for all functions")) ( "disable-chr" , cl::init(false) , cl::Hidden , cl::desc("Disable CHR for all functions") ) static

ForceCHR

cl::opt< bool > ForceCHR("force-chr", cl::init(false), cl::Hidden, cl::desc("Apply CHR for all functions")) ( "force-chr" , cl::init(false) , cl::Hidden , cl::desc("Apply CHR for all functions") ) static