Skip to content

Commit d95f46c

Browse files
authored
[IR] Fix incorrect writeonly on llvm.allow.ubsan/runtime.check (#145492)
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.
1 parent 01b288f commit d95f46c

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

llvm/include/llvm/IR/Intrinsics.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1842,11 +1842,11 @@ def int_ubsantrap : Intrinsic<[], [llvm_i8_ty],
18421842

18431843
// Return true if ubsan check is allowed.
18441844
def int_allow_ubsan_check : DefaultAttrsIntrinsic<[llvm_i1_ty], [llvm_i8_ty],
1845-
[IntrInaccessibleMemOnly, IntrWriteMem, ImmArg<ArgIndex<0>>, NoUndef<RetIndex>]>;
1845+
[IntrInaccessibleMemOnly, ImmArg<ArgIndex<0>>, NoUndef<RetIndex>]>;
18461846

18471847
// Return true if runtime check is allowed.
18481848
def int_allow_runtime_check : DefaultAttrsIntrinsic<[llvm_i1_ty], [llvm_metadata_ty],
1849-
[IntrInaccessibleMemOnly, IntrWriteMem, NoUndef<RetIndex>]>,
1849+
[IntrInaccessibleMemOnly, NoUndef<RetIndex>]>,
18501850
ClangBuiltin<"__builtin_allow_runtime_check">;
18511851

18521852
// Support for dynamic deoptimization (or de-specialization)

llvm/test/Instrumentation/BoundsChecking/runtimes.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ define void @f1(i64 %x) nounwind {
205205
; TR-GUARD: attributes #[[ATTR3]] = { nomerge noreturn nounwind }
206206
;.
207207
; RT-GUARD: attributes #[[ATTR0]] = { nounwind }
208-
; RT-GUARD: attributes #[[ATTR1:[0-9]+]] = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) }
208+
; RT-GUARD: attributes #[[ATTR1:[0-9]+]] = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: readwrite) }
209209
; RT-GUARD: attributes #[[ATTR2]] = { nomerge nounwind }
210210
;.
211211
; TR: [[META0]] = !{}

0 commit comments

Comments
 (0)