KhronosGroup / KhronosGroup/SPIRV-Tools

spirv-opt: MergeReturn pass places ` DebugFunctionDefinition` in non-first block of a function.

Open
#5,959 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
C++
Stars
1.4k
Forks
709
Avg merge
1d 22h
Merged PRs (30d)
28

Description

Given this SPIRV Input:

[in.zip](https://github.com/user-attachments/files/18515389/in.zip)

Running
```
spirv-val in.spv --scalar-block-layout
```
returns no errors.

However, if we run the merge return pass on this spirv and then validate its output, we will get an error:
```
spirv-opt in.spv --scalar-block-layout --merge-return -o out.spv
spirv-val out.spv --scalar-block-layout
```

Produces:
```
error: line 171: NonSemantic.Shader.DebugInfo.100 DebugFunctionDefinition: must be in the entry basic block of the function
%38 = OpExtInst %void %2 DebugFunctionDefinition %34 %main
```

Observed with `SPIRV-Tools v2024.4 v2024.4.rc2-0-g4d2f0b40`.

Contributor guide

Open the contributing guide

Research direction

Start with the provided in.zip and reproduce the issue using spirv-opt with --merge-return, then validate the output with spirv-val using --scalar-block-layout. Trace the merge-return pass to determine why DebugFunctionDefinition is emitted outside the entry block; done means the transformed SPIR-V validates without that error.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.