-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Reapply "[NFC][AMDGPU] Pre-commit clang and llvm tests for dynamic allocas" #120410
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@llvm/pr-subscribers-llvm-globalisel @llvm/pr-subscribers-backend-amdgpu Author: Aaditya (easyonaadit) ChangesThis reapplies commit #120063. A machine-verifier bug was causing a crash in the previous commit. Full diff: https://github.com/llvm/llvm-project/pull/120410.diff 2 Files Affected:
diff --git a/llvm/test/CodeGen/AMDGPU/GlobalISel/dynamic-alloca-divergent.ll b/llvm/test/CodeGen/AMDGPU/GlobalISel/dynamic-alloca-divergent.ll
index cfe5d1c194f420..aefcad491073fc 100644
--- a/llvm/test/CodeGen/AMDGPU/GlobalISel/dynamic-alloca-divergent.ll
+++ b/llvm/test/CodeGen/AMDGPU/GlobalISel/dynamic-alloca-divergent.ll
@@ -13,6 +13,31 @@ define amdgpu_kernel void @kernel_dynamic_stackalloc_vgpr_align4(ptr addrspace(1
ret void
}
+; ERR: remark: <unknown>:0:0: cannot select: %{{[0-9]+}}:sreg_32(p5) = G_DYN_STACKALLOC %{{[0-9]+}}:vgpr(s32), 1 (in function: kernel_dynamic_stackalloc_vgpr_default_align)
+; ERR-NEXT: warning: Instruction selection used fallback path for kernel_dynamic_stackalloc_vgpr_default_align
+; ERR-NEXT: error: <unknown>:0:0: in function kernel_dynamic_stackalloc_vgpr_default_align void (ptr addrspace(1)): unsupported dynamic alloca
+
+define amdgpu_kernel void @kernel_dynamic_stackalloc_vgpr_default_align(ptr addrspace(1) %ptr) {
+ %id = call i32 @llvm.amdgcn.workitem.id.x()
+ %gep = getelementptr i32, ptr addrspace(1) %ptr, i32 %id
+ %n = load i32, ptr addrspace(1) %gep
+ %alloca = alloca i32, i32 %n, addrspace(5)
+ store volatile i32 123, ptr addrspace(5) %alloca
+ ret void
+}
+; ERR: remark: <unknown>:0:0: cannot select: %{{[0-9]+}}:sreg_32(p5) = G_DYN_STACKALLOC %{{[0-9]+}}:vgpr(s32), 64 (in function: kernel_dynamic_stackalloc_vgpr_align64)
+; ERR-NEXT: warning: Instruction selection used fallback path for kernel_dynamic_stackalloc_vgpr_align64
+; ERR-NEXT: error: <unknown>:0:0: in function kernel_dynamic_stackalloc_vgpr_align64 void (ptr addrspace(1)): unsupported dynamic alloca
+
+define amdgpu_kernel void @kernel_dynamic_stackalloc_vgpr_align64(ptr addrspace(1) %ptr) {
+ %id = call i32 @llvm.amdgcn.workitem.id.x()
+ %gep = getelementptr i32, ptr addrspace(1) %ptr, i32 %id
+ %n = load i32, ptr addrspace(1) %gep
+ %alloca = alloca i32, i32 %n, align 64, addrspace(5)
+ store volatile i32 123, ptr addrspace(5) %alloca
+ ret void
+}
+
; ERR: remark: <unknown>:0:0: cannot select: %{{[0-9]+}}:sreg_32(p5) = G_DYN_STACKALLOC %{{[0-9]+}}:vgpr(s32), 1 (in function: func_dynamic_stackalloc_vgpr_align4)
; ERR-NEXT: warning: Instruction selection used fallback path for func_dynamic_stackalloc_vgpr_align4
; ERR-NEXT: error: <unknown>:0:0: in function func_dynamic_stackalloc_vgpr_align4 void (i32): unsupported dynamic alloca
@@ -23,6 +48,25 @@ define void @func_dynamic_stackalloc_vgpr_align4(i32 %n) {
ret void
}
+; ERR: remark: <unknown>:0:0: cannot select: %{{[0-9]+}}:sreg_32(p5) = G_DYN_STACKALLOC %{{[0-9]+}}:vgpr(s32), 1 (in function: func_dynamic_stackalloc_vgpr_default_align)
+; ERR-NEXT: warning: Instruction selection used fallback path for func_dynamic_stackalloc_vgpr_default_align
+; ERR-NEXT: error: <unknown>:0:0: in function func_dynamic_stackalloc_vgpr_default_align void (i32): unsupported dynamic alloca
+
+define void @func_dynamic_stackalloc_vgpr_default_align(i32 %n) {
+ %alloca = alloca i32, i32 %n, addrspace(5)
+ store volatile i32 456, ptr addrspace(5) %alloca
+ ret void
+}
+; ERR: remark: <unknown>:0:0: cannot select: %{{[0-9]+}}:sreg_32(p5) = G_DYN_STACKALLOC %{{[0-9]+}}:vgpr(s32), 64 (in function: func_dynamic_stackalloc_vgpr_align64)
+; ERR-NEXT: warning: Instruction selection used fallback path for func_dynamic_stackalloc_vgpr_align64
+; ERR-NEXT: error: <unknown>:0:0: in function func_dynamic_stackalloc_vgpr_align64 void (i32): unsupported dynamic alloca
+
+define void @func_dynamic_stackalloc_vgpr_align64(i32 %n) {
+ %alloca = alloca i32, i32 %n, align 64, addrspace(5)
+ store volatile i32 456, ptr addrspace(5) %alloca
+ ret void
+}
+
declare i32 @llvm.amdgcn.workitem.id.x() #0
attributes #0 = { nounwind readnone speculatable }
diff --git a/llvm/test/CodeGen/AMDGPU/dynamic_stackalloc.ll b/llvm/test/CodeGen/AMDGPU/dynamic_stackalloc.ll
index 1c093bf31ea75f..73aa87e5c55d20 100644
--- a/llvm/test/CodeGen/AMDGPU/dynamic_stackalloc.ll
+++ b/llvm/test/CodeGen/AMDGPU/dynamic_stackalloc.ll
@@ -5,8 +5,188 @@ target datalayout = "A5"
; CHECK: in function test_dynamic_stackalloc{{.*}}: unsupported dynamic alloca
-define amdgpu_kernel void @test_dynamic_stackalloc(ptr addrspace(1) %out, i32 %n) {
+define amdgpu_kernel void @test_dynamic_stackalloc_kernel_uniform(i32 %n) {
%alloca = alloca i32, i32 %n, addrspace(5)
- store volatile i32 0, ptr addrspace(5) %alloca
+ store volatile i32 123, ptr addrspace(5) %alloca
+ ret void
+}
+
+; CHECK: in function test_dynamic_stackalloc{{.*}}: unsupported dynamic alloca
+
+define amdgpu_kernel void @test_dynamic_stackalloc_kernel_uniform_over_aligned(i32 %n) {
+ %alloca = alloca i32, i32 %n, align 128, addrspace(5)
+ store volatile i32 10, ptr addrspace(5) %alloca
+ ret void
+}
+
+; CHECK: in function test_dynamic_stackalloc{{.*}}: unsupported dynamic alloca
+
+define amdgpu_kernel void @test_dynamic_stackalloc_kernel_uniform_under_aligned(i32 %n) {
+ %alloca = alloca i32, i32 %n, align 2, addrspace(5)
+ store volatile i32 22, ptr addrspace(5) %alloca
+ ret void
+}
+
+; CHECK: in function test_dynamic_stackalloc{{.*}}: unsupported dynamic alloca
+
+define amdgpu_kernel void @test_dynamic_stackalloc_kernel_divergent() {
+ %idx = call i32 @llvm.amdgcn.workitem.id.x()
+ %alloca = alloca float, i32 %idx, addrspace(5)
+ store volatile i32 123, ptr addrspace(5) %alloca
+ ret void
+}
+
+; CHECK: in function test_dynamic_stackalloc{{.*}}: unsupported dynamic alloca
+
+define amdgpu_kernel void @test_dynamic_stackalloc_kernel_divergent_over_aligned() {
+ %idx = call i32 @llvm.amdgcn.workitem.id.x()
+ %alloca = alloca i32, i32 %idx, align 128, addrspace(5)
+ store volatile i32 444, ptr addrspace(5) %alloca
+ ret void
+}
+
+; CHECK: in function test_dynamic_stackalloc{{.*}}: unsupported dynamic alloca
+
+define amdgpu_kernel void @test_dynamic_stackalloc_kernel_divergent_under_aligned() {
+ %idx = call i32 @llvm.amdgcn.workitem.id.x()
+ %alloca = alloca i128, i32 %idx, align 2, addrspace(5)
+ store volatile i32 666, ptr addrspace(5) %alloca
+ ret void
+}
+
+; CHECK: in function test_dynamic_stackalloc{{.*}}: unsupported dynamic alloca
+; CHECK: in function test_dynamic_stackalloc{{.*}}: unsupported dynamic alloca
+; CHECK: in function test_dynamic_stackalloc{{.*}}: unsupported dynamic alloca
+
+define amdgpu_kernel void @test_dynamic_stackalloc_kernel_multiple_allocas(i32 %n, i32 %m) {
+entry:
+ %cond = icmp eq i32 %n, 0
+ %alloca1 = alloca i32, i32 8, addrspace(5)
+ %alloca2 = alloca i17, i32 %n, addrspace(5)
+ br i1 %cond, label %bb.0, label %bb.1
+bb.0:
+ %idx = call i32 @llvm.amdgcn.workitem.id.x()
+ %alloca3 = alloca i32, i32 %m, align 64, addrspace(5)
+ %alloca4 = alloca i32, i32 %idx, align 4, addrspace(5)
+ store volatile i32 3, ptr addrspace(5) %alloca3
+ store volatile i32 4, ptr addrspace(5) %alloca4
+ br label %bb.1
+bb.1:
+ store volatile i32 1, ptr addrspace(5) %alloca1
+ store volatile i32 2, ptr addrspace(5) %alloca2
+ ret void
+}
+
+; CHECK: in function test_dynamic_stackalloc{{.*}}: unsupported dynamic alloca
+; CHECK: in function test_dynamic_stackalloc{{.*}}: unsupported dynamic alloca
+
+define amdgpu_kernel void @test_dynamic_stackalloc_kernel_control_flow(i32 %n, i32 %m) {
+entry:
+ %cond = icmp eq i32 %n, 0
+ br i1 %cond, label %bb.0, label %bb.1
+bb.0:
+ %alloca2 = alloca i32, i32 %m, align 64, addrspace(5)
+ store volatile i32 2, ptr addrspace(5) %alloca2
+ br label %bb.2
+bb.1:
+ %idx = call i32 @llvm.amdgcn.workitem.id.x()
+ %alloca1 = alloca i32, i32 %idx, align 4, addrspace(5)
+ store volatile i32 1, ptr addrspace(5) %alloca1
+ br label %bb.2
+bb.2:
+ ret void
+}
+
+; CHECK: in function test_dynamic_stackalloc{{.*}}: unsupported dynamic alloca
+
+define void @test_dynamic_stackalloc_device_uniform(i32 %n) {
+ %alloca = alloca i32, i32 %n, addrspace(5)
+ store volatile i32 123, ptr addrspace(5) %alloca
+ ret void
+}
+
+; CHECK: in function test_dynamic_stackalloc{{.*}}: unsupported dynamic alloca
+
+define void @test_dynamic_stackalloc_device_uniform_over_aligned(i32 %n) {
+ %alloca = alloca i32, i32 %n, align 128, addrspace(5)
+ store volatile i32 10, ptr addrspace(5) %alloca
+ ret void
+}
+
+; CHECK: in function test_dynamic_stackalloc{{.*}}: unsupported dynamic alloca
+
+define void @test_dynamic_stackalloc_device_uniform_under_aligned(i32 %n) {
+ %alloca = alloca i32, i32 %n, align 2, addrspace(5)
+ store volatile i32 22, ptr addrspace(5) %alloca
+ ret void
+}
+
+; CHECK: in function test_dynamic_stackalloc{{.*}}: unsupported dynamic alloca
+
+define void @test_dynamic_stackalloc_device_divergent() {
+ %idx = call i32 @llvm.amdgcn.workitem.id.x()
+ %alloca = alloca i32, i32 %idx, addrspace(5)
+ store volatile i32 123, ptr addrspace(5) %alloca
+ ret void
+}
+
+; CHECK: in function test_dynamic_stackalloc{{.*}}: unsupported dynamic alloca
+
+define void @test_dynamic_stackalloc_device_divergent_over_aligned() {
+ %idx = call i32 @llvm.amdgcn.workitem.id.x()
+ %alloca = alloca i32, i32 %idx, align 128, addrspace(5)
+ store volatile i32 444, ptr addrspace(5) %alloca
+ ret void
+}
+
+; CHECK: in function test_dynamic_stackalloc{{.*}}: unsupported dynamic alloca
+
+define void @test_dynamic_stackalloc_device_divergent_under_aligned() {
+ %idx = call i32 @llvm.amdgcn.workitem.id.x()
+ %alloca = alloca i32, i32 %idx, align 2, addrspace(5)
+ store volatile i32 666, ptr addrspace(5) %alloca
+ ret void
+}
+
+; CHECK: in function test_dynamic_stackalloc{{.*}}: unsupported dynamic alloca
+; CHECK: in function test_dynamic_stackalloc{{.*}}: unsupported dynamic alloca
+; CHECK: in function test_dynamic_stackalloc{{.*}}: unsupported dynamic alloca
+
+define void @test_dynamic_stackalloc_device_multiple_allocas(i32 %n, i32 %m) {
+entry:
+ %cond = icmp eq i32 %n, 0
+ %alloca1 = alloca i32, i32 8, addrspace(5)
+ %alloca2 = alloca i32, i32 %n, addrspace(5)
+ br i1 %cond, label %bb.0, label %bb.1
+bb.0:
+ %idx = call i32 @llvm.amdgcn.workitem.id.x()
+ %alloca3 = alloca i32, i32 %m, align 64, addrspace(5)
+ %alloca4 = alloca i32, i32 %idx, align 4, addrspace(5)
+ store volatile i32 3, ptr addrspace(5) %alloca3
+ store volatile i32 4, ptr addrspace(5) %alloca4
+ br label %bb.1
+bb.1:
+ store volatile i32 1, ptr addrspace(5) %alloca1
+ store volatile i32 2, ptr addrspace(5) %alloca2
+ ret void
+}
+
+; CHECK: in function test_dynamic_stackalloc{{.*}}: unsupported dynamic alloca
+; CHECK: in function test_dynamic_stackalloc{{.*}}: unsupported dynamic alloca
+
+define void @test_dynamic_stackalloc_device_control_flow(i32 %n, i32 %m) {
+entry:
+ %cond = icmp eq i32 %n, 0
+ br i1 %cond, label %bb.0, label %bb.1
+bb.0:
+ %idx = call i32 @llvm.amdgcn.workitem.id.x()
+ %alloca1 = alloca i32, i32 %idx, align 4, addrspace(5)
+ store volatile i32 1, ptr addrspace(5) %alloca1
+ br label %bb.2
+bb.1:
+ %alloca2 = alloca i32, i32 %m, align 64, addrspace(5)
+ store volatile i32 2, ptr addrspace(5) %alloca2
+ br label %bb.2
+bb.2:
ret void
}
|
pravinjagtap
approved these changes
Dec 18, 2024
searlmc1
pushed a commit
to ROCm/llvm-project
that referenced
this pull request
Mar 24, 2025
…locas" (llvm#120410) This reapplies commit llvm#120063. A machine-verifier bug was causing a crash in the previous commit. This has been addressed in llvm#120393.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This reapplies commit #120063.
A machine-verifier bug was causing a crash in the previous commit.
This has been addressed in #120393.