[llvm] c0c8548 - [AMDGPU] Do not annotate features for graphics
Sebastian Neubauer via llvm-commits
llvm-commits at lists.llvm.org
Mon May 3 01:34:05 PDT 2021
Author: Sebastian Neubauer
Date: 2021-05-03T10:33:11+02:00
New Revision: c0c8548b70685533da46d9453eac9f3cfb22ccc6
URL: https://github.com/llvm/llvm-project/commit/c0c8548b70685533da46d9453eac9f3cfb22ccc6
DIFF: https://github.com/llvm/llvm-project/commit/c0c8548b70685533da46d9453eac9f3cfb22ccc6.diff
LOG: [AMDGPU] Do not annotate features for graphics
SITargetLowering::LowerFormalArguments asserts that none of these
features are used for graphics calling conventions, so
AnnotateKernelFeatures should not add them.
Differential Revision: https://reviews.llvm.org/D101534
Added:
llvm/test/CodeGen/AMDGPU/pal-simple-indirect-call.ll
Modified:
llvm/lib/Target/AMDGPU/AMDGPUAnnotateKernelFeatures.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUAnnotateKernelFeatures.cpp b/llvm/lib/Target/AMDGPU/AMDGPUAnnotateKernelFeatures.cpp
index c986b261e36a2..af6dfc07eb500 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUAnnotateKernelFeatures.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUAnnotateKernelFeatures.cpp
@@ -403,9 +403,11 @@ bool AMDGPUAnnotateKernelFeatures::runOnSCC(CallGraphSCC &SCC) {
}
Function *F = I->getFunction();
- // Add feature attributes
- if (!F || F->isDeclaration())
+ // Ignore functions with graphics calling conventions, these are currently
+ // not allowed to have kernel arguments.
+ if (!F || F->isDeclaration() || AMDGPU::isGraphics(F->getCallingConv()))
continue;
+ // Add feature attributes
Changed |= addFeatureAttributes(*F);
}
diff --git a/llvm/test/CodeGen/AMDGPU/pal-simple-indirect-call.ll b/llvm/test/CodeGen/AMDGPU/pal-simple-indirect-call.ll
new file mode 100644
index 0000000000000..d1b826b701458
--- /dev/null
+++ b/llvm/test/CodeGen/AMDGPU/pal-simple-indirect-call.ll
@@ -0,0 +1,36 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; Check that no attributes are added to graphics functions
+; RUN: opt -S -mtriple=amdgcn-amd-amdpal -amdgpu-annotate-kernel-features %s | FileCheck -check-prefix=GCN %s
+
+; Check that it doesn't crash
+; RUN: llc -mtriple=amdgcn-amd-amdpal -mcpu=gfx1010 < %s | FileCheck -check-prefix=GFX9 %s
+
+target datalayout = "A5"
+
+define amdgpu_cs void @test_simple_indirect_call() {
+; GCN-LABEL: define amdgpu_cs void @test_simple_indirect_call() {
+; GFX9-LABEL: test_simple_indirect_call:
+; GFX9: ; %bb.0:
+; GFX9-NEXT: s_getpc_b64 s[36:37]
+; GFX9-NEXT: s_mov_b32 s36, s0
+; GFX9-NEXT: s_getpc_b64 s[4:5]
+; GFX9-NEXT: s_load_dwordx4 s[36:39], s[36:37], 0x10
+; GFX9-NEXT: s_mov_b32 s32, 0
+; GFX9-NEXT: s_waitcnt lgkmcnt(0)
+; GFX9-NEXT: s_add_u32 s36, s36, s0
+; GFX9-NEXT: s_addc_u32 s37, s37, 0
+; GFX9-NEXT: s_mov_b64 s[0:1], s[36:37]
+; GFX9-NEXT: s_mov_b64 s[2:3], s[38:39]
+; GFX9-NEXT: s_swappc_b64 s[30:31], s[4:5]
+; GFX9-NEXT: s_endpgm
+
+ %pc = call i64 @llvm.amdgcn.s.getpc()
+ %fun = inttoptr i64 %pc to void()*
+ call amdgpu_gfx void %fun()
+ ret void
+}
+
+; Function Attrs: nounwind readnone speculatable willreturn
+declare i64 @llvm.amdgcn.s.getpc() #0
+
+attributes #0 = { nounwind readnone speculatable willreturn }
More information about the llvm-commits
mailing list