[llvm-branch-commits] [clang] [llvm] [UBSan] Use -fsanitize-handler-preserve-all-regs in codegen (PR #168645)
Florian Mayer via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Nov 20 10:51:59 PST 2025
https://github.com/fmayer updated https://github.com/llvm/llvm-project/pull/168645
>From 54f9084ddba1711dd20ff231605e7418cf4f19cf Mon Sep 17 00:00:00 2001
From: Florian Mayer <fmayer at google.com>
Date: Tue, 18 Nov 2025 17:39:33 -0800
Subject: [PATCH 1/3] fmt
Created using spr 1.3.7
---
clang/lib/CodeGen/BackendUtil.cpp | 4 ++--
llvm/include/llvm/Transforms/Instrumentation/BoundsChecking.h | 3 ++-
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp
index a243b2e222716..13854c6c0e40c 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -1134,8 +1134,8 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
CodeGenOpts.SanitizeMinimalRuntime),
/*MayReturn=*/
CodeGenOpts.SanitizeRecover.has(SanitizerKind::LocalBounds),
- /*PreserveRt=*/static_cast<bool>(
- CodeGenOpts.SanitizePreserveRuntime),
+ /*PreserveRt=*/
+ static_cast<bool>(CodeGenOpts.SanitizePreserveRuntime),
};
}
FPM.addPass(BoundsCheckingPass(Options));
diff --git a/llvm/include/llvm/Transforms/Instrumentation/BoundsChecking.h b/llvm/include/llvm/Transforms/Instrumentation/BoundsChecking.h
index 2f5aacf2825f6..1c6fef1ad0636 100644
--- a/llvm/include/llvm/Transforms/Instrumentation/BoundsChecking.h
+++ b/llvm/include/llvm/Transforms/Instrumentation/BoundsChecking.h
@@ -24,7 +24,8 @@ class BoundsCheckingPass : public PassInfoMixin<BoundsCheckingPass> {
struct Options {
struct Runtime {
Runtime(bool MinRuntime, bool MayReturn, bool PreserveRt)
- : MinRuntime(MinRuntime), MayReturn(MayReturn), PreserveRt(PreserveRt) {}
+ : MinRuntime(MinRuntime), MayReturn(MayReturn),
+ PreserveRt(PreserveRt) {}
bool MinRuntime;
bool MayReturn;
bool PreserveRt;
>From 00416604198c859d5a8d6021cde08a7385174d35 Mon Sep 17 00:00:00 2001
From: Florian Mayer <fmayer at google.com>
Date: Thu, 20 Nov 2025 10:50:59 -0800
Subject: [PATCH 2/3] undo stray change
Created using spr 1.3.7
---
llvm/lib/Transforms/Instrumentation/BoundsChecking.cpp | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/llvm/lib/Transforms/Instrumentation/BoundsChecking.cpp b/llvm/lib/Transforms/Instrumentation/BoundsChecking.cpp
index 9ccefa99fb180..f3b2ae44fee76 100644
--- a/llvm/lib/Transforms/Instrumentation/BoundsChecking.cpp
+++ b/llvm/lib/Transforms/Instrumentation/BoundsChecking.cpp
@@ -174,9 +174,8 @@ static void insertBoundsCheck(Value *Or, BuilderTy &IRB, GetTrapBBT GetTrapBB) {
static std::string
getRuntimeCallName(const BoundsCheckingPass::Options::Runtime &Opts) {
std::string Name = "__ubsan_handle_local_out_of_bounds";
- if (Opts.MinRuntime) {
+ if (Opts.MinRuntime)
Name += "_minimal";
- }
if (!Opts.MayReturn)
Name += "_abort";
if (Opts.HandlerPreserveAllRegs && Opts.MinRuntime)
>From bd003aa85381ca88bde960469b61792e8238ba2c Mon Sep 17 00:00:00 2001
From: Florian Mayer <fmayer at google.com>
Date: Thu, 20 Nov 2025 10:51:42 -0800
Subject: [PATCH 3/3] correct logic
Created using spr 1.3.7
---
llvm/lib/Transforms/Instrumentation/BoundsChecking.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/llvm/lib/Transforms/Instrumentation/BoundsChecking.cpp b/llvm/lib/Transforms/Instrumentation/BoundsChecking.cpp
index f3b2ae44fee76..ae2760b0b69ad 100644
--- a/llvm/lib/Transforms/Instrumentation/BoundsChecking.cpp
+++ b/llvm/lib/Transforms/Instrumentation/BoundsChecking.cpp
@@ -178,7 +178,7 @@ getRuntimeCallName(const BoundsCheckingPass::Options::Runtime &Opts) {
Name += "_minimal";
if (!Opts.MayReturn)
Name += "_abort";
- if (Opts.HandlerPreserveAllRegs && Opts.MinRuntime)
+ else if (Opts.HandlerPreserveAllRegs && Opts.MinRuntime)
Name += "_preserve";
return Name;
}
More information about the llvm-branch-commits
mailing list