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;
78 auto ShouldRemove = [&](
bool IsHot) {
82 Rng =
F.getParent()->createRNG(
F.getName());
94 case Intrinsic::allow_ubsan_check:
95 case Intrinsic::allow_runtime_check: {
100 uint64_t Count = BFI.getBlockProfileCount(&BB).value_or(0);
104 bool ToRemove = ShouldRemove(IsHot);
120 for (
auto [
I, V] : ReplaceWithValue) {
122 I->eraseFromParent();
125 return !ReplaceWithValue.
empty();
130 if (
F.isDeclaration())
ReachingDefAnalysis InstSet & ToRemove
static const Function * getParent(const Value *V)
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
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.
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.
Intrinsic::ID getIntrinsicID() const
Return the intrinsic ID of this intrinsic.
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.
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.