[Mlir-commits] [mlir] 04b524f - [mlir][SPIR-V] Serialize decorations on FunctionCall results (#233917)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Tue Oct 20 20:15:19 PDT 2026
Author: Arseniy Obolenskiy
Date: 2026-10-21T05:15:14+02:00
New Revision: 04b524ff69b928535c7ef7d995958e2f5e825b13
URL: https://github.com/llvm/llvm-project/commit/04b524ff69b928535c7ef7d995958e2f5e825b13
DIFF: https://github.com/llvm/llvm-project/commit/04b524ff69b928535c7ef7d995958e2f5e825b13.diff
LOG: [mlir][SPIR-V] Serialize decorations on FunctionCall results (#233917)
Decorations such as RelaxedPrecision on an OpFunctionCall result were
dropped in both directions (serialize/deserialize)
---------
Co-authored-by: Igor Wodiany <dev at wodiany.com>
Added:
Modified:
mlir/lib/Target/SPIRV/Deserialization/DeserializeOps.cpp
mlir/lib/Target/SPIRV/Serialization/SerializeOps.cpp
mlir/test/Target/SPIRV/function-call.mlir
Removed:
################################################################################
diff --git a/mlir/lib/Target/SPIRV/Deserialization/DeserializeOps.cpp b/mlir/lib/Target/SPIRV/Deserialization/DeserializeOps.cpp
index acb43b6e04bd67..22837177494fae 100644
--- a/mlir/lib/Target/SPIRV/Deserialization/DeserializeOps.cpp
+++ b/mlir/lib/Target/SPIRV/Deserialization/DeserializeOps.cpp
@@ -674,6 +674,10 @@ Deserializer::processOp<spirv::FunctionCallOp>(ArrayRef<uint32_t> operands) {
opBuilder, unknownLoc, resultType,
SymbolRefAttr::get(opBuilder.getContext(), functionName), arguments);
+ if (auto it = decorations.find(resultID); it != decorations.end())
+ for (NamedAttribute attr : it->second)
+ opFunctionCall->setAttr(attr.getName(), attr.getValue());
+
if (resultType)
valueMap[resultID] = opFunctionCall.getResult(0);
return success();
diff --git a/mlir/lib/Target/SPIRV/Serialization/SerializeOps.cpp b/mlir/lib/Target/SPIRV/Serialization/SerializeOps.cpp
index da311c386a3242..c450be92794c7a 100644
--- a/mlir/lib/Target/SPIRV/Serialization/SerializeOps.cpp
+++ b/mlir/lib/Target/SPIRV/Serialization/SerializeOps.cpp
@@ -1114,6 +1114,9 @@ Serializer::processOp<spirv::FunctionCallOp>(spirv::FunctionCallOp op) {
valueIDMap[op.getResult(0)] = funcCallID;
encodeInstructionInto(functionBody, spirv::Opcode::OpFunctionCall, operands);
+ for (auto attr : op->getDiscardableAttrs())
+ if (failed(processDecoration(op.getLoc(), funcCallID, attr)))
+ return failure();
return success();
}
diff --git a/mlir/test/Target/SPIRV/function-call.mlir b/mlir/test/Target/SPIRV/function-call.mlir
index 2e94ded3401ceb..5ece0029fec84b 100644
--- a/mlir/test/Target/SPIRV/function-call.mlir
+++ b/mlir/test/Target/SPIRV/function-call.mlir
@@ -1,4 +1,4 @@
-// RUN: mlir-translate -no-implicit-module -test-spirv-roundtrip %s | FileCheck %s
+// RUN: mlir-translate --no-implicit-module --split-input-file --test-spirv-roundtrip %s | FileCheck %s
// RUN: %if spirv-tools %{ rm -rf %t %}
// RUN: %if spirv-tools %{ mkdir %t %}
@@ -56,3 +56,24 @@ spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader, VariablePointers
spirv.Return
}
}
+
+// -----
+
+spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader, Linkage], []> {
+ spirv.func @callee() -> f32 "None" {
+ %0 = spirv.Constant 1.0 : f32
+ spirv.ReturnValue %0 : f32
+ }
+ // CHECK-LABEL: spirv.func @call_decorated
+ spirv.func @call_decorated() -> f32 "None" {
+ // CHECK: spirv.FunctionCall @callee() {relaxed_precision} : () -> f32
+ %0 = spirv.FunctionCall @callee() {relaxed_precision} : () -> f32
+ spirv.ReturnValue %0 : f32
+ }
+ // CHECK-LABEL: spirv.func @call_multi_decorated
+ spirv.func @call_multi_decorated() -> f32 "None" {
+ // CHECK: spirv.FunctionCall @callee() {no_contraction, relaxed_precision} : () -> f32
+ %0 = spirv.FunctionCall @callee() {no_contraction, relaxed_precision} : () -> f32
+ spirv.ReturnValue %0 : f32
+ }
+}
More information about the Mlir-commits
mailing list