30#define DEBUG_TYPE "lower-allow-check"
34 cl::desc(
"Hot percentile cuttoff."));
38 cl::desc(
"Probability value in the range [0.0, 1.0] of "
39 "unconditional pseudo-random checks."));
42STATISTIC(NumChecksRemoved,
"Number of removed checks");
49 :
Kind(
"Kind",
II->getArgOperand(0)),
60 <<
"Removed check: Kind=" <<
Info.Kind <<
" F=" <<
Info.F
67 <<
"Allowed check: Kind=" <<
Info.Kind <<
" F=" <<
Info.F
77 std::unique_ptr<RandomNumberGenerator> Rng;
81 Rng =
F.getParent()->createRNG(
F.getName());
85 auto ShouldRemoveHot = [&](
const BasicBlock &BB) {
91 auto ShouldRemoveRandom = [&]() {
93 !std::bernoulli_distribution(
RandomRate)(GetRng());
96 auto ShouldRemove = [&](
const BasicBlock &BB) {
97 return ShouldRemoveRandom() || ShouldRemoveHot(BB);
105 auto ID =
II->getIntrinsicID();
107 case Intrinsic::allow_ubsan_check:
108 case Intrinsic::allow_runtime_check: {
127 for (
auto [
I, V] : ReplaceWithValue) {
129 I->eraseFromParent();
132 return !ReplaceWithValue.
empty();
137 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...
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.
Module.h This file contains the declarations for the Module class.
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.