LLVM 24.0.0git
ControlHeightReduction.cpp File Reference

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "chr"
#define CHR_DEBUG(X)

Functions

static void parseCHRFilterFiles ()
static raw_ostream & operator<< (raw_ostream &OS, const CHRStats &Stats)
static raw_ostream & operator<< (raw_ostream &OS, const CHRScope &Scope)
static bool shouldApply (const InstrumentationOptions &Opts, Function &F, ProfileSummaryInfo &PSI)
static void 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 (const InstrumentationOptions &Opts)
template<typename K, typename S, typename M>
static bool checkBias (const InstrumentationOptions &Opts, K *Key, BranchProbability TrueProb, BranchProbability FalseProb, S &TrueSet, S &FalseSet, M &BiasMap)
static bool checkBiasedBranch (const InstrumentationOptions &Opts, CondBrInst *BI, Region *R, DenseSet< Region * > &TrueBiasedRegionsGlobal, DenseSet< Region * > &FalseBiasedRegionsGlobal, DenseMap< Region *, BranchProbability > &BranchBiasMap)
static bool checkBiasedSelect (const InstrumentationOptions &Opts, 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 (const InstrumentationOptions &Opts, 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 assertCHRRegionsHaveBiasedBranchOrSelect (CHRScope *Scope)
static void assertBranchOrSelectConditionHoisted (CHRScope *Scope, BasicBlock *PreEntryBlock)
static void dumpScopes (SmallVectorImpl< CHRScope * > &Scopes, const char *Label)

Variables

static StringSet CHRModules
static StringSet CHRFunctions

Macro Definition Documentation

◆ CHR_DEBUG

#define CHR_DEBUG ( X)
Value:
#define X(NUM, ENUM, NAME)
Definition ELF.h:857
#define LLVM_DEBUG(...)
Definition Debug.h:119

Definition at line 49 of file ControlHeightReduction.cpp.

Referenced by assertBranchOrSelectConditionHoisted(), checkBiasedBranch(), checkBiasedSelect(), checkHoistValue(), dumpIR(), hoistValue(), insertTrivialPHIs(), and shouldSplit().

◆ DEBUG_TYPE

#define DEBUG_TYPE   "chr"

Definition at line 47 of file ControlHeightReduction.cpp.

Function Documentation

◆ assertBranchOrSelectConditionHoisted()

void assertBranchOrSelectConditionHoisted ( CHRScope * Scope,
BasicBlock * PreEntryBlock )
static

◆ assertCHRRegionsHaveBiasedBranchOrSelect()

void assertCHRRegionsHaveBiasedBranchOrSelect ( CHRScope * Scope)
static

Definition at line 1615 of file ControlHeightReduction.cpp.

References assert().

◆ checkBias()

template<typename K, typename S, typename M>
bool checkBias ( const InstrumentationOptions & Opts,
K * Key,
BranchProbability TrueProb,
BranchProbability FalseProb,
S & TrueSet,
S & FalseSet,
M & BiasMap )
static

◆ checkBiasedBranch()

bool checkBiasedBranch ( const InstrumentationOptions & Opts,
CondBrInst * BI,
Region * R,
DenseSet< Region * > & TrueBiasedRegionsGlobal,
DenseSet< Region * > & FalseBiasedRegionsGlobal,
DenseMap< Region *, BranchProbability > & BranchBiasMap )
static

◆ checkBiasedSelect()

bool checkBiasedSelect ( const InstrumentationOptions & Opts,
SelectInst * SI,
Region * R,
DenseSet< SelectInst * > & TrueBiasedSelectsGlobal,
DenseSet< SelectInst * > & FalseBiasedSelectsGlobal,
DenseMap< SelectInst *, BranchProbability > & SelectBiasMap )
static

◆ checkHoistValue()

◆ CHRScopeSorter()

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

Definition at line 1400 of file ControlHeightReduction.cpp.

◆ dumpIR()

void dumpIR ( Function & F,
const char * Label,
CHRStats * Stats )
static

Definition at line 407 of file ControlHeightReduction.cpp.

References CHR_DEBUG, llvm::dbgs(), F, and Stats.

◆ dumpScopes()

void dumpScopes ( SmallVectorImpl< CHRScope * > & Scopes,
const char * Label )
static

Definition at line 2000 of file ControlHeightReduction.cpp.

References llvm::dbgs().

◆ extractBranchProbabilities()

bool extractBranchProbabilities ( Instruction * I,
BranchProbability & TrueProb,
BranchProbability & FalseProb )
static

◆ getBaseValues()

const std::set< Value * > & getBaseValues ( Value * V,
DominatorTree & DT,
DenseMap< Value *, std::set< Value * > > & Visited )
static

Definition at line 468 of file ControlHeightReduction.cpp.

References llvm::dyn_cast(), getBaseValues(), I, llvm::isa(), and isHoistable().

Referenced by getBaseValues(), and shouldSplit().

◆ getBranchInsertPoint()

◆ getCHRBiasThreshold()

BranchProbability getCHRBiasThreshold ( const InstrumentationOptions & Opts)
static

Definition at line 580 of file ControlHeightReduction.cpp.

References llvm::BranchProbability::getBranchProbability(), and uint64_t.

Referenced by checkBias().

◆ getCHRConditionValuesForRegion()

DenseSet< Value * > getCHRConditionValuesForRegion ( RegInfo & RI)
static

◆ getSelectsInScope()

void getSelectsInScope ( CHRScope * Scope,
DenseSet< Instruction * > & Output )
static

◆ hasAtLeastTwoBiasedBranches()

bool hasAtLeastTwoBiasedBranches ( const InstrumentationOptions & Opts,
CHRScope * Scope )
static

Definition at line 1298 of file ControlHeightReduction.cpp.

◆ hoistScopeConditions()

void hoistScopeConditions ( CHRScope * Scope,
Instruction * HoistPoint,
DenseSet< PHINode * > & TrivialPHIs,
DominatorTree & DT )
static

Definition at line 1461 of file ControlHeightReduction.cpp.

References llvm::cast(), and hoistValue().

◆ hoistValue()

◆ insertTrivialPHIs()

◆ isHoistable()

bool isHoistable ( Instruction * I,
DominatorTree & DT )
static

◆ isHoistableInstructionType()

bool isHoistableInstructionType ( Instruction * I)
static

Definition at line 447 of file ControlHeightReduction.cpp.

References I, and llvm::isa().

Referenced by hoistValue(), and isHoistable().

◆ negateICmpIfUsedByBranchOrSelectOnly()

◆ operator<<() [1/2]

raw_ostream & operator<< ( raw_ostream & OS,
const CHRScope & Scope )
inlinestatic

Definition at line 385 of file ControlHeightReduction.cpp.

◆ operator<<() [2/2]

raw_ostream & operator<< ( raw_ostream & OS,
const CHRStats & Stats )
inlinestatic

Definition at line 378 of file ControlHeightReduction.cpp.

References Stats.

◆ parseCHRFilterFiles()

◆ shouldApply()

bool shouldApply ( const InstrumentationOptions & Opts,
Function & F,
ProfileSummaryInfo & PSI )
static

◆ shouldSplit()

bool shouldSplit ( Instruction * InsertPoint,
DenseSet< Value * > & PrevConditionValues,
DenseSet< Value * > & ConditionValues,
DominatorTree & DT,
DenseSet< Instruction * > & Unhoistables )
static

Variable Documentation

◆ CHRFunctions

StringSet CHRFunctions
static

Definition at line 52 of file ControlHeightReduction.cpp.

Referenced by parseCHRFilterFiles(), and shouldApply().

◆ CHRModules

StringSet CHRModules
static

Definition at line 51 of file ControlHeightReduction.cpp.

Referenced by parseCHRFilterFiles(), and shouldApply().