[llvm] 63b0227 - [Attributor][NFCI] Avoid spending time resolving kernel reachability queries

Arsenault, Matthew via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 2 14:11:11 PST 2023


[AMD Official Use Only - General]

Should this go off the calling convention instead of this attribute I've never seen before?
________________________________
From: llvm-commits <llvm-commits-bounces at lists.llvm.org> on behalf of Johannes Doerfert via llvm-commits <llvm-commits at lists.llvm.org>
Sent: Thursday, February 2, 2023 5:03 PM
To: llvm-commits at lists.llvm.org <llvm-commits at lists.llvm.org>
Subject: [llvm] 63b0227 - [Attributor][NFCI] Avoid spending time resolving kernel reachability queries

Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.


Author: Johannes Doerfert
Date: 2023-02-02T13:59:58-08:00
New Revision: 63b02271a8916c8ed8ce240ac5823825329755a6

URL: https://github.com/llvm/llvm-project/commit/63b02271a8916c8ed8ce240ac5823825329755a6
DIFF: https://github.com/llvm/llvm-project/commit/63b02271a8916c8ed8ce240ac5823825329755a6.diff

LOG: [Attributor][NFCI] Avoid spending time resolving kernel reachability queries

We know kernels (generally) cannot be called from within the module. Thus,
for reachability we would need to step back from a kernel which would allow
us to reach anything anyway. Even if a kernel is invoked from another
kernel, values like allocas and shared memory are not accessible. We
implicitly check for this situation to avoid costly lookups.

Added:


Modified:
    llvm/lib/Transforms/IPO/Attributor.cpp

Removed:



################################################################################
diff  --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp
index 67d21adb6bdb..f83acb0f1753 100644
--- a/llvm/lib/Transforms/IPO/Attributor.cpp
+++ b/llvm/lib/Transforms/IPO/Attributor.cpp
@@ -586,6 +586,19 @@ isPotentiallyReachable(Attributor &A, const Instruction &FromI,
         dbgs() << *ES << "\n";
   });

+  // We know kernels (generally) cannot be called from within the module. Thus,
+  // for reachability we would need to step back from a kernel which would allow
+  // us to reach anything anyway. Even if a kernel is invoked from another
+  // kernel, values like allocas and shared memory are not accessible. We
+  // implicitly check for this situation to avoid costly lookups.
+  if (GoBackwardsCB && &ToFn != FromI.getFunction() &&
+      !GoBackwardsCB(*FromI.getFunction()) && ToFn.hasFnAttribute("kernel") &&
+      FromI.getFunction()->hasFnAttribute("kernel")) {
+    LLVM_DEBUG(dbgs() << "[AA] assume kernel cannot be reached from within the "
+                         "module; success\n";);
+    return false;
+  }
+
   // If we can go arbitrarily backwards we will eventually reach an entry point
   // that can reach ToI. Only if a set of blocks through which we cannot go is
   // provided, or once we track internal functions not accessible from the



_______________________________________________
llvm-commits mailing list
llvm-commits at lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230202/6ae3d95e/attachment.html>


More information about the llvm-commits mailing list