[llvm] 574243d - [SPIR-V] Emit missing Sext function parameter decoration for signext args and test other param decorations (#200801)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 2 05:46:00 PDT 2026
Author: Arseniy Obolenskiy
Date: 2026-06-02T14:45:55+02:00
New Revision: 574243d7fad23da3532699caf0eadf36dfc321d8
URL: https://github.com/llvm/llvm-project/commit/574243d7fad23da3532699caf0eadf36dfc321d8
DIFF: https://github.com/llvm/llvm-project/commit/574243d7fad23da3532699caf0eadf36dfc321d8.diff
LOG: [SPIR-V] Emit missing Sext function parameter decoration for signext args and test other param decorations (#200801)
Added:
llvm/test/CodeGen/SPIRV/transcoding/func_param_attr.ll
Modified:
llvm/lib/Target/SPIRV/SPIRVCallLowering.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/SPIRV/SPIRVCallLowering.cpp b/llvm/lib/Target/SPIRV/SPIRVCallLowering.cpp
index 14c33b5190f5e..6e516b08fab5b 100644
--- a/llvm/lib/Target/SPIRV/SPIRVCallLowering.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVCallLowering.cpp
@@ -301,6 +301,12 @@ bool SPIRVCallLowering::lowerFormalArguments(MachineIRBuilder &MIRBuilder,
buildOpDecorate(VRegs[i][0], MIRBuilder,
SPIRV::Decoration::FuncParamAttr, {Attr});
}
+ if (Arg.hasAttribute(Attribute::SExt)) {
+ auto Attr =
+ static_cast<unsigned>(SPIRV::FunctionParameterAttribute::Sext);
+ buildOpDecorate(VRegs[i][0], MIRBuilder,
+ SPIRV::Decoration::FuncParamAttr, {Attr});
+ }
if (Arg.hasAttribute(Attribute::NoAlias)) {
auto Attr =
static_cast<unsigned>(SPIRV::FunctionParameterAttribute::NoAlias);
diff --git a/llvm/test/CodeGen/SPIRV/transcoding/func_param_attr.ll b/llvm/test/CodeGen/SPIRV/transcoding/func_param_attr.ll
new file mode 100644
index 0000000000000..e158477a3627c
--- /dev/null
+++ b/llvm/test/CodeGen/SPIRV/transcoding/func_param_attr.ll
@@ -0,0 +1,45 @@
+; RUN: llc -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV
+; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown %s -o - -filetype=obj | spirv-val %}
+
+; CHECK-SPIRV-DAG: OpDecorate %[[#ZEXT:]] FuncParamAttr Zext
+; CHECK-SPIRV-DAG: OpDecorate %[[#SEXT:]] FuncParamAttr Sext
+; CHECK-SPIRV-DAG: OpDecorate %[[#NOWRITE:]] FuncParamAttr NoWrite
+; CHECK-SPIRV-DAG: OpDecorate %[[#NOALIAS:]] FuncParamAttr NoAlias
+; CHECK-SPIRV-DAG: OpDecorate %[[#BYVAL:]] FuncParamAttr ByVal
+; CHECK-SPIRV-DAG: OpDecorate %[[#SRET:]] FuncParamAttr Sret
+
+; CHECK-SPIRV: %[[#ZEXT]] = OpFunctionParameter %[[#]]
+define spir_func void @test_zext(i8 zeroext %arg) {
+entry:
+ ret void
+}
+
+; CHECK-SPIRV: %[[#SEXT]] = OpFunctionParameter %[[#]]
+define spir_func void @test_sext(i8 signext %arg) {
+entry:
+ ret void
+}
+
+; CHECK-SPIRV: %[[#NOWRITE]] = OpFunctionParameter %[[#]]
+define spir_func void @test_readonly(ptr readonly %arg) {
+entry:
+ ret void
+}
+
+; CHECK-SPIRV: %[[#NOALIAS]] = OpFunctionParameter %[[#]]
+define spir_func void @test_noalias(ptr noalias %arg) {
+entry:
+ ret void
+}
+
+; CHECK-SPIRV: %[[#BYVAL]] = OpFunctionParameter %[[#]]
+define spir_func void @test_byval(ptr byval(i32) %arg) {
+entry:
+ ret void
+}
+
+; CHECK-SPIRV: %[[#SRET]] = OpFunctionParameter %[[#]]
+define spir_func void @test_sret(ptr sret(i32) %arg) {
+entry:
+ ret void
+}
More information about the llvm-commits
mailing list