[PATCH] D128444: [BasicAA] Handle passthru calls in isEscapeSource()

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 23 07:40:40 PDT 2022


nikic created this revision.
nikic added reviewers: fhahn, asbirlea, reames, efriedma.
Herald added subscribers: jeroen.dobbelaere, hiraditya.
Herald added a project: All.
nikic requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

isEscapeSource() currently considers all call return values as escape sources. However, CaptureTracking can look through certain calls, so we shouldn't consider these as escape sources either.

The corresponding CaptureTracking code is https://github.com/llvm/llvm-project/blob/7c9a3825b8420f5d37c5bb8919a9e46684a87089/llvm/lib/Analysis/CaptureTracking.cpp#L332-L333.


https://reviews.llvm.org/D128444

Files:
  llvm/lib/Analysis/BasicAliasAnalysis.cpp
  llvm/test/Analysis/BasicAA/call-escape-source.ll


Index: llvm/test/Analysis/BasicAA/call-escape-source.ll
===================================================================
--- llvm/test/Analysis/BasicAA/call-escape-source.ll
+++ llvm/test/Analysis/BasicAA/call-escape-source.ll
@@ -1,11 +1,11 @@
 ; RUN: opt -aa-eval -print-all-alias-modref-info -disable-output < %s 2>&1 | FileCheck %s
 
-; FIXME: A call return value is not always an escape source, because
+; A call return value is not always an escape source, because
 ; CaptureTracking can look through some calls. The test is constructed to
 ; hit the getUnderlyingObject() recursion limit.
 define i32 @test() {
 ; CHECK-LABEL: Function: test
-; CHECK-NEXT: NoAlias: i32* %a, i32* %p7
+; CHECK-NEXT: MustAlias: i32* %a, i32* %p7
   %a = alloca i32
   %p1 = call ptr @llvm.strip.invariant.group.p0(ptr %a)
   %p2 = getelementptr i8, ptr %p1, i64 1
Index: llvm/lib/Analysis/BasicAliasAnalysis.cpp
===================================================================
--- llvm/lib/Analysis/BasicAliasAnalysis.cpp
+++ llvm/lib/Analysis/BasicAliasAnalysis.cpp
@@ -106,8 +106,9 @@
 /// Returns true if the pointer is one which would have been considered an
 /// escape by isNonEscapingLocalObject.
 static bool isEscapeSource(const Value *V) {
-  if (isa<CallBase>(V))
-    return true;
+  if (auto *CB = dyn_cast<CallBase>(V))
+    return !isIntrinsicReturningPointerAliasingArgumentWithoutCapturing(CB,
+                                                                        true);
 
   // The load case works because isNonEscapingLocalObject considers all
   // stores to be escapes (it passes true for the StoreCaptures argument


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D128444.439392.patch
Type: text/x-patch
Size: 1635 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220623/30fe553c/attachment.bin>


More information about the llvm-commits mailing list