[llvm] e282c27 - [AMDGPU] Mark the async marker intrinsics nocallback (#219099)

via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 3 07:54:32 PDT 2026


Author: Wang, Dewei
Date: 2026-09-03T22:54:26+08:00
New Revision: e282c27d4c4d1c4fd8cea8d0dcb4674ad2dff02d

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

LOG: [AMDGPU] Mark the async marker intrinsics nocallback (#219099)

llvm.amdgcn.asyncmark and llvm.amdgcn.wait.asyncmark only set and await
a marker in the stream of async requests. They cannot transfer control
out of the module, so they qualify for nocallback.

Without it, AAAMDGPUMinAGPRAlloc takes its conservative arm for calls
that are not nocallback and reaches a pessimistic fixpoint, so no
amdgpu-agpr-alloc attribute is manifested. getMaxNumVectorRegs then
falls back to reserving half of the vector register file for AGPRs,
which halves the arch VGPRs available to any kernel that uses async LDS
copies.

---------

Co-authored-by: Harrison Hao <57025411+harrisonGPU at users.noreply.github.com>

Added: 
    llvm/test/CodeGen/AMDGPU/amdgpu-attributor-asyncmark-leaf.ll

Modified: 
    llvm/include/llvm/IR/IntrinsicsAMDGPU.td

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/IR/IntrinsicsAMDGPU.td b/llvm/include/llvm/IR/IntrinsicsAMDGPU.td
index 037630ea86904..716a3f312b0f2 100644
--- a/llvm/include/llvm/IR/IntrinsicsAMDGPU.td
+++ b/llvm/include/llvm/IR/IntrinsicsAMDGPU.td
@@ -2923,12 +2923,15 @@ def int_amdgcn_pops_exiting_wave_id :
 
 // Sets a marker in the stream of async requests. Modelled as InaccessibleMem.
 def int_amdgcn_asyncmark : ClangBuiltin<"__builtin_amdgcn_asyncmark">,
-  Intrinsic<[], [], [IntrNoMem, IntrHasSideEffects]>;
+  Intrinsic<[], [], [IntrNoMem, IntrHasSideEffects, IntrWillReturn,
+                     IntrNoCallback, IntrNoFree]>;
 
 // Waits until the Nth previous marker is completed, if it exists.
 def int_amdgcn_wait_asyncmark :
     ClangBuiltin<"__builtin_amdgcn_wait_asyncmark">,
-    Intrinsic<[], [llvm_i16_ty], [ImmArg<ArgIndex<0>>, IntrNoMem, IntrHasSideEffects]>;
+    Intrinsic<[], [llvm_i16_ty],
+              [ImmArg<ArgIndex<0>>, IntrNoMem, IntrHasSideEffects,
+               IntrWillReturn, IntrNoCallback, IntrNoFree]>;
 
 //===----------------------------------------------------------------------===//
 // GFX10 Intrinsics

diff  --git a/llvm/test/CodeGen/AMDGPU/amdgpu-attributor-asyncmark-leaf.ll b/llvm/test/CodeGen/AMDGPU/amdgpu-attributor-asyncmark-leaf.ll
new file mode 100644
index 0000000000000..2dc823f54139c
--- /dev/null
+++ b/llvm/test/CodeGen/AMDGPU/amdgpu-attributor-asyncmark-leaf.ll
@@ -0,0 +1,16 @@
+; RUN: opt -S -mtriple=amdgpu9.50 -passes=amdgpu-attributor %s | FileCheck %s
+
+; The async marker intrinsics only set/await a marker in the stream of async
+; requests; they cannot transfer control out of the module. Make sure they do
+; not defeat the AGPR allocation inference, which conservatively gives up on
+; any call that is not nocallback.
+
+; CHECK: define amdgpu_kernel void @asyncmark_kernel({{.*}}) #[[ATTR:[0-9]+]]
+define amdgpu_kernel void @asyncmark_kernel(ptr addrspace(1) %out) {
+  call void @llvm.amdgcn.asyncmark()
+  call void @llvm.amdgcn.wait.asyncmark(i16 0)
+  store i32 0, ptr addrspace(1) %out
+  ret void
+}
+
+; CHECK: attributes #[[ATTR]] = {{{.*}}"amdgpu-agpr-alloc"="0"


        


More information about the llvm-commits mailing list