Index: lib/Target/AMDGPU/SIISelLowering.cpp =================================================================== --- lib/Target/AMDGPU/SIISelLowering.cpp +++ lib/Target/AMDGPU/SIISelLowering.cpp @@ -21,6 +21,7 @@ #include "SIISelLowering.h" #include "SIInstrInfo.h" #include "AMDGPU.h" +#include "AMDGPUDiagnosticInfoUnsupported.h" #include "AMDGPUIntrinsicInfo.h" #include "AMDGPUSubtarget.h" #include "SIInstrInfo.h" @@ -515,6 +516,13 @@ SIMachineFunctionInfo *Info = MF.getInfo(); const AMDGPUSubtarget &ST = MF.getSubtarget(); + if (ST.isAmdHsaOS() && Info->getShaderType() != ShaderType::COMPUTE) { + const Function *Fn = MF.getFunction(); + DiagnosticInfoUnsupported NoGraphicsHSA(*Fn, "non-compute shaders with HSA"); + DAG.getContext()->diagnose(NoGraphicsHSA); + return SDValue(); + } + // FIXME: We currently assume all calling conventions are kernels. SmallVector Splits; Index: test/CodeGen/AMDGPU/no-hsa-graphics-shaders.ll =================================================================== --- /dev/null +++ test/CodeGen/AMDGPU/no-hsa-graphics-shaders.ll @@ -0,0 +1,18 @@ +; RUN: not llc -march=amdgcn -mtriple=amdgcn-unknown-amdhsa < %s 2>&1 | FileCheck %s + +; CHECK: error: unsupported non-compute shaders with HSA in pixel_shader +define void @pixel_shader() #0 { + ret void +} + +define void @vertex_shader() #1 { + ret void +} + +define void @geometry_shader() #2 { + ret void +} + +attributes #0 = { nounwind "ShaderType"="0" } +attributes #1 = { nounwind "ShaderType"="1" } +attributes #2 = { nounwind "ShaderType"="2" }