Skip to content
This repository was archived by the owner on Apr 23, 2021. It is now read-only.

Commit 32b81a8

Browse files
Mahesh Ravishankartensorflower-gardener
authored andcommitted
Use operand number during serialization to get the <id>s of the operands
During serialization, the operand number must be used to get the values assocaited with an operand. Using the argument number in Op specification was wrong since some of the elements in the arguments list might be attributes on the operation. This resulted in a segfault during serialization. Add a test that exercise that path. PiperOrigin-RevId: 260977758
1 parent 4ca0e2c commit 32b81a8

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// RUN: mlir-translate -serialize-spirv %s | mlir-translate -deserialize-spirv | FileCheck %s
2+
3+
func @spirv_variables() -> () {
4+
spv.module "Logical" "VulkanKHR" {
5+
// CHECK: [[INIT:%.*]] = spv.constant 4.000000e+00 : f32
6+
// CHECK: {{%.*}} = spv.Variable init([[INIT]]) bind(1, 0) : !spv.ptr<f32, Input>
7+
%0 = spv.constant 4.0 : f32
8+
%2 = spv.Variable init(%0) bind(1, 0) : !spv.ptr<f32, Input>
9+
}
10+
return
11+
}

tools/mlir-tblgen/SPIRVUtilsGen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ static void emitSerializationFunction(const Record *attrClass,
130130
auto argument = op.getArg(i);
131131
os << " {\n";
132132
if (argument.is<NamedTypeConstraint *>()) {
133-
os << " for (auto arg : op.getODSOperands(" << i << ")) {\n";
133+
os << " for (auto arg : op.getODSOperands(" << operandNum << ")) {\n";
134134
os << " auto argID = findValueID(arg);\n";
135135
os << " if (!argID) {\n";
136136
os << " emitError(op.getLoc(), \"operand " << operandNum

0 commit comments

Comments
 (0)