[llvm] [AMDGPU][Attributor] Don't run `AAAddressSpace` for graphics functions (PR #108560)

Shilei Tian via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 13 06:26:24 PDT 2024


https://github.com/shiltian created https://github.com/llvm/llvm-project/pull/108560

None

>From f7e15791f110cbec4a46af81bc8ee0267172a7d3 Mon Sep 17 00:00:00 2001
From: Shilei Tian <i at tianshilei.me>
Date: Fri, 13 Sep 2024 09:25:50 -0400
Subject: [PATCH] [AMDGPU][Attributor] Don't run `AAAddressSpace` for graphics
 functions

---
 llvm/lib/Target/AMDGPU/AMDGPUAttributor.cpp | 29 ++++++++++++---------
 1 file changed, 16 insertions(+), 13 deletions(-)

diff --git a/llvm/lib/Target/AMDGPU/AMDGPUAttributor.cpp b/llvm/lib/Target/AMDGPU/AMDGPUAttributor.cpp
index 687a7339da379d..37c8b043aca198 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUAttributor.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUAttributor.cpp
@@ -1077,19 +1077,22 @@ static bool runImpl(Module &M, AnalysisGetter &AG, TargetMachine &TM,
       addPreloadKernArgHint(*F, TM);
     }
 
-    for (auto &I : instructions(F)) {
-      if (auto *LI = dyn_cast<LoadInst>(&I)) {
-        A.getOrCreateAAFor<AAAddressSpace>(
-            IRPosition::value(*LI->getPointerOperand()));
-      } else if (auto *SI = dyn_cast<StoreInst>(&I)) {
-        A.getOrCreateAAFor<AAAddressSpace>(
-            IRPosition::value(*SI->getPointerOperand()));
-      } else if (auto *RMW = dyn_cast<AtomicRMWInst>(&I)) {
-        A.getOrCreateAAFor<AAAddressSpace>(
-            IRPosition::value(*RMW->getPointerOperand()));
-      } else if (auto *CmpX = dyn_cast<AtomicCmpXchgInst>(&I)) {
-        A.getOrCreateAAFor<AAAddressSpace>(
-            IRPosition::value(*CmpX->getPointerOperand()));
+    // Don't bother to run AAAddressSpace for graphics.
+    if (!AMDGPU::isGraphics(F->getCallingConv())) {
+      for (auto &I : instructions(F)) {
+        if (auto *LI = dyn_cast<LoadInst>(&I)) {
+          A.getOrCreateAAFor<AAAddressSpace>(
+              IRPosition::value(*LI->getPointerOperand()));
+        } else if (auto *SI = dyn_cast<StoreInst>(&I)) {
+          A.getOrCreateAAFor<AAAddressSpace>(
+              IRPosition::value(*SI->getPointerOperand()));
+        } else if (auto *RMW = dyn_cast<AtomicRMWInst>(&I)) {
+          A.getOrCreateAAFor<AAAddressSpace>(
+              IRPosition::value(*RMW->getPointerOperand()));
+        } else if (auto *CmpX = dyn_cast<AtomicCmpXchgInst>(&I)) {
+          A.getOrCreateAAFor<AAAddressSpace>(
+              IRPosition::value(*CmpX->getPointerOperand()));
+        }
       }
     }
   }



More information about the llvm-commits mailing list