[llvm] ed155ff - AMDGPU: Avoid report_fatal_error on ds ordered intrinsics (#145202)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Jun 22 21:09:12 PDT 2025
Author: Matt Arsenault
Date: 2025-06-23T13:09:09+09:00
New Revision: ed155ff9f25c0f0c9fcdfaae42db8423dc24a208
URL: https://github.com/llvm/llvm-project/commit/ed155ff9f25c0f0c9fcdfaae42db8423dc24a208
DIFF: https://github.com/llvm/llvm-project/commit/ed155ff9f25c0f0c9fcdfaae42db8423dc24a208.diff
LOG: AMDGPU: Avoid report_fatal_error on ds ordered intrinsics (#145202)
Added:
llvm/test/CodeGen/AMDGPU/llvm.amdgcn.ds.ordered.add-errors.ll
Modified:
llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp
llvm/lib/Target/AMDGPU/SIISelLowering.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp b/llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp
index 672520390c8bf..b632b16f5c198 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp
@@ -1767,8 +1767,12 @@ bool AMDGPUInstructionSelector::selectDSOrderedIntrinsic(
bool WaveRelease = MI.getOperand(8).getImm() != 0;
bool WaveDone = MI.getOperand(9).getImm() != 0;
- if (WaveDone && !WaveRelease)
- report_fatal_error("ds_ordered_count: wave_done requires wave_release");
+ if (WaveDone && !WaveRelease) {
+ // TODO: Move this to IR verifier
+ const Function &Fn = MF->getFunction();
+ Fn.getContext().diagnose(DiagnosticInfoUnsupported(
+ Fn, "ds_ordered_count: wave_done requires wave_release", DL));
+ }
unsigned OrderedCountIndex = IndexOperand & 0x3f;
IndexOperand &= ~0x3f;
@@ -1779,13 +1783,18 @@ bool AMDGPUInstructionSelector::selectDSOrderedIntrinsic(
IndexOperand &= ~(0xf << 24);
if (CountDw < 1 || CountDw > 4) {
- report_fatal_error(
- "ds_ordered_count: dword count must be between 1 and 4");
+ const Function &Fn = MF->getFunction();
+ Fn.getContext().diagnose(DiagnosticInfoUnsupported(
+ Fn, "ds_ordered_count: dword count must be between 1 and 4", DL));
+ CountDw = 1;
}
}
- if (IndexOperand)
- report_fatal_error("ds_ordered_count: bad index operand");
+ if (IndexOperand) {
+ const Function &Fn = MF->getFunction();
+ Fn.getContext().diagnose(DiagnosticInfoUnsupported(
+ Fn, "ds_ordered_count: bad index operand", DL));
+ }
unsigned Instruction = IntrID == Intrinsic::amdgcn_ds_ordered_add ? 0 : 1;
unsigned ShaderType = SIInstrInfo::getDSShaderTypeValue(*MF);
diff --git a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
index 6f37e2dd3aa7e..931a6363e74e8 100644
--- a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
+++ b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
@@ -9330,16 +9330,27 @@ SDValue SITargetLowering::LowerINTRINSIC_W_CHAIN(SDValue Op,
IndexOperand &= ~(0xf << 24);
if (CountDw < 1 || CountDw > 4) {
- report_fatal_error(
- "ds_ordered_count: dword count must be between 1 and 4");
+ const Function &Fn = DAG.getMachineFunction().getFunction();
+ DAG.getContext()->diagnose(DiagnosticInfoUnsupported(
+ Fn, "ds_ordered_count: dword count must be between 1 and 4",
+ DL.getDebugLoc()));
+ CountDw = 1;
}
}
- if (IndexOperand)
- report_fatal_error("ds_ordered_count: bad index operand");
+ if (IndexOperand) {
+ const Function &Fn = DAG.getMachineFunction().getFunction();
+ DAG.getContext()->diagnose(DiagnosticInfoUnsupported(
+ Fn, "ds_ordered_count: bad index operand", DL.getDebugLoc()));
+ }
- if (WaveDone && !WaveRelease)
- report_fatal_error("ds_ordered_count: wave_done requires wave_release");
+ if (WaveDone && !WaveRelease) {
+ // TODO: Move this to IR verifier
+ const Function &Fn = DAG.getMachineFunction().getFunction();
+ DAG.getContext()->diagnose(DiagnosticInfoUnsupported(
+ Fn, "ds_ordered_count: wave_done requires wave_release",
+ DL.getDebugLoc()));
+ }
unsigned Instruction = IntrID == Intrinsic::amdgcn_ds_ordered_add ? 0 : 1;
unsigned ShaderType =
diff --git a/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.ds.ordered.add-errors.ll b/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.ds.ordered.add-errors.ll
new file mode 100644
index 0000000000000..36b13e3b16cc6
--- /dev/null
+++ b/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.ds.ordered.add-errors.ll
@@ -0,0 +1,30 @@
+; RUN: not llc -global-isel=0 -mtriple=amdgcn -mcpu=gfx1010 -filetype=null %s 2>&1 | FileCheck %s
+; RUN: not llc -global-isel=1 -mtriple=amdgcn -mcpu=gfx1010 -filetype=null %s 2>&1 | FileCheck %s
+
+; CHECK: error: <unknown>:0:0: in function ds_ordered_add_dword_count_too_low void (ptr addrspace(2), ptr addrspace(1)): ds_ordered_count: dword count must be between 1 and 4
+define amdgpu_kernel void @ds_ordered_add_dword_count_too_low(ptr addrspace(2) inreg %gds, ptr addrspace(1) %out) {
+ %val = call i32 @llvm.amdgcn.ds.ordered.add(ptr addrspace(2) %gds, i32 31, i32 0, i32 0, i1 false, i32 0, i1 true, i1 true)
+ store i32 %val, ptr addrspace(1) %out
+ ret void
+}
+
+; CHECK: error: <unknown>:0:0: in function ds_ordered_add_dword_count_too_high void (ptr addrspace(2), ptr addrspace(1)): ds_ordered_count: dword count must be between 1 and 4
+define amdgpu_kernel void @ds_ordered_add_dword_count_too_high(ptr addrspace(2) inreg %gds, ptr addrspace(1) %out) {
+ %val = call i32 @llvm.amdgcn.ds.ordered.add(ptr addrspace(2) %gds, i32 31, i32 0, i32 0, i1 false, i32 5, i1 true, i1 true)
+ store i32 %val, ptr addrspace(1) %out
+ ret void
+}
+
+; CHECK: error: <unknown>:0:0: in function ds_ordered_add_bad_index_operand void (ptr addrspace(2), ptr addrspace(1)): ds_ordered_count: bad index operand
+define amdgpu_kernel void @ds_ordered_add_bad_index_operand(ptr addrspace(2) inreg %gds, ptr addrspace(1) %out) {
+ %val = call i32 @llvm.amdgcn.ds.ordered.add(ptr addrspace(2) %gds, i32 31, i32 0, i32 1, i1 false, i32 -1, i1 true, i1 true)
+ store i32 %val, ptr addrspace(1) %out
+ ret void
+}
+
+; CHECK: error: <unknown>:0:0: in function ds_ordered_add_dword_count_wave_done_without_wave_release void (ptr addrspace(2), ptr addrspace(1)): ds_ordered_count: wave_done requires wave_release
+define amdgpu_kernel void @ds_ordered_add_dword_count_wave_done_without_wave_release(ptr addrspace(2) inreg %gds, ptr addrspace(1) %out) {
+ %val = call i32 @llvm.amdgcn.ds.ordered.add(ptr addrspace(2) %gds, i32 31, i32 0, i32 0, i1 false, i32 1, i1 false, i1 true)
+ store i32 %val, ptr addrspace(1) %out
+ ret void
+}
More information about the llvm-commits
mailing list