Skip to content

spirv-opt module builder injects extra OpLine instructions that don't exist on the input #4029

@dneto0

Description

@dneto0

This is a consequence of #3951

This breaks some line number attribution in Tint, and breaks one of its tests.

Here's the sample SPIR-V assembly:

OpCapability Shader
OpMemoryModel Logical Simple
OpEntryPoint GLCompute %2 "main"
OpExecutionMode %2 LocalSize 1 1 1
%15 = OpString "myfile"
%void = OpTypeVoid
%4 = OpTypeFunction %void
OpLine %15 42 53
%uint = OpTypeInt 32 0
%60 = OpConstantNull %uint
OpNoLine
%2 = OpFunction %void None %4
%1 = OpLabel
OpReturn
OpFunctionEnd

The test checks to see that %1 is instruction number 13 (start counting from 1).
That worked until #3951 was merged, and now it is reported as instruction number 14.

The Tint cod uses module->ForEachInst to walk the module. To help debug the issue I added a print to see the opcode for each instruction that is visited. I get this output:

[ RUN      ] SpvParserTest.Impl_Source_WithOpLine_WithOpNoLine
 inst 17
 inst 14
 inst 15
 inst 16
 inst 7
 inst 19
 inst 33
 inst 8
 inst 21
 inst 8          ; <<<<< This was an OpLine injected by the change in #3951 
 inst 46
 inst 317
 inst 54
 inst 248
 inst 253
 inst 56

Basically, the module no longer accurately represents the input module.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions