LLVM 20.0.0git
|
#include "llvm/Transforms/Instrumentation/ControlHeightReduction.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringSet.h"
#include "llvm/Analysis/BlockFrequencyInfo.h"
#include "llvm/Analysis/GlobalsModRef.h"
#include "llvm/Analysis/OptimizationRemarkEmitter.h"
#include "llvm/Analysis/ProfileSummaryInfo.h"
#include "llvm/Analysis/RegionInfo.h"
#include "llvm/Analysis/RegionIterator.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/IR/CFG.h"
#include "llvm/IR/Dominators.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/MDBuilder.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/PassManager.h"
#include "llvm/IR/ProfDataUtils.h"
#include "llvm/Support/BranchProbability.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Transforms/Utils.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include "llvm/Transforms/Utils/Cloning.h"
#include "llvm/Transforms/Utils/ValueMapper.h"
#include <optional>
#include <set>
#include <sstream>
Go to the source code of this file.
Namespaces | |
namespace | llvm |
This is an optimization pass for GlobalISel generic memory operations. | |
Macros | |
#define | DEBUG_TYPE "chr" |
#define | CHR_DEBUG(X) LLVM_DEBUG(X) |
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 |
#define CHR_DEBUG | ( | X | ) | LLVM_DEBUG(X) |
Definition at line 50 of file ControlHeightReduction.cpp.
#define DEBUG_TYPE "chr" |
Definition at line 48 of file ControlHeightReduction.cpp.
|
static |
Definition at line 1639 of file ControlHeightReduction.cpp.
References assert(), CHR_DEBUG, llvm::dbgs(), and I.
|
static |
Definition at line 1618 of file ControlHeightReduction.cpp.
References assert().
|
static |
Definition at line 611 of file ControlHeightReduction.cpp.
References getCHRBiasThreshold().
Referenced by checkBiasedBranch(), and checkBiasedSelect().
|
static |
Definition at line 629 of file ControlHeightReduction.cpp.
References assert(), checkBias(), CHR_DEBUG, llvm::dbgs(), extractBranchProbabilities(), llvm::BranchInst::getSuccessor(), llvm::BranchInst::isConditional(), and std::swap().
|
static |
Definition at line 659 of file ControlHeightReduction.cpp.
References checkBias(), CHR_DEBUG, llvm::dbgs(), and extractBranchProbabilities().
|
static |
Definition at line 526 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().
|
static |
Definition at line 1419 of file ControlHeightReduction.cpp.
|
static |
Definition at line 429 of file ControlHeightReduction.cpp.
References CHR_DEBUG, llvm::dbgs(), F, and Stats.
|
static |
Definition at line 1990 of file ControlHeightReduction.cpp.
References llvm::dbgs().
|
static |
Definition at line 580 of file ControlHeightReduction.cpp.
References assert(), llvm::extractBranchWeights(), llvm::BranchProbability::getBranchProbability(), and I.
Referenced by checkBiasedBranch(), and checkBiasedSelect().
|
static |
Definition at line 490 of file ControlHeightReduction.cpp.
References getBaseValues(), I, and isHoistable().
Referenced by getBaseValues(), and shouldSplit().
|
static |
Definition at line 678 of file ControlHeightReduction.cpp.
References assert(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::contains(), llvm::BasicBlock::getTerminator(), I, and llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::insert().
|
static |
Definition at line 601 of file ControlHeightReduction.cpp.
References CHRBiasThreshold, and llvm::BranchProbability::getBranchProbability().
Referenced by checkBias().
Definition at line 1024 of file ControlHeightReduction.cpp.
References llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::insert().
|
static |
Definition at line 1105 of file ControlHeightReduction.cpp.
References getSelectsInScope(), and llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::insert().
Referenced by getSelectsInScope().
|
static |
Definition at line 1314 of file ControlHeightReduction.cpp.
References CHRMergeThreshold.
|
static |
Definition at line 1480 of file ControlHeightReduction.cpp.
References hoistValue().
|
static |
Definition at line 1432 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().
|
static |
Definition at line 1555 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.
|
static |
Definition at line 478 of file ControlHeightReduction.cpp.
References I, isHoistableInstructionType(), and llvm::isSafeToSpeculativelyExecute().
Referenced by checkHoistValue(), and getBaseValues().
|
static |
Definition at line 469 of file ControlHeightReduction.cpp.
References I.
Referenced by hoistValue(), and isHoistable().
|
static |
Definition at line 1506 of file ControlHeightReduction.cpp.
References assert(), llvm::CmpInst::getInversePredicate(), llvm::CmpInst::getPredicate(), llvm_unreachable, llvm::CmpInst::setPredicate(), and llvm::Value::users().
|
inlinestatic |
Definition at line 408 of file ControlHeightReduction.cpp.
References OS.
|
inlinestatic |
Definition at line 401 of file ControlHeightReduction.cpp.
|
static |
Definition at line 81 of file ControlHeightReduction.cpp.
References CHRFunctionList, CHRFunctions, CHRModuleList, CHRModules, llvm::errs(), llvm::MemoryBuffer::getFile(), llvm::StringSet< AllocatorTy >::insert(), and llvm::StringRef::split().
Referenced by llvm::ControlHeightReductionPass::ControlHeightReductionPass().
|
static |
Definition at line 413 of file ControlHeightReduction.cpp.
References CHRFunctionList, CHRFunctions, CHRModuleList, CHRModules, llvm::StringMap< ValueTy, AllocatorTy >::count(), DisableCHR, F, ForceCHR, and llvm::ProfileSummaryInfo::isFunctionEntryHot().
|
static |
Definition at line 1043 of file ControlHeightReduction.cpp.
References assert(), checkHoistValue(), CHR_DEBUG, llvm::dbgs(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::empty(), and getBaseValues().
|
static |
Referenced by getCHRBiasThreshold().
|
static |
|
static |
Referenced by parseCHRFilterFiles(), and shouldApply().
|
static |
Definition at line 79 of file ControlHeightReduction.cpp.
Referenced by parseCHRFilterFiles(), and shouldApply().
|
static |
Referenced by hasAtLeastTwoBiasedBranches().
|
static |
Referenced by parseCHRFilterFiles(), and shouldApply().
|
static |
Definition at line 78 of file ControlHeightReduction.cpp.
Referenced by parseCHRFilterFiles(), and shouldApply().
|
static |
Referenced by shouldApply().