diff --git a/llvm/lib/SYCLLowerIR/CompileTimePropertiesPass.cpp b/llvm/lib/SYCLLowerIR/CompileTimePropertiesPass.cpp index da14bc2772c61..32a476a8ac893 100644 --- a/llvm/lib/SYCLLowerIR/CompileTimePropertiesPass.cpp +++ b/llvm/lib/SYCLLowerIR/CompileTimePropertiesPass.cpp @@ -444,8 +444,10 @@ attributeToExecModeMetadata(const Attribute &Attr, Function &F) { // TODO: Remove SYCL_REGISTER_ALLOC_MODE_ATTR support in next ABI break. uint32_t PropVal = getAttributeAsInteger(Attr); if (AttrKindStr == SYCL_GRF_SIZE_ATTR) { - assert((PropVal == 0 || PropVal == 128 || PropVal == 256) && - "Unsupported GRF Size"); + // The RegisterAllocMode metadata supports only 0, 128, and 256 for + // PropVal. + if (PropVal != 0 && PropVal != 128 && PropVal != 256) + return std::nullopt; // Map sycl-grf-size values to RegisterAllocMode values used in SPIR-V. static constexpr int SMALL_GRF_REGALLOCMODE_VAL = 1; static constexpr int LARGE_GRF_REGALLOCMODE_VAL = 2; diff --git a/llvm/test/SYCLLowerIR/CompileTimePropertiesPass/sycl-grf-mode.ll b/llvm/test/SYCLLowerIR/CompileTimePropertiesPass/sycl-grf-mode.ll new file mode 100644 index 0000000000000..a5d491bb54db0 --- /dev/null +++ b/llvm/test/SYCLLowerIR/CompileTimePropertiesPass/sycl-grf-mode.ll @@ -0,0 +1,10 @@ +; Check we don't assert for different GRF values and don't add the RegisterAllocMode metadata +; RUN: opt -passes=compile-time-properties %s -S | FileCheck %s --implicit-check-not=RegisterAllocMode + +; CHECK: spir_kernel void @foo() +define weak_odr dso_local spir_kernel void @foo() #0 { +entry: + ret void +} + +attributes #0 = { convergent mustprogress norecurse nounwind "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "sycl-grf-size"="16384" "sycl-module-id"="main.cpp" "sycl-optlevel"="2" "uniform-work-group-size"="true" }