aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/BackendUtil.cpp
diff options
context:
space:
mode:
authorVitaly Buka <vitalybuka@google.com>2025-01-13 09:55:44 -0800
committerGitHub <noreply@github.com>2025-01-13 09:55:44 -0800
commit409ca49feb6659e279358f77b393f7955fb1bbda (patch)
treec20a0fedc880e656281ecd9c8c648b69bbcfa10c /clang/lib/CodeGen/BackendUtil.cpp
parent2d2fc4eb6820dfaebb5225c9f5c7275d0f1d0e86 (diff)
downloadllvm-409ca49feb6659e279358f77b393f7955fb1bbda.zip
llvm-409ca49feb6659e279358f77b393f7955fb1bbda.tar.gz
llvm-409ca49feb6659e279358f77b393f7955fb1bbda.tar.bz2
[ubsan] Pass fsanitize-skip-hot-cutoff into -fsanitize=bounds (#122576)
Diffstat (limited to 'clang/lib/CodeGen/BackendUtil.cpp')
-rw-r--r--clang/lib/CodeGen/BackendUtil.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp
index bcf6db1..79e6bf3 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -85,6 +85,7 @@
#include "llvm/Transforms/Scalar/JumpThreading.h"
#include "llvm/Transforms/Utils/Debugify.h"
#include "llvm/Transforms/Utils/ModuleUtils.h"
+#include <limits>
#include <memory>
#include <optional>
using namespace clang;
@@ -119,6 +120,9 @@ static cl::opt<PGOOptions::ColdFuncOpt> ClPGOColdFuncAttr(
extern cl::opt<InstrProfCorrelator::ProfCorrelatorKind> ProfileCorrelate;
} // namespace llvm
+namespace clang {
+extern llvm::cl::opt<bool> ClSanitizeGuardChecks;
+}
namespace {
@@ -1023,6 +1027,14 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
PB.registerScalarOptimizerLateEPCallback([this](FunctionPassManager &FPM,
OptimizationLevel Level) {
BoundsCheckingPass::Options Options;
+ if (CodeGenOpts.SanitizeSkipHotCutoffs[SanitizerKind::SO_LocalBounds] ||
+ ClSanitizeGuardChecks) {
+ static_assert(SanitizerKind::SO_LocalBounds <=
+ std::numeric_limits<
+ decltype(Options.GuardKind)::value_type>::max(),
+ "Update type of llvm.allow.ubsan.check.");
+ Options.GuardKind = SanitizerKind::SO_LocalBounds;
+ }
Options.Merge =
CodeGenOpts.SanitizeMergeHandlers.has(SanitizerKind::LocalBounds);
if (!CodeGenOpts.SanitizeTrap.has(SanitizerKind::LocalBounds)) {