Files
TheRock/compiler/amd-llvm/llvm/test/CodeGen/AMDGPU/cc-inreg-sgpr0-3-mismatch.ll
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

237 lines
9.8 KiB
LLVM

; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc -global-isel=0 -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 < %s | FileCheck -check-prefix=SDAG %s
; RUN: llc -global-isel=1 -new-reg-bank-select -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 < %s | FileCheck -check-prefix=GISEL %s
; Test for a caller/callee mismatch in SGPR assignment for inreg args.
;
; The following test case demonstrates the bug with a function that takes 32
; inreg i32 arguments and returns the first one. In the callee, arg 0 is read
; from s16 (v_mov_b32_e32 v0, s16). In the caller, arg 0 (value 42) is written
; to s0 (s_mov_b32 s0, 42). Since s0 != s16, the callee does not see the value
; the caller intended to pass.
;
; The root cause is that the scratch resource descriptor occupies SGPR0-3. On
; the callee side, LowerFormalArguments marks SGPR0-3 as allocated in CCState
; before running the CC analysis, so CC_AMDGPU_Func skips them. On the caller
; side, LowerCall adds the scratch resource to RegsToPass without marking
; SGPR0-3 in CCState, so CC_AMDGPU_Func treats them as available and assigns
; user inreg args there.
define i32 @callee_returns_arg0(
; CHECK-LABEL: callee_returns_arg0:
; CHECK: ; %bb.0:
; CHECK-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
; CHECK-NEXT: v_mov_b32_e32 v0, s16
; CHECK-NEXT: s_setpc_b64 s[30:31]
; SDAG-LABEL: callee_returns_arg0:
; SDAG: ; %bb.0:
; SDAG-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
; SDAG-NEXT: v_mov_b32_e32 v0, s16
; SDAG-NEXT: s_setpc_b64 s[30:31]
;
; GISEL-LABEL: callee_returns_arg0:
; GISEL: ; %bb.0:
; GISEL-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
; GISEL-NEXT: v_mov_b32_e32 v0, s16
; GISEL-NEXT: s_setpc_b64 s[30:31]
i32 inreg %a0, i32 inreg %a1, i32 inreg %a2, i32 inreg %a3,
i32 inreg %a4, i32 inreg %a5, i32 inreg %a6, i32 inreg %a7,
i32 inreg %a8, i32 inreg %a9, i32 inreg %a10, i32 inreg %a11,
i32 inreg %a12, i32 inreg %a13, i32 inreg %a14, i32 inreg %a15,
i32 inreg %a16, i32 inreg %a17, i32 inreg %a18, i32 inreg %a19,
i32 inreg %a20, i32 inreg %a21, i32 inreg %a22, i32 inreg %a23,
i32 inreg %a24, i32 inreg %a25, i32 inreg %a26, i32 inreg %a27,
i32 inreg %a28, i32 inreg %a29, i32 inreg %a30, i32 inreg %a31) #0 {
ret i32 %a0
}
define i32 @caller_passes_42() #0 {
; CHECK-LABEL: caller_passes_42:
; CHECK: ; %bb.0:
; CHECK-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
; CHECK-NEXT: s_mov_b32 s42, s33
; CHECK-NEXT: s_mov_b32 s33, s32
; CHECK-NEXT: s_xor_saveexec_b64 s[16:17], -1
; CHECK-NEXT: buffer_store_dword v18, off, s[0:3], s33 ; 4-byte Folded Spill
; CHECK-NEXT: s_mov_b64 exec, s[16:17]
; CHECK-NEXT: s_addk_i32 s32, 0x400
; CHECK-NEXT: s_getpc_b64 s[16:17]
; CHECK-NEXT: s_add_u32 s16, s16, callee_returns_arg0@gotpcrel32@lo+4
; CHECK-NEXT: s_addc_u32 s17, s17, callee_returns_arg0@gotpcrel32@hi+12
; CHECK-NEXT: s_load_dwordx2 s[40:41], s[16:17], 0x0
; CHECK-NEXT: v_writelane_b32 v18, s30, 0
; CHECK-NEXT: s_mov_b32 s16, 42
; CHECK-NEXT: s_mov_b32 s17, 1
; CHECK-NEXT: s_mov_b32 s18, 2
; CHECK-NEXT: s_mov_b32 s19, 3
; CHECK-NEXT: s_mov_b32 s20, 4
; CHECK-NEXT: s_mov_b32 s21, 5
; CHECK-NEXT: s_mov_b32 s22, 6
; CHECK-NEXT: s_mov_b32 s23, 7
; CHECK-NEXT: s_mov_b32 s24, 8
; CHECK-NEXT: s_mov_b32 s25, 9
; CHECK-NEXT: s_mov_b32 s26, 10
; CHECK-NEXT: s_mov_b32 s27, 11
; CHECK-NEXT: s_mov_b32 s28, 12
; CHECK-NEXT: s_mov_b32 s29, 13
; CHECK-NEXT: v_mov_b32_e32 v0, 14
; CHECK-NEXT: v_mov_b32_e32 v1, 15
; CHECK-NEXT: v_mov_b32_e32 v2, 16
; CHECK-NEXT: v_mov_b32_e32 v3, 17
; CHECK-NEXT: v_mov_b32_e32 v4, 18
; CHECK-NEXT: v_mov_b32_e32 v5, 19
; CHECK-NEXT: v_mov_b32_e32 v6, 20
; CHECK-NEXT: v_mov_b32_e32 v7, 21
; CHECK-NEXT: v_mov_b32_e32 v8, 22
; CHECK-NEXT: v_mov_b32_e32 v9, 23
; CHECK-NEXT: v_mov_b32_e32 v10, 24
; CHECK-NEXT: v_mov_b32_e32 v11, 25
; CHECK-NEXT: v_mov_b32_e32 v12, 26
; CHECK-NEXT: v_mov_b32_e32 v13, 27
; CHECK-NEXT: v_mov_b32_e32 v14, 28
; CHECK-NEXT: v_mov_b32_e32 v15, 29
; CHECK-NEXT: v_mov_b32_e32 v16, 30
; CHECK-NEXT: v_mov_b32_e32 v17, 31
; CHECK-NEXT: v_writelane_b32 v18, s31, 1
; CHECK-NEXT: s_waitcnt lgkmcnt(0)
; CHECK-NEXT: s_swappc_b64 s[30:31], s[40:41]
; CHECK-NEXT: v_readlane_b32 s31, v18, 1
; CHECK-NEXT: v_readlane_b32 s30, v18, 0
; CHECK-NEXT: s_mov_b32 s32, s33
; CHECK-NEXT: s_xor_saveexec_b64 s[4:5], -1
; CHECK-NEXT: buffer_load_dword v18, off, s[0:3], s33 ; 4-byte Folded Reload
; CHECK-NEXT: s_mov_b64 exec, s[4:5]
; CHECK-NEXT: s_mov_b32 s33, s42
; CHECK-NEXT: s_waitcnt vmcnt(0)
; CHECK-NEXT: s_setpc_b64 s[30:31]
; SDAG-LABEL: caller_passes_42:
; SDAG: ; %bb.0:
; SDAG-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
; SDAG-NEXT: s_mov_b32 s42, s33
; SDAG-NEXT: s_mov_b32 s33, s32
; SDAG-NEXT: s_xor_saveexec_b64 s[16:17], -1
; SDAG-NEXT: buffer_store_dword v18, off, s[0:3], s33 ; 4-byte Folded Spill
; SDAG-NEXT: s_mov_b64 exec, s[16:17]
; SDAG-NEXT: v_writelane_b32 v18, s30, 0
; SDAG-NEXT: s_addk_i32 s32, 0x400
; SDAG-NEXT: v_writelane_b32 v18, s31, 1
; SDAG-NEXT: s_getpc_b64 s[16:17]
; SDAG-NEXT: s_add_u32 s16, s16, callee_returns_arg0@gotpcrel32@lo+4
; SDAG-NEXT: s_addc_u32 s17, s17, callee_returns_arg0@gotpcrel32@hi+12
; SDAG-NEXT: s_load_dwordx2 s[40:41], s[16:17], 0x0
; SDAG-NEXT: s_mov_b32 s16, 42
; SDAG-NEXT: s_mov_b32 s17, 1
; SDAG-NEXT: s_mov_b32 s18, 2
; SDAG-NEXT: s_mov_b32 s19, 3
; SDAG-NEXT: s_mov_b32 s20, 4
; SDAG-NEXT: s_mov_b32 s21, 5
; SDAG-NEXT: s_mov_b32 s22, 6
; SDAG-NEXT: s_mov_b32 s23, 7
; SDAG-NEXT: s_mov_b32 s24, 8
; SDAG-NEXT: s_mov_b32 s25, 9
; SDAG-NEXT: s_mov_b32 s26, 10
; SDAG-NEXT: s_mov_b32 s27, 11
; SDAG-NEXT: s_mov_b32 s28, 12
; SDAG-NEXT: s_mov_b32 s29, 13
; SDAG-NEXT: v_mov_b32_e32 v0, 14
; SDAG-NEXT: v_mov_b32_e32 v1, 15
; SDAG-NEXT: v_mov_b32_e32 v2, 16
; SDAG-NEXT: v_mov_b32_e32 v3, 17
; SDAG-NEXT: v_mov_b32_e32 v4, 18
; SDAG-NEXT: v_mov_b32_e32 v5, 19
; SDAG-NEXT: v_mov_b32_e32 v6, 20
; SDAG-NEXT: v_mov_b32_e32 v7, 21
; SDAG-NEXT: v_mov_b32_e32 v8, 22
; SDAG-NEXT: v_mov_b32_e32 v9, 23
; SDAG-NEXT: v_mov_b32_e32 v10, 24
; SDAG-NEXT: v_mov_b32_e32 v11, 25
; SDAG-NEXT: v_mov_b32_e32 v12, 26
; SDAG-NEXT: v_mov_b32_e32 v13, 27
; SDAG-NEXT: v_mov_b32_e32 v14, 28
; SDAG-NEXT: v_mov_b32_e32 v15, 29
; SDAG-NEXT: v_mov_b32_e32 v16, 30
; SDAG-NEXT: v_mov_b32_e32 v17, 31
; SDAG-NEXT: s_waitcnt lgkmcnt(0)
; SDAG-NEXT: s_swappc_b64 s[30:31], s[40:41]
; SDAG-NEXT: v_readlane_b32 s30, v18, 0
; SDAG-NEXT: v_readlane_b32 s31, v18, 1
; SDAG-NEXT: s_mov_b32 s32, s33
; SDAG-NEXT: s_xor_saveexec_b64 s[4:5], -1
; SDAG-NEXT: buffer_load_dword v18, off, s[0:3], s33 ; 4-byte Folded Reload
; SDAG-NEXT: s_mov_b64 exec, s[4:5]
; SDAG-NEXT: s_mov_b32 s33, s42
; SDAG-NEXT: s_waitcnt vmcnt(0)
; SDAG-NEXT: s_setpc_b64 s[30:31]
;
; GISEL-LABEL: caller_passes_42:
; GISEL: ; %bb.0:
; GISEL-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
; GISEL-NEXT: s_mov_b32 s42, s33
; GISEL-NEXT: s_mov_b32 s33, s32
; GISEL-NEXT: s_xor_saveexec_b64 s[16:17], -1
; GISEL-NEXT: buffer_store_dword v18, off, s[0:3], s33 ; 4-byte Folded Spill
; GISEL-NEXT: s_mov_b64 exec, s[16:17]
; GISEL-NEXT: v_writelane_b32 v18, s30, 0
; GISEL-NEXT: s_addk_i32 s32, 0x400
; GISEL-NEXT: v_writelane_b32 v18, s31, 1
; GISEL-NEXT: s_getpc_b64 s[16:17]
; GISEL-NEXT: s_add_u32 s16, s16, callee_returns_arg0@gotpcrel32@lo+4
; GISEL-NEXT: s_addc_u32 s17, s17, callee_returns_arg0@gotpcrel32@hi+12
; GISEL-NEXT: s_load_dwordx2 s[40:41], s[16:17], 0x0
; GISEL-NEXT: s_mov_b32 s16, 42
; GISEL-NEXT: s_mov_b32 s17, 1
; GISEL-NEXT: s_mov_b32 s18, 2
; GISEL-NEXT: s_mov_b32 s19, 3
; GISEL-NEXT: s_mov_b32 s20, 4
; GISEL-NEXT: s_mov_b32 s21, 5
; GISEL-NEXT: s_mov_b32 s22, 6
; GISEL-NEXT: s_mov_b32 s23, 7
; GISEL-NEXT: s_mov_b32 s24, 8
; GISEL-NEXT: s_mov_b32 s25, 9
; GISEL-NEXT: s_mov_b32 s26, 10
; GISEL-NEXT: s_mov_b32 s27, 11
; GISEL-NEXT: s_mov_b32 s28, 12
; GISEL-NEXT: s_mov_b32 s29, 13
; GISEL-NEXT: v_mov_b32_e32 v0, 14
; GISEL-NEXT: v_mov_b32_e32 v1, 15
; GISEL-NEXT: v_mov_b32_e32 v2, 16
; GISEL-NEXT: v_mov_b32_e32 v3, 17
; GISEL-NEXT: v_mov_b32_e32 v4, 18
; GISEL-NEXT: v_mov_b32_e32 v5, 19
; GISEL-NEXT: v_mov_b32_e32 v6, 20
; GISEL-NEXT: v_mov_b32_e32 v7, 21
; GISEL-NEXT: v_mov_b32_e32 v8, 22
; GISEL-NEXT: v_mov_b32_e32 v9, 23
; GISEL-NEXT: v_mov_b32_e32 v10, 24
; GISEL-NEXT: v_mov_b32_e32 v11, 25
; GISEL-NEXT: v_mov_b32_e32 v12, 26
; GISEL-NEXT: v_mov_b32_e32 v13, 27
; GISEL-NEXT: v_mov_b32_e32 v14, 28
; GISEL-NEXT: v_mov_b32_e32 v15, 29
; GISEL-NEXT: v_mov_b32_e32 v16, 30
; GISEL-NEXT: v_mov_b32_e32 v17, 31
; GISEL-NEXT: s_waitcnt lgkmcnt(0)
; GISEL-NEXT: s_swappc_b64 s[30:31], s[40:41]
; GISEL-NEXT: v_readlane_b32 s30, v18, 0
; GISEL-NEXT: v_readlane_b32 s31, v18, 1
; GISEL-NEXT: s_mov_b32 s32, s33
; GISEL-NEXT: s_xor_saveexec_b64 s[4:5], -1
; GISEL-NEXT: buffer_load_dword v18, off, s[0:3], s33 ; 4-byte Folded Reload
; GISEL-NEXT: s_mov_b64 exec, s[4:5]
; GISEL-NEXT: s_mov_b32 s33, s42
; GISEL-NEXT: s_waitcnt vmcnt(0)
; GISEL-NEXT: s_setpc_b64 s[30:31]
%r = call i32 @callee_returns_arg0(
i32 inreg 42, i32 inreg 1, i32 inreg 2, i32 inreg 3,
i32 inreg 4, i32 inreg 5, i32 inreg 6, i32 inreg 7,
i32 inreg 8, i32 inreg 9, i32 inreg 10, i32 inreg 11,
i32 inreg 12, i32 inreg 13, i32 inreg 14, i32 inreg 15,
i32 inreg 16, i32 inreg 17, i32 inreg 18, i32 inreg 19,
i32 inreg 20, i32 inreg 21, i32 inreg 22, i32 inreg 23,
i32 inreg 24, i32 inreg 25, i32 inreg 26, i32 inreg 27,
i32 inreg 28, i32 inreg 29, i32 inreg 30, i32 inreg 31)
ret i32 %r
}
attributes #0 = { nounwind }