29#define DEBUG_TYPE "lower-allow-check"
33 cl::desc(
"Hot percentile cuttoff."));
37 cl::desc(
"Probability value in the range [0.0, 1.0] of "
38 "unconditional pseudo-random checks."));
41STATISTIC(NumChecksRemoved,
"Number of removed checks");
48 :
Kind(
"Kind",
II->getArgOperand(0)),
59 <<
"Removed check: Kind=" <<
Info.Kind <<
" F=" <<
Info.F
66 <<
"Allowed check: Kind=" <<
Info.Kind <<
" F=" <<
Info.F
76 std::unique_ptr<RandomNumberGenerator> Rng;
80 Rng =
F.getParent()->createRNG(
F.getName());
84 auto ShouldRemoveHot = [&](
const BasicBlock &BB) {
90 auto ShouldRemoveRandom = [&]() {
92 !std::bernoulli_distribution(
RandomRate)(GetRng());
95 auto ShouldRemove = [&](
const BasicBlock &BB) {
96 return ShouldRemoveRandom() || ShouldRemoveHot(BB);
104 auto ID =
II->getIntrinsicID();
106 case Intrinsic::allow_ubsan_check:
107 case Intrinsic::allow_runtime_check: {
126 for (
auto [
I, V] : ReplaceWithValue) {
128 I->eraseFromParent();
131 return !ReplaceWithValue.
empty();
136 if (
F.isDeclaration())
ReachingDefAnalysis InstSet & ToRemove
static const Function * getParent(const Value *V)
Analysis containing CSE Info
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Module.h This file contains the declarations for the Module class.
static bool removeUbsanTraps(Function &F, const BlockFrequencyInfo &BFI, const ProfileSummaryInfo *PSI, OptimizationRemarkEmitter &ORE)
static cl::opt< int > HotPercentileCutoff("lower-allow-check-percentile-cutoff-hot", cl::desc("Hot percentile cuttoff."))
static cl::opt< float > RandomRate("lower-allow-check-random-rate", cl::desc("Probability value in the range [0.0, 1.0] of " "unconditional pseudo-random checks."))
static void emitRemark(IntrinsicInst *II, OptimizationRemarkEmitter &ORE, bool Removed)
This file provides the interface for the pass responsible for removing expensive ubsan checks.
uint64_t IntrinsicInst * II
static StringRef getName(Value *V)
This file defines the SmallVector class.
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
A container for analyses that lazily runs them and caches their results.
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
LLVM Basic Block Representation.
Analysis pass which computes BlockFrequencyInfo.
BlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate IR basic block frequen...
static ConstantInt * getBool(LLVMContext &Context, bool V)
A wrapper class for inspecting calls to intrinsic functions.
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
static bool IsRequested()
An analysis over an "inner" IR unit that provides access to an analysis manager over a "outer" IR uni...
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses none()
Convenience factory function for the empty preserved set.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
An analysis pass based on the new PM to deliver ProfileSummaryInfo.
Analysis providing profile information.
bool isHotCountNthPercentile(int PercentileCutoff, uint64_t C) const
Returns true if count C is considered hot with regard to a given hot percentile cutoff value.
A random number generator.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
This is an optimization pass for GlobalISel generic memory operations.
Used in the streaming interface as the general argument type.