<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<p style="font-family:Arial;font-size:10pt;color:#0000FF;margin:5pt;" align="Left">
[AMD Official Use Only - General]<br>
</p>
<br>
<div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);" class="elementToProof">
Should this go off the calling convention instead of this attribute I've never seen before?</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> llvm-commits <llvm-commits-bounces@lists.llvm.org> on behalf of Johannes Doerfert via llvm-commits <llvm-commits@lists.llvm.org><br>
<b>Sent:</b> Thursday, February 2, 2023 5:03 PM<br>
<b>To:</b> llvm-commits@lists.llvm.org <llvm-commits@lists.llvm.org><br>
<b>Subject:</b> [llvm] 63b0227 - [Attributor][NFCI] Avoid spending time resolving kernel reachability queries</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.<br>
<br>
<br>
Author: Johannes Doerfert<br>
Date: 2023-02-02T13:59:58-08:00<br>
New Revision: 63b02271a8916c8ed8ce240ac5823825329755a6<br>
<br>
URL: <a href="https://github.com/llvm/llvm-project/commit/63b02271a8916c8ed8ce240ac5823825329755a6">
https://github.com/llvm/llvm-project/commit/63b02271a8916c8ed8ce240ac5823825329755a6</a><br>
DIFF: <a href="https://github.com/llvm/llvm-project/commit/63b02271a8916c8ed8ce240ac5823825329755a6.diff">
https://github.com/llvm/llvm-project/commit/63b02271a8916c8ed8ce240ac5823825329755a6.diff</a><br>
<br>
LOG: [Attributor][NFCI] Avoid spending time resolving kernel reachability queries<br>
<br>
We know kernels (generally) cannot be called from within the module. Thus,<br>
for reachability we would need to step back from a kernel which would allow<br>
us to reach anything anyway. Even if a kernel is invoked from another<br>
kernel, values like allocas and shared memory are not accessible. We<br>
implicitly check for this situation to avoid costly lookups.<br>
<br>
Added:<br>
<br>
<br>
Modified:<br>
    llvm/lib/Transforms/IPO/Attributor.cpp<br>
<br>
Removed:<br>
<br>
<br>
<br>
################################################################################<br>
diff  --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp<br>
index 67d21adb6bdb..f83acb0f1753 100644<br>
--- a/llvm/lib/Transforms/IPO/Attributor.cpp<br>
+++ b/llvm/lib/Transforms/IPO/Attributor.cpp<br>
@@ -586,6 +586,19 @@ isPotentiallyReachable(Attributor &A, const Instruction &FromI,<br>
         dbgs() << *ES << "\n";<br>
   });<br>
<br>
+  // We know kernels (generally) cannot be called from within the module. Thus,<br>
+  // for reachability we would need to step back from a kernel which would allow<br>
+  // us to reach anything anyway. Even if a kernel is invoked from another<br>
+  // kernel, values like allocas and shared memory are not accessible. We<br>
+  // implicitly check for this situation to avoid costly lookups.<br>
+  if (GoBackwardsCB && &ToFn != FromI.getFunction() &&<br>
+      !GoBackwardsCB(*FromI.getFunction()) && ToFn.hasFnAttribute("kernel") &&<br>
+      FromI.getFunction()->hasFnAttribute("kernel")) {<br>
+    LLVM_DEBUG(dbgs() << "[AA] assume kernel cannot be reached from within the "<br>
+                         "module; success\n";);<br>
+    return false;<br>
+  }<br>
+<br>
   // If we can go arbitrarily backwards we will eventually reach an entry point<br>
   // that can reach ToI. Only if a set of blocks through which we cannot go is<br>
   // provided, or once we track internal functions not accessible from the<br>
<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
llvm-commits@lists.llvm.org<br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</div>
</span></font></div>
</div>
</body>
</html>