From 88e3d4013ed593796e2c604a34d2e50f78b46189 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Tue, 24 Jun 2025 11:38:35 +0200 Subject: [PATCH] [IR] Fix incorrect writeonly on llvm.allow.ubsan/runtime.check These intrinsics introduced in #84850 are currently marked as `memory(inaccessiblemem: write)`. This is not correct for the intended purpose of allowing per-block decisions, as such calls may get DCEd across control-flow boundaries (which will start actually happening with #145474). Use `memory(inaccessiblemem: readwrite)` instead, just like all the other control-flow sensitive intrinsics. --- llvm/include/llvm/IR/Intrinsics.td | 4 ++-- llvm/test/Instrumentation/BoundsChecking/runtimes.ll | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/llvm/include/llvm/IR/Intrinsics.td b/llvm/include/llvm/IR/Intrinsics.td index 7add4a27ce9e9..bd6f94ac1286c 100644 --- a/llvm/include/llvm/IR/Intrinsics.td +++ b/llvm/include/llvm/IR/Intrinsics.td @@ -1842,11 +1842,11 @@ def int_ubsantrap : Intrinsic<[], [llvm_i8_ty], // Return true if ubsan check is allowed. def int_allow_ubsan_check : DefaultAttrsIntrinsic<[llvm_i1_ty], [llvm_i8_ty], - [IntrInaccessibleMemOnly, IntrWriteMem, ImmArg>, NoUndef]>; + [IntrInaccessibleMemOnly, ImmArg>, NoUndef]>; // Return true if runtime check is allowed. def int_allow_runtime_check : DefaultAttrsIntrinsic<[llvm_i1_ty], [llvm_metadata_ty], - [IntrInaccessibleMemOnly, IntrWriteMem, NoUndef]>, + [IntrInaccessibleMemOnly, NoUndef]>, ClangBuiltin<"__builtin_allow_runtime_check">; // Support for dynamic deoptimization (or de-specialization) diff --git a/llvm/test/Instrumentation/BoundsChecking/runtimes.ll b/llvm/test/Instrumentation/BoundsChecking/runtimes.ll index 6c1acf6d13775..2006a6db2ef40 100644 --- a/llvm/test/Instrumentation/BoundsChecking/runtimes.ll +++ b/llvm/test/Instrumentation/BoundsChecking/runtimes.ll @@ -205,7 +205,7 @@ define void @f1(i64 %x) nounwind { ; TR-GUARD: attributes #[[ATTR3]] = { nomerge noreturn nounwind } ;. ; RT-GUARD: attributes #[[ATTR0]] = { nounwind } -; RT-GUARD: attributes #[[ATTR1:[0-9]+]] = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) } +; RT-GUARD: attributes #[[ATTR1:[0-9]+]] = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: readwrite) } ; RT-GUARD: attributes #[[ATTR2]] = { nomerge nounwind } ;. ; TR: [[META0]] = !{}