KhronosGroup / SPIRV-LLVM-Translator

A tool and a library for bi-directional translation between SPIR-V and LLVM IR
Other
468 stars 209 forks source link

Avoid duplication of DebugLine extended instruction #2530

Closed asudarsa closed 4 months ago

asudarsa commented 4 months ago

In https://github.com/KhronosGroup/SPIRV-Registry/blob/9df72fe377f68baa97f963a3f7462d2d7c0a6908/nonsemantic/NonSemantic.Shader.DebugInfo.100.asciidoc

We have the following info for DebugLine: "Specify source-level line and column information. This information applies to all following instructions, up to the first occurrence of any of the following: the next end of block, the next DebugLine instruction, or the next DebugNoLine instruction. This instruction must only appear within a block."

The 'CurrentDebugLine' info of the SPIRV module being created was not being reset at the end of each basic block. This resulted in some duplication of identical looking DebugLine extended instructions across blocks and spirv validator threw an error about a SPIR-V value being defined more than once.

This PR fixes this issue by correctly resetting CurrentDebugLine at the end of each block.

Thanks