[PATCH] D91658: [BasicAA] Deoptimize intrinsics don't modify memory
Artur Pilipenko via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 17 13:35:53 PST 2020
apilipenko created this revision.
apilipenko added reviewers: yrouban, skatkov, fedor.sergeev, hfinkel.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.
apilipenko requested review of this revision.
Similarly to assumes and guards deoptimize intrinsics are marked as writing to ensure proper control dependencies but they never modify any particular memory location.
In most cases aliasing of deoptimize calls doesn't matter because these calls never return to the compiled code. One case were it does matter is transformations of the deopt operand bundle attached to the deoptimize. According to the lang ref "operand bundles represent an alternate “safe” continuation for the call site they’re attached to". Semantically the deopt bundle values are used after the call. (This is true for any call with deopt operand bundle, not only deoptimize calls). When we rewrite the deopt bundle values we need to take the effects of the call into account.
https://reviews.llvm.org/D91658
Files:
llvm/lib/Analysis/BasicAliasAnalysis.cpp
llvm/test/Analysis/BasicAA/deoptimize.ll
Index: llvm/test/Analysis/BasicAA/deoptimize.ll
===================================================================
--- /dev/null
+++ llvm/test/Analysis/BasicAA/deoptimize.ll
@@ -0,0 +1,14 @@
+; RUN: opt < %s -basic-aa -aa-eval -print-all-alias-modref-info -disable-output 2>&1 | FileCheck %s
+target datalayout = "e-p:32:32:32-i1:8:32-i8:8:32-i16:16:32-i32:32:32-i64:32:32-f32:32:32-f64:32:32-v64:32:64-v128:32:128-a0:0:32-n32"
+
+declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture, i64, i32, i1) #0
+declare void @llvm.experimental.deoptimize.void(...)
+declare void @unknown_but_readonly() readonly
+
+define void @test1(i8* %p) {
+ call void(...) @llvm.experimental.deoptimize.void() [ "deopt"() ]
+ ret void
+
+; CHECK-LABEL: Function: test1:
+; CHECK: Just Ref: Ptr: i8* %p <-> call void (...) @llvm.experimental.deoptimize.isVoid() [ "deopt"() ]
+}
Index: llvm/lib/Analysis/BasicAliasAnalysis.cpp
===================================================================
--- llvm/lib/Analysis/BasicAliasAnalysis.cpp
+++ llvm/lib/Analysis/BasicAliasAnalysis.cpp
@@ -958,6 +958,9 @@
// the guard invokes the "deopt" continuation.
if (isIntrinsicCall(Call, Intrinsic::experimental_guard))
return ModRefInfo::Ref;
+ // The same applies to deoptimize which is essentially a guard(false).
+ if (isIntrinsicCall(Call, Intrinsic::experimental_deoptimize))
+ return ModRefInfo::Ref;
// Like assumes, invariant.start intrinsics were also marked as arbitrarily
// writing so that proper control dependencies are maintained but they never
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D91658.305884.patch
Type: text/x-patch
Size: 1573 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201117/62b6fcb6/attachment.bin>
More information about the llvm-commits
mailing list