[llvm] [Attributor] Use more appropriate approach to check flat address space (PR #108713)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 15 05:31:09 PDT 2024


================
@@ -3294,6 +3295,27 @@ InformationCache::getIndirectlyCallableFunctions(Attributor &A) const {
   return IndirectlyCallableFunctions;
 }
 
+unsigned InformationCache::getFlatAddressSpace(const Function *F) {
+  if (!F)
+    return getAssumedFlatAddressSpace();
+  auto *TTI = getAnalysisResultForFunction<TargetIRAnalysis>(*F);
+  if (!TTI)
+    return getAssumedFlatAddressSpace();
+  return TTI->getFlatAddressSpace();
+}
+
+unsigned InformationCache::getAssumedFlatAddressSpace() const {
+  if (targetIsGPU()) {
+    if (TargetTriple.isAMDGPU() || TargetTriple.isNVPTX()) {
----------------
arsenm wrote:

this is doing the targetIsGPU check twice, but it shouldn't be necessary anyway 

https://github.com/llvm/llvm-project/pull/108713


More information about the llvm-commits mailing list