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 <[email protected]> Date: Tue, 18 Nov 2025 17:39:33 -0800 Subject: [PATCH 1/6] 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 <[email protected]> Date: Thu, 20 Nov 2025 10:50:59 -0800 Subject: [PATCH 2/6] 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 <[email protected]> Date: Thu, 20 Nov 2025 10:51:42 -0800 Subject: [PATCH 3/6] 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; } >From a8be55d9b0abded6a66e8b707388a806a6d11295 Mon Sep 17 00:00:00 2001 From: Florian Mayer <[email protected]> Date: Thu, 20 Nov 2025 15:09:05 -0800 Subject: [PATCH 4/6] fix abort case Created using spr 1.3.7 --- clang/lib/CodeGen/CGExpr.cpp | 9 +++-- .../CodeGen/cfi-icall-trap-recover-runtime.c | 35 +++++++++++++++++++ .../cfi-vcall-trap-recover-runtime.cpp | 25 +++++++++++++ 3 files changed, 66 insertions(+), 3 deletions(-) diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index 6e726ed42cede..261c7a851f6b1 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -3791,6 +3791,7 @@ static void emitCheckHandlerCall(CodeGenFunction &CGF, bool MinimalRuntime = CGF.CGM.getCodeGenOpts().SanitizeMinimalRuntime; bool HandlerPreserveAllRegs = CGF.CGM.getCodeGenOpts().SanitizeHandlerPreserveAllRegs; + bool UsePreserveFn = false; const SanitizerHandlerInfo &CheckInfo = SanitizerHandlers[CheckHandler]; const StringRef CheckName = CheckInfo.Name; std::string FnName = "__ubsan_handle_" + CheckName.str(); @@ -3798,10 +3799,12 @@ static void emitCheckHandlerCall(CodeGenFunction &CGF, FnName += "_v" + llvm::utostr(CheckInfo.Version); if (MinimalRuntime) FnName += "_minimal"; - if (NeedsAbortSuffix) + if (NeedsAbortSuffix) { FnName += "_abort"; - else if (MinimalRuntime && HandlerPreserveAllRegs) + } else if (MinimalRuntime && HandlerPreserveAllRegs) { FnName += "_preserve"; + UsePreserveFn = true; + } bool MayReturn = !IsFatal || RecoverKind == CheckRecoverableKind::AlwaysRecoverable; @@ -3822,7 +3825,7 @@ static void emitCheckHandlerCall(CodeGenFunction &CGF, (CGF.CurCodeDecl && CGF.CurCodeDecl->hasAttr<OptimizeNoneAttr>()); if (NoMerge) HandlerCall->addFnAttr(llvm::Attribute::NoMerge); - if (MinimalRuntime && HandlerPreserveAllRegs) { + if (UsePreserveFn) { // N.B. there is also a clang::CallingConv which is not what we want here. HandlerCall->setCallingConv(llvm::CallingConv::PreserveAll); } diff --git a/clang/test/CodeGen/cfi-icall-trap-recover-runtime.c b/clang/test/CodeGen/cfi-icall-trap-recover-runtime.c index 146c904e2ca28..b916dc9def699 100644 --- a/clang/test/CodeGen/cfi-icall-trap-recover-runtime.c +++ b/clang/test/CodeGen/cfi-icall-trap-recover-runtime.c @@ -11,6 +11,8 @@ // RUN: %clang_cc1 -fsanitize=cfi-icall -fno-sanitize-trap=cfi-icall -fsanitize-recover=cfi-icall -fsanitize-minimal-runtime -fsanitize-handler-preserve-all-regs -flto -fvisibility=hidden -triple x86_64-unknown-linux -fwhole-program-vtables -emit-llvm -o - %s | FileCheck --check-prefix=PRESERVE_MIN %s +// RUN: %clang_cc1 -fsanitize=cfi-icall -fno-sanitize-trap=cfi-icall -fsanitize-minimal-runtime -fsanitize-handler-preserve-all-regs -flto -fvisibility=hidden -triple x86_64-unknown-linux -fwhole-program-vtables -emit-llvm -o - %s | FileCheck --check-prefix=PRESERVE_ABORT_MIN %s + // TRAP-LABEL: define hidden void @f( // TRAP-SAME: ) #[[ATTR0:[0-9]+]] !type [[META6:![0-9]+]] !type [[META7:![0-9]+]] { @@ -42,6 +44,11 @@ // PRESERVE_MIN-NEXT: [[ENTRY:.*:]] // PRESERVE_MIN-NEXT: ret void // +// PRESERVE_ABORT_MIN-LABEL: define hidden void @f( +// PRESERVE_ABORT_MIN-SAME: ) #[[ATTR0:[0-9]+]] !type [[META6:![0-9]+]] !type [[META7:![0-9]+]] { +// PRESERVE_ABORT_MIN-NEXT: [[ENTRY:.*:]] +// PRESERVE_ABORT_MIN-NEXT: ret void +// void f() { } @@ -175,6 +182,27 @@ void xf(); // PRESERVE_MIN-NEXT: call void (...) [[TMP2]]() // PRESERVE_MIN-NEXT: ret void // +// PRESERVE_ABORT_MIN-LABEL: define hidden void @g( +// PRESERVE_ABORT_MIN-SAME: i32 noundef [[B:%.*]]) #[[ATTR0]] !type [[META8:![0-9]+]] !type [[META9:![0-9]+]] { +// PRESERVE_ABORT_MIN-NEXT: [[ENTRY:.*:]] +// PRESERVE_ABORT_MIN-NEXT: [[B_ADDR:%.*]] = alloca i32, align 4 +// PRESERVE_ABORT_MIN-NEXT: [[FP:%.*]] = alloca ptr, align 8 +// PRESERVE_ABORT_MIN-NEXT: store i32 [[B]], ptr [[B_ADDR]], align 4 +// PRESERVE_ABORT_MIN-NEXT: [[TMP0:%.*]] = load i32, ptr [[B_ADDR]], align 4 +// PRESERVE_ABORT_MIN-NEXT: [[TOBOOL:%.*]] = icmp ne i32 [[TMP0]], 0 +// PRESERVE_ABORT_MIN-NEXT: [[TMP1:%.*]] = zext i1 [[TOBOOL]] to i64 +// PRESERVE_ABORT_MIN-NEXT: [[COND:%.*]] = select i1 [[TOBOOL]], ptr @f, ptr @xf +// PRESERVE_ABORT_MIN-NEXT: store ptr [[COND]], ptr [[FP]], align 8 +// PRESERVE_ABORT_MIN-NEXT: [[TMP2:%.*]] = load ptr, ptr [[FP]], align 8 +// PRESERVE_ABORT_MIN-NEXT: [[TMP3:%.*]] = call i1 @llvm.type.test(ptr [[TMP2]], metadata !"_ZTSFvE"), !nosanitize [[META10:![0-9]+]] +// PRESERVE_ABORT_MIN-NEXT: br i1 [[TMP3]], label %[[CONT:.*]], label %[[HANDLER_CFI_CHECK_FAIL:.*]], !prof [[PROF11:![0-9]+]], !nosanitize [[META10]] +// PRESERVE_ABORT_MIN: [[HANDLER_CFI_CHECK_FAIL]]: +// PRESERVE_ABORT_MIN-NEXT: call void @__ubsan_handle_cfi_check_fail_minimal_abort() #[[ATTR4:[0-9]+]], !nosanitize [[META10]] +// PRESERVE_ABORT_MIN-NEXT: unreachable, !nosanitize [[META10]] +// PRESERVE_ABORT_MIN: [[CONT]]: +// PRESERVE_ABORT_MIN-NEXT: call void (...) [[TMP2]]() +// PRESERVE_ABORT_MIN-NEXT: ret void +// void g(int b) { void (*fp)() = b ? f : xf; fp(); @@ -222,3 +250,10 @@ void g(int b) { // PRESERVE_MIN: [[META10]] = !{} // PRESERVE_MIN: [[PROF11]] = !{!"branch_weights", i32 1048575, i32 1} //. +// PRESERVE_ABORT_MIN: [[META6]] = !{i64 0, !"_ZTSFvE"} +// PRESERVE_ABORT_MIN: [[META7]] = !{i64 0, !"_ZTSFvE.generalized"} +// PRESERVE_ABORT_MIN: [[META8]] = !{i64 0, !"_ZTSFviE"} +// PRESERVE_ABORT_MIN: [[META9]] = !{i64 0, !"_ZTSFviE.generalized"} +// PRESERVE_ABORT_MIN: [[META10]] = !{} +// PRESERVE_ABORT_MIN: [[PROF11]] = !{!"branch_weights", i32 1048575, i32 1} +//. diff --git a/clang/test/CodeGenCXX/cfi-vcall-trap-recover-runtime.cpp b/clang/test/CodeGenCXX/cfi-vcall-trap-recover-runtime.cpp index a85f77493730d..6c3863ac484eb 100644 --- a/clang/test/CodeGenCXX/cfi-vcall-trap-recover-runtime.cpp +++ b/clang/test/CodeGenCXX/cfi-vcall-trap-recover-runtime.cpp @@ -11,6 +11,9 @@ // RUN: %clang_cc1 -fsanitize=cfi-vcall -fno-sanitize-trap=cfi-vcall -fsanitize-recover=cfi-vcall -fsanitize-minimal-runtime -flto -fvisibility=hidden -triple x86_64-unknown-linux -fwhole-program-vtables -fsanitize-handler-preserve-all-regs -emit-llvm -o - %s | FileCheck --check-prefix=PRESERVE_MIN %s +// RUN: %clang_cc1 -fsanitize=cfi-vcall -fno-sanitize-trap=cfi-vcall -fsanitize-minimal-runtime -flto -fvisibility=hidden -triple x86_64-unknown-linux -fwhole-program-vtables -fsanitize-handler-preserve-all-regs -emit-llvm -o - %s | FileCheck --check-prefix=PRESERVE_ABORT_MIN %s + + struct S1 { virtual void f(); }; @@ -132,6 +135,25 @@ struct S1 { // PRESERVE_MIN-NEXT: call void [[TMP3]](ptr noundef nonnull align 8 dereferenceable(8) [[TMP0]]) // PRESERVE_MIN-NEXT: ret void // +// PRESERVE_ABORT_MIN-LABEL: define hidden void @_Z3s1fP2S1( +// PRESERVE_ABORT_MIN-SAME: ptr noundef [[S1:%.*]]) #[[ATTR0:[0-9]+]] { +// PRESERVE_ABORT_MIN-NEXT: [[ENTRY:.*:]] +// PRESERVE_ABORT_MIN-NEXT: [[S1_ADDR:%.*]] = alloca ptr, align 8 +// PRESERVE_ABORT_MIN-NEXT: store ptr [[S1]], ptr [[S1_ADDR]], align 8 +// PRESERVE_ABORT_MIN-NEXT: [[TMP0:%.*]] = load ptr, ptr [[S1_ADDR]], align 8 +// PRESERVE_ABORT_MIN-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8 +// PRESERVE_ABORT_MIN-NEXT: [[TMP1:%.*]] = call i1 @llvm.type.test(ptr [[VTABLE]], metadata !"_ZTS2S1"), !nosanitize [[META5:![0-9]+]] +// PRESERVE_ABORT_MIN-NEXT: [[TMP2:%.*]] = call i1 @llvm.type.test(ptr [[VTABLE]], metadata !"all-vtables"), !nosanitize [[META5]] +// PRESERVE_ABORT_MIN-NEXT: br i1 [[TMP1]], label %[[CONT:.*]], label %[[HANDLER_CFI_CHECK_FAIL:.*]], !prof [[PROF6:![0-9]+]], !nosanitize [[META5]] +// PRESERVE_ABORT_MIN: [[HANDLER_CFI_CHECK_FAIL]]: +// PRESERVE_ABORT_MIN-NEXT: call void @__ubsan_handle_cfi_check_fail_minimal_abort() #[[ATTR3:[0-9]+]], !nosanitize [[META5]] +// PRESERVE_ABORT_MIN-NEXT: unreachable, !nosanitize [[META5]] +// PRESERVE_ABORT_MIN: [[CONT]]: +// PRESERVE_ABORT_MIN-NEXT: [[VFN:%.*]] = getelementptr inbounds ptr, ptr [[VTABLE]], i64 0 +// PRESERVE_ABORT_MIN-NEXT: [[TMP3:%.*]] = load ptr, ptr [[VFN]], align 8 +// PRESERVE_ABORT_MIN-NEXT: call void [[TMP3]](ptr noundef nonnull align 8 dereferenceable(8) [[TMP0]]) +// PRESERVE_ABORT_MIN-NEXT: ret void +// void s1f(S1 *s1) { s1->f(); } @@ -154,3 +176,6 @@ void s1f(S1 *s1) { // PRESERVE_MIN: [[META5]] = !{} // PRESERVE_MIN: [[PROF6]] = !{!"branch_weights", i32 1048575, i32 1} //. +// PRESERVE_ABORT_MIN: [[META5]] = !{} +// PRESERVE_ABORT_MIN: [[PROF6]] = !{!"branch_weights", i32 1048575, i32 1} +//. >From 2b8b38a9753c414c10007f34dff5479576a3a220 Mon Sep 17 00:00:00 2001 From: Florian Mayer <[email protected]> Date: Thu, 20 Nov 2025 15:14:26 -0800 Subject: [PATCH 5/6] localoob Created using spr 1.3.7 --- .../Instrumentation/BoundsChecking.cpp | 2 ++ .../BoundsChecking/runtimes.ll | 32 +++++++++---------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/llvm/lib/Transforms/Instrumentation/BoundsChecking.cpp b/llvm/lib/Transforms/Instrumentation/BoundsChecking.cpp index ae2760b0b69ad..e7be188ca92c2 100644 --- a/llvm/lib/Transforms/Instrumentation/BoundsChecking.cpp +++ b/llvm/lib/Transforms/Instrumentation/BoundsChecking.cpp @@ -265,6 +265,8 @@ static bool addBoundsChecking(Function &F, TargetLibraryInfo &TLI, bool MayReturn = Opts.Rt && Opts.Rt->MayReturn; if (MayReturn) { IRB.CreateBr(Cont); + if (Opts.Rt && Opts.Rt->HandlerPreserveAllRegs && Opts.Rt->MinRuntime) + TrapCall->setCallingConv(CallingConv::PreserveAll); } else { TrapCall->setDoesNotReturn(); IRB.CreateUnreachable(); diff --git a/llvm/test/Instrumentation/BoundsChecking/runtimes.ll b/llvm/test/Instrumentation/BoundsChecking/runtimes.ll index b4f936bc11dab..101272e4f8a0c 100644 --- a/llvm/test/Instrumentation/BoundsChecking/runtimes.ll +++ b/llvm/test/Instrumentation/BoundsChecking/runtimes.ll @@ -96,6 +96,22 @@ define void @f1(i64 %x) nounwind { ; RTABORT-NOMERGE-NEXT: call void @__ubsan_handle_local_out_of_bounds_abort() #[[ATTR2:[0-9]+]], !nosanitize [[META0]] ; RTABORT-NOMERGE-NEXT: unreachable, !nosanitize [[META0]] ; +; MINRT-PRESERVE-NOMERGE-LABEL: define void @f1( +; MINRT-PRESERVE-NOMERGE-SAME: i64 [[X:%.*]]) #[[ATTR0:[0-9]+]] { +; MINRT-PRESERVE-NOMERGE-NEXT: [[TMP1:%.*]] = mul i64 16, [[X]] +; MINRT-PRESERVE-NOMERGE-NEXT: [[TMP2:%.*]] = alloca i128, i64 [[X]], align 8 +; MINRT-PRESERVE-NOMERGE-NEXT: [[TMP3:%.*]] = sub i64 [[TMP1]], 0, !nosanitize [[META0:![0-9]+]] +; MINRT-PRESERVE-NOMERGE-NEXT: [[TMP4:%.*]] = icmp ult i64 [[TMP3]], 16, !nosanitize [[META0]] +; MINRT-PRESERVE-NOMERGE-NEXT: [[TMP5:%.*]] = or i1 false, [[TMP4]], !nosanitize [[META0]] +; MINRT-PRESERVE-NOMERGE-NEXT: [[TMP6:%.*]] = or i1 false, [[TMP5]], !nosanitize [[META0]] +; MINRT-PRESERVE-NOMERGE-NEXT: br i1 [[TMP6]], label %[[TRAP:.*]], label %[[BB7:.*]] +; MINRT-PRESERVE-NOMERGE: [[BB7]]: +; MINRT-PRESERVE-NOMERGE-NEXT: [[TMP8:%.*]] = load i128, ptr [[TMP2]], align 4 +; MINRT-PRESERVE-NOMERGE-NEXT: ret void +; MINRT-PRESERVE-NOMERGE: [[TRAP]]: +; MINRT-PRESERVE-NOMERGE-NEXT: call preserve_allcc void @__ubsan_handle_local_out_of_bounds_minimal_preserve() #[[ATTR1:[0-9]+]], !nosanitize [[META0]] +; MINRT-PRESERVE-NOMERGE-NEXT: br label %[[BB7]], !nosanitize [[META0]] +; ; MINRT-NOMERGE-LABEL: define void @f1( ; MINRT-NOMERGE-SAME: i64 [[X:%.*]]) #[[ATTR0:[0-9]+]] { ; MINRT-NOMERGE-NEXT: [[TMP1:%.*]] = mul i64 16, [[X]] @@ -112,22 +128,6 @@ define void @f1(i64 %x) nounwind { ; MINRT-NOMERGE-NEXT: call void @__ubsan_handle_local_out_of_bounds_minimal() #[[ATTR1:[0-9]+]], !nosanitize [[META0]] ; MINRT-NOMERGE-NEXT: br label %[[BB7]], !nosanitize [[META0]] ; -; MINRT-PRESERVE-NOMERGE-LABEL: define void @f1( -; MINRT-PRESERVE-NOMERGE-SAME: i64 [[X:%.*]]) #[[ATTR0:[0-9]+]] { -; MINRT-PRESERVE-NOMERGE-NEXT: [[TMP1:%.*]] = mul i64 16, [[X]] -; MINRT-PRESERVE-NOMERGE-NEXT: [[TMP2:%.*]] = alloca i128, i64 [[X]], align 8 -; MINRT-PRESERVE-NOMERGE-NEXT: [[TMP3:%.*]] = sub i64 [[TMP1]], 0, !nosanitize [[META0:![0-9]+]] -; MINRT-PRESERVE-NOMERGE-NEXT: [[TMP4:%.*]] = icmp ult i64 [[TMP3]], 16, !nosanitize [[META0]] -; MINRT-PRESERVE-NOMERGE-NEXT: [[TMP5:%.*]] = or i1 false, [[TMP4]], !nosanitize [[META0]] -; MINRT-PRESERVE-NOMERGE-NEXT: [[TMP6:%.*]] = or i1 false, [[TMP5]], !nosanitize [[META0]] -; MINRT-PRESERVE-NOMERGE-NEXT: br i1 [[TMP6]], label %[[TRAP:.*]], label %[[BB7:.*]] -; MINRT-PRESERVE-NOMERGE: [[BB7]]: -; MINRT-PRESERVE-NOMERGE-NEXT: [[TMP8:%.*]] = load i128, ptr [[TMP2]], align 4 -; MINRT-PRESERVE-NOMERGE-NEXT: ret void -; MINRT-PRESERVE-NOMERGE: [[TRAP]]: -; MINRT-PRESERVE-NOMERGE-NEXT: call void @__ubsan_handle_local_out_of_bounds_minimal_preserve() #[[ATTR1:[0-9]+]], !nosanitize [[META0]] -; MINRT-PRESERVE-NOMERGE-NEXT: br label %[[BB7]], !nosanitize [[META0]] -; ; MINRTABORT-NOMERGE-LABEL: define void @f1( ; MINRTABORT-NOMERGE-SAME: i64 [[X:%.*]]) #[[ATTR0:[0-9]+]] { ; MINRTABORT-NOMERGE-NEXT: [[TMP1:%.*]] = mul i64 16, [[X]] >From ec9be2de77099b340245b5f7981227c855909820 Mon Sep 17 00:00:00 2001 From: Florian Mayer <[email protected]> Date: Thu, 20 Nov 2025 15:28:39 -0800 Subject: [PATCH 6/6] moire test Created using spr 1.3.7 --- llvm/lib/Passes/PassBuilder.cpp | 9 +++------ llvm/test/Instrumentation/BoundsChecking/runtimes.ll | 7 ++++++- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp index 948a66ee1623f..f5281ea69b512 100644 --- a/llvm/lib/Passes/PassBuilder.cpp +++ b/llvm/lib/Passes/PassBuilder.cpp @@ -1604,12 +1604,6 @@ parseBoundsCheckingOptions(StringRef Params) { /*MayReturn=*/true, /*HandlerPreserveAllRegs=*/false, }; - } else if (ParamName == "min-rt-handler-preserve-all-regs") { - Options.Rt = { - /*MinRuntime=*/true, - /*MayReturn=*/true, - /*HandlerPreserveAllRegs=*/true, - }; } else if (ParamName == "min-rt-abort") { Options.Rt = { /*MinRuntime=*/true, @@ -1618,6 +1612,9 @@ parseBoundsCheckingOptions(StringRef Params) { }; } else if (ParamName == "merge") { Options.Merge = true; + } else if (ParamName == "handler-preserve-all-regs") { + if (Options.Rt) + Options.Rt->HandlerPreserveAllRegs = true; } else { StringRef ParamEQ; StringRef Val; diff --git a/llvm/test/Instrumentation/BoundsChecking/runtimes.ll b/llvm/test/Instrumentation/BoundsChecking/runtimes.ll index 101272e4f8a0c..d66052b5fe71d 100644 --- a/llvm/test/Instrumentation/BoundsChecking/runtimes.ll +++ b/llvm/test/Instrumentation/BoundsChecking/runtimes.ll @@ -8,7 +8,12 @@ ; RUN: opt < %s -passes='bounds-checking<rt-abort>' -S | FileCheck %s --check-prefixes=RTABORT-NOMERGE ; RUN: opt < %s -passes='bounds-checking<min-rt>' -S | FileCheck %s --check-prefixes=MINRT-NOMERGE ; RUN: opt < %s -passes='bounds-checking<min-rt-abort>' -S | FileCheck %s --check-prefixes=MINRTABORT-NOMERGE -; RUN: opt < %s -passes='bounds-checking<min-rt-handler-preserve-all-regs>' -S | FileCheck %s --check-prefixes=MINRT-PRESERVE-NOMERGE + +; RUN: opt < %s -passes='bounds-checking<trap;handler-preserve-all-regs>' -S | FileCheck %s --check-prefixes=TR-NOMERGE +; RUN: opt < %s -passes='bounds-checking<rt;handler-preserve-all-regs>' -S | FileCheck %s --check-prefixes=RT-NOMERGE +; RUN: opt < %s -passes='bounds-checking<rt-abort;handler-preserve-all-regs>' -S | FileCheck %s --check-prefixes=RTABORT-NOMERGE +; RUN: opt < %s -passes='bounds-checking<min-rt;handler-preserve-all-regs>' -S | FileCheck %s --check-prefixes=MINRT-PRESERVE-NOMERGE +; RUN: opt < %s -passes='bounds-checking<min-rt-abort;handler-preserve-all-regs>' -S | FileCheck %s --check-prefixes=MINRTABORT-NOMERGE ; ; RUN: opt < %s -passes='bounds-checking<trap;guard=3>' -S | FileCheck %s --check-prefixes=TR-GUARD-COMMON,TR-GUARD-THREE ; RUN: opt < %s -passes='bounds-checking<trap;guard=13>' -S | FileCheck %s --check-prefixes=TR-GUARD-COMMON,TR-GUARD-THIRTEEN _______________________________________________ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
