[PATCH] D101541: BasicAA: Recognize inttoptr as isEscapeSource
Joseph Tremoulet via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 29 08:41:07 PDT 2021
JosephTremoulet created this revision.
Herald added a subscriber: hiraditya.
JosephTremoulet requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Pointers escape when converted to integers, so a pointer produced by
converting an integer to a pointer must not be a local non-escaping
object.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D101541
Files:
llvm/lib/Analysis/BasicAliasAnalysis.cpp
llvm/test/Analysis/BasicAA/noalias-inttoptr.ll
Index: llvm/test/Analysis/BasicAA/noalias-inttoptr.ll
===================================================================
--- /dev/null
+++ llvm/test/Analysis/BasicAA/noalias-inttoptr.ll
@@ -0,0 +1,10 @@
+; RUN: opt < %s -basic-aa -aa-eval -print-all-alias-modref-info -disable-output 2>&1 | FileCheck %s
+target datalayout = "p:64:64"
+
+define void @test1(i8* noalias %P, i64 %Q_as_int) {
+ ; CHECK: NoAlias: i8* %P, i8* %Q
+ %Q = inttoptr i64 %Q_as_int to i8*
+ store i8 0, i8* %P
+ store i8 1, i8* %Q
+ ret void
+}
Index: llvm/lib/Analysis/BasicAliasAnalysis.cpp
===================================================================
--- llvm/lib/Analysis/BasicAliasAnalysis.cpp
+++ llvm/lib/Analysis/BasicAliasAnalysis.cpp
@@ -129,6 +129,14 @@
if (isa<LoadInst>(V))
return true;
+ // The inttoptr case works because isNonEscapingLocalObject considers all
+ // means of converting or equating a pointer to an int (ptrtoint, ptr store
+ // which could be followed by an integer load, ptr<->int compare) as
+ // escaping, and objects located at well-known addresses via platform-specific
+ // means cannot be considered non-escaping local objects.
+ if (isa<IntToPtrInst>(V))
+ return true;
+
return false;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D101541.341531.patch
Type: text/x-patch
Size: 1238 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210429/cd637362/attachment.bin>
More information about the llvm-commits
mailing list