#include "llvm/Transforms/Instrumentation/LowerAllowCheckPass.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Analysis/OptimizationRemarkEmitter.h"
#include "llvm/Analysis/ProfileSummaryInfo.h"
#include "llvm/IR/Constant.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DiagnosticInfo.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/Metadata.h"
#include "llvm/IR/Module.h"
#include "llvm/Support/RandomNumberGenerator.h"
#include <memory>
#include <random>
usingnamespacellvm;
#define DEBUG_TYPE …
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."));
STATISTIC(NumChecksTotal, "Number of checks");
STATISTIC(NumChecksRemoved, "Number of removed checks");
struct RemarkInfo { … };
static void emitRemark(IntrinsicInst *II, OptimizationRemarkEmitter &ORE,
bool Removed) { … }
static bool removeUbsanTraps(Function &F, const BlockFrequencyInfo &BFI,
const ProfileSummaryInfo *PSI,
OptimizationRemarkEmitter &ORE) { … }
PreservedAnalyses LowerAllowCheckPass::run(Function &F,
FunctionAnalysisManager &AM) { … }
bool LowerAllowCheckPass::IsRequested() { … }