Skip to content

Commit

Permalink
[memoryssa] Exclude llvm.allow.{runtime,ubsan}.check() (#86066)
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalybuka committed Apr 1, 2024
1 parent 0bc3781 commit 37d6e5b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
4 changes: 4 additions & 0 deletions llvm/lib/Analysis/MemorySSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,8 @@ instructionClobbersQuery(const MemoryDef *MD, const MemoryLocation &UseLoc,
// clobbers where they don't really exist at all. Please see D43269 for
// context.
switch (II->getIntrinsicID()) {
case Intrinsic::allow_runtime_check:
case Intrinsic::allow_ubsan_check:
case Intrinsic::invariant_start:
case Intrinsic::invariant_end:
case Intrinsic::assume:
Expand Down Expand Up @@ -1725,6 +1727,8 @@ MemoryUseOrDef *MemorySSA::createNewAccess(Instruction *I,
switch (II->getIntrinsicID()) {
default:
break;
case Intrinsic::allow_runtime_check:
case Intrinsic::allow_ubsan_check:
case Intrinsic::assume:
case Intrinsic::experimental_noalias_scope_decl:
case Intrinsic::pseudoprobe:
Expand Down
29 changes: 29 additions & 0 deletions llvm/test/Analysis/MemorySSA/allow-check.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
; RUN: opt -aa-pipeline=basic-aa -passes='print<memoryssa>,verify<memoryssa>' -disable-output < %s 2>&1 | FileCheck %s --implicit-check-not=MemoryDef
;
; Ensures that allow.*.check are treated as not reading or writing memory.

target triple = "aarch64-linux"

define i1 @test_runtime(ptr %a) local_unnamed_addr {
entry:
; CHECK: 1 = MemoryDef(liveOnEntry)
store i32 4, ptr %a, align 4
%allow = call i1 @llvm.allow.runtime.check(metadata !"test_check")
%0 = load i32, ptr %a, align 4
; CHECK: MemoryUse(1)
ret i1 %allow
}

declare i1 @llvm.allow.runtime.check(metadata)

define i1 @test_ubsan(ptr %a) local_unnamed_addr {
entry:
; CHECK: 1 = MemoryDef(liveOnEntry)
store i32 4, ptr %a, align 4
%allow = call i1 @llvm.allow.ubsan.check(i8 7)
%0 = load i32, ptr %a, align 4
; CHECK: MemoryUse(1)
ret i1 %allow
}

declare i1 @llvm.allow.ubsan.check(i8)

0 comments on commit 37d6e5b

Please sign in to comment.