Skip to content

Commit 37d6e5b

Browse files
authored
[memoryssa] Exclude llvm.allow.{runtime,ubsan}.check() (#86066)
RFC: https://discourse.llvm.org/t/rfc-add-llvm-experimental-hot-intrinsic-or-llvm-hot/77641
1 parent 0bc3781 commit 37d6e5b

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

llvm/lib/Analysis/MemorySSA.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,8 @@ instructionClobbersQuery(const MemoryDef *MD, const MemoryLocation &UseLoc,
292292
// clobbers where they don't really exist at all. Please see D43269 for
293293
// context.
294294
switch (II->getIntrinsicID()) {
295+
case Intrinsic::allow_runtime_check:
296+
case Intrinsic::allow_ubsan_check:
295297
case Intrinsic::invariant_start:
296298
case Intrinsic::invariant_end:
297299
case Intrinsic::assume:
@@ -1725,6 +1727,8 @@ MemoryUseOrDef *MemorySSA::createNewAccess(Instruction *I,
17251727
switch (II->getIntrinsicID()) {
17261728
default:
17271729
break;
1730+
case Intrinsic::allow_runtime_check:
1731+
case Intrinsic::allow_ubsan_check:
17281732
case Intrinsic::assume:
17291733
case Intrinsic::experimental_noalias_scope_decl:
17301734
case Intrinsic::pseudoprobe:
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
; RUN: opt -aa-pipeline=basic-aa -passes='print<memoryssa>,verify<memoryssa>' -disable-output < %s 2>&1 | FileCheck %s --implicit-check-not=MemoryDef
2+
;
3+
; Ensures that allow.*.check are treated as not reading or writing memory.
4+
5+
target triple = "aarch64-linux"
6+
7+
define i1 @test_runtime(ptr %a) local_unnamed_addr {
8+
entry:
9+
; CHECK: 1 = MemoryDef(liveOnEntry)
10+
store i32 4, ptr %a, align 4
11+
%allow = call i1 @llvm.allow.runtime.check(metadata !"test_check")
12+
%0 = load i32, ptr %a, align 4
13+
; CHECK: MemoryUse(1)
14+
ret i1 %allow
15+
}
16+
17+
declare i1 @llvm.allow.runtime.check(metadata)
18+
19+
define i1 @test_ubsan(ptr %a) local_unnamed_addr {
20+
entry:
21+
; CHECK: 1 = MemoryDef(liveOnEntry)
22+
store i32 4, ptr %a, align 4
23+
%allow = call i1 @llvm.allow.ubsan.check(i8 7)
24+
%0 = load i32, ptr %a, align 4
25+
; CHECK: MemoryUse(1)
26+
ret i1 %allow
27+
}
28+
29+
declare i1 @llvm.allow.ubsan.check(i8)

0 commit comments

Comments
 (0)