aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/BackendUtil.cpp
diff options
context:
space:
mode:
authorThurston Dang <thurston@google.com>2025-01-30 09:37:16 -0800
committerGitHub <noreply@github.com>2025-01-30 09:37:16 -0800
commit9c0606a08b7e81df59afa3894830cb5c374f99ac (patch)
tree2bac01286cf88dcc3d38a3440fc385d1c9726266 /clang/lib/CodeGen/BackendUtil.cpp
parent2f48ca3aec4aa81b81d8591773bf29b4c72c623f (diff)
downloadllvm-9c0606a08b7e81df59afa3894830cb5c374f99ac.zip
llvm-9c0606a08b7e81df59afa3894830cb5c374f99ac.tar.gz
llvm-9c0606a08b7e81df59afa3894830cb5c374f99ac.tar.bz2
Reapply "[ubsan] Connect -fsanitize-skip-hot-cutoff to LowerAllowCheckPass<cutoffs>" (#125032) (#125037)
This reverts commit 928cad49beec0120686478f502899222e836b545 i.e., relands dccd27112722109d2e2f03e8da9ce8690f06e11b, with a fix to avoid use-after-scope by changing the lambda to capture by value.
Diffstat (limited to 'clang/lib/CodeGen/BackendUtil.cpp')
-rw-r--r--clang/lib/CodeGen/BackendUtil.cpp23
1 files changed, 16 insertions, 7 deletions
diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp
index 3e65eeb..97e9bbc 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -795,14 +795,23 @@ static void addSanitizers(const Triple &TargetTriple,
PB.registerOptimizerLastEPCallback(SanitizersCallback);
}
- if (LowerAllowCheckPass::IsRequested()) {
+ // SanitizeSkipHotCutoffs: doubles with range [0, 1]
+ // Opts.cutoffs: unsigned ints with range [0, 1000000]
+ auto ScaledCutoffs = CodeGenOpts.SanitizeSkipHotCutoffs.getAllScaled(1000000);
+
+ // TODO: remove IsRequested()
+ if (LowerAllowCheckPass::IsRequested() || ScaledCutoffs.has_value()) {
// We want to call it after inline, which is about OptimizerEarlyEPCallback.
- PB.registerOptimizerEarlyEPCallback([&](ModulePassManager &MPM,
- OptimizationLevel Level,
- ThinOrFullLTOPhase Phase) {
- LowerAllowCheckPass::Options Opts;
- MPM.addPass(createModuleToFunctionPassAdaptor(LowerAllowCheckPass(Opts)));
- });
+ PB.registerOptimizerEarlyEPCallback(
+ [ScaledCutoffs](ModulePassManager &MPM, OptimizationLevel Level,
+ ThinOrFullLTOPhase Phase) {
+ LowerAllowCheckPass::Options Opts;
+ // TODO: after removing IsRequested(), make this unconditional
+ if (ScaledCutoffs.has_value())
+ Opts.cutoffs = ScaledCutoffs.value();
+ MPM.addPass(
+ createModuleToFunctionPassAdaptor(LowerAllowCheckPass(Opts)));
+ });
}
}