LLVM  9.0.0svn
Macros | Functions | Variables
GuardWidening.cpp File Reference
#include "llvm/Transforms/Scalar/GuardWidening.h"
#include <functional>
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/DepthFirstIterator.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/BranchProbabilityInfo.h"
#include "llvm/Analysis/GuardUtils.h"
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Analysis/LoopPass.h"
#include "llvm/Analysis/PostDominators.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/IR/ConstantRange.h"
#include "llvm/IR/Dominators.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/PatternMatch.h"
#include "llvm/Pass.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/KnownBits.h"
#include "llvm/Transforms/Scalar.h"
#include "llvm/Transforms/Utils/LoopUtils.h"
Include dependency graph for GuardWidening.cpp:

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "guard-widening"
 

Functions

 STATISTIC (GuardsEliminated, "Number of eliminated guards")
 
 STATISTIC (CondBranchEliminated, "Number of eliminated conditional branches")
 
static bool isSupportedGuardInstruction (const Instruction *Insn)
 
 INITIALIZE_PASS_BEGIN (GuardWideningLegacyPass, "guard-widening", "Widen guards", false, false) if(WidenFrequentBranches) INITIALIZE_PASS_END(GuardWideningLegacyPass
 
guard Widen false INITIALIZE_PASS_BEGIN (LoopGuardWideningLegacyPass, "loop-guard-widening", "Widen guards (within a single loop, as a loop pass)", false, false) if(WidenFrequentBranches) INITIALIZE_PASS_END(LoopGuardWideningLegacyPass
 
guard Widen false loop guard Widen guards (within a single loop, as a loop pass)"
 

Variables

static cl::opt< boolWidenFrequentBranches ("guard-widening-widen-frequent-branches", cl::Hidden, cl::desc("Widen conditions of explicit branches into dominating guards in " "case if their taken frequency exceeds threshold set by " "guard-widening-frequent-branch-threshold option"), cl::init(false))
 
static cl::opt< unsignedFrequentBranchThreshold ("guard-widening-frequent-branch-threshold", cl::Hidden, cl::desc("When WidenFrequentBranches is set to true, this option is used " "to determine which branches are frequently taken. The criteria " "that a branch is taken more often than " "((FrequentBranchThreshold - 1) / FrequentBranchThreshold), then " "it is considered frequently taken"), cl::init(1000))
 
static cl::opt< boolWidenBranchGuards ("guard-widening-widen-branch-guards", cl::Hidden, cl::desc("Whether or not we should widen guards " "expressed as branches by widenable conditions"), cl::init(true))
 
guard widening
 
guard Widen guards
 
guard Widen false
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "guard-widening"

Definition at line 64 of file GuardWidening.cpp.

Function Documentation

◆ guards()

guard Widen false loop guard Widen guards ( within a single  loop,
as a loop  pass 
)

◆ INITIALIZE_PASS_BEGIN() [1/2]

INITIALIZE_PASS_BEGIN ( GuardWideningLegacyPass  ,
"guard-widening ,
"Widen guards ,
false  ,
false   
)

◆ INITIALIZE_PASS_BEGIN() [2/2]

guard Widen false INITIALIZE_PASS_BEGIN ( LoopGuardWideningLegacyPass  ,
"loop-guard-widening ,
"Widen guards (within a single loop, as a loop pass)"  ,
false  ,
false   
)

◆ isSupportedGuardInstruction()

static bool isSupportedGuardInstruction ( const Instruction Insn)
static

Definition at line 301 of file GuardWidening.cpp.

References llvm::all_of(), assert(), llvm::SmallVectorTemplateCommon< T >::back(), llvm::SmallVectorTemplateCommon< T >::begin(), Check(), llvm::computeKnownBits(), llvm::LoopBase< BlockT, LoopT >::contains(), llvm::copy_if(), llvm::detail::DenseSetImpl< ValueT, DenseMap< ValueT, detail::DenseSetEmpty, ValueInfoT, detail::DenseSetPair< ValueT > >, ValueInfoT >::count(), llvm::SmallPtrSetImpl< PtrType >::count(), llvm::BinaryOperator::CreateNot(), llvm::dbgs(), llvm::df_begin(), llvm::df_end(), llvm::DominatorTree::dominates(), llvm::DominatorTreeBase< NodeT, IsPostDom >::dominates(), llvm::dyn_cast(), E, llvm::SmallVectorImpl< T >::emplace_back(), llvm::SmallVectorBase::empty(), llvm::SmallVectorTemplateCommon< T >::end(), llvm::SmallVectorImpl< T >::erase(), llvm::find(), FrequentBranchThreshold, llvm::SmallVectorTemplateCommon< T >::front(), llvm::ConstantInt::get(), llvm::APInt::getBitWidth(), llvm::Value::getContext(), llvm::BranchProbabilityInfo::getEdgeProbability(), llvm::ConstantInt::getFalse(), llvm::CmpInst::getInversePredicate(), llvm::LoopInfoBase< BlockT, LoopT >::getLoopFor(), llvm::Constant::getNullValue(), llvm::Instruction::getParent(), llvm::df_iterator< GraphT, SetType, ExtStorage, GT >::getPath(), llvm::df_iterator< GraphT, SetType, ExtStorage, GT >::getPathLength(), llvm::APInt::getSignedMinValue(), llvm::ConstantInt::getTrue(), llvm::ConstantInt::getValue(), llvm::CmpInst::ICMP_UGT, llvm::CmpInst::ICMP_ULT, llvm::detail::DenseSetImpl< ValueT, DenseMap< ValueT, detail::DenseSetEmpty, ValueInfoT, detail::DenseSetPair< ValueT > >, ValueInfoT >::insert(), llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::SmallVectorImpl< T >::insert(), llvm::ConstantRange::intersectWith(), llvm::ConstantRange::inverse(), llvm::isGuard(), llvm::isGuardAsWidenableBranch(), llvm::isKnownNonNegative(), llvm::APInt::isMinValue(), llvm::DominatorTree::isReachableFromEntry(), llvm::isSafeToSpeculativelyExecute(), LLVM_DEBUG, llvm_unreachable, llvm::PatternMatch::m_Add(), llvm::PatternMatch::m_And(), llvm::PatternMatch::m_ConstantInt(), llvm::PatternMatch::m_ICmp(), llvm::PatternMatch::m_Or(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Value(), llvm::make_range(), llvm::ConstantRange::makeExactICmpRegion(), llvm::PatternMatch::match(), llvm::None, llvm::SmallVectorTemplateBase< T >::push_back(), llvm::remove_if(), llvm::Value::setName(), llvm::SmallVectorBase::size(), llvm::sort(), std::swap(), Threshold, llvm::ConstantRange::unionWith(), WidenBranchGuards, WidenFrequentBranches, and llvm::KnownBits::Zero.

◆ STATISTIC() [1/2]

STATISTIC ( GuardsEliminated  ,
"Number of eliminated guards  
)

◆ STATISTIC() [2/2]

STATISTIC ( CondBranchEliminated  ,
"Number of eliminated conditional branches  
)

Variable Documentation

◆ false

guard Widen false loop guard Widen false

Definition at line 900 of file GuardWidening.cpp.

◆ FrequentBranchThreshold

cl::opt<unsigned> FrequentBranchThreshold("guard-widening-frequent-branch-threshold", cl::Hidden, cl::desc("When WidenFrequentBranches is set to true, this option is used " "to determine which branches are frequently taken. The criteria " "that a branch is taken more often than " "((FrequentBranchThreshold - 1) / FrequentBranchThreshold), then " "it is considered frequently taken"), cl::init(1000))
static

◆ guards

guard Widen guards

Definition at line 900 of file GuardWidening.cpp.

◆ WidenBranchGuards

cl::opt<bool> WidenBranchGuards("guard-widening-widen-branch-guards", cl::Hidden, cl::desc("Whether or not we should widen guards " "expressed as branches by widenable conditions"), cl::init(true))
static

◆ WidenFrequentBranches

cl::opt<bool> WidenFrequentBranches("guard-widening-widen-frequent-branches", cl::Hidden, cl::desc("Widen conditions of explicit branches into dominating guards in " "case if their taken frequency exceeds threshold set by " "guard-widening-frequent-branch-threshold option"), cl::init(false))
static

◆ widening

guard Widen false loop guard widening

Definition at line 900 of file GuardWidening.cpp.