[llvm] 63b0227 - [Attributor][NFCI] Avoid spending time resolving kernel reachability queries
Johannes Doerfert via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 2 14:03:18 PST 2023
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
More information about the llvm-commits
mailing list