microsoft / microsoft/DirectXShaderCompiler

[Debug info] `discard` has slightly wrong debug location

Open
#8,746 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug needs-triage
Dominant language
C++
Stars
3.7k
Forks
900
Avg merge
2d 11h
Merged PRs (30d)
44

Description

Version: dxcompiler.dll 1.9(5402-0d3ee6b5)(1.9.0.5402) - 1.9.0.5402 (0d3ee6b55-dirty)
Repro: discard_location.zip

dxc -T ps_6_0 -Zi -Qembed_debug -Od -Fc dis

card_location.ll discard_location.hlsl
 5  float4 main(float2 uv : TEXCOORD0) : SV_Target
 6  {
 7      if (uv.x < 0.1)
 8      {
 9          discard;                     // line 9, col 9
10      }
11
12      if (uv.x < 0.2)
13          discard;                     // line 13, col 9
14
15      if (uv.x < 0.3) discard;         // line 15, col 21
16
17      discard;                         // line 17, col 5
18
19      return float4(uv, 0, 1);
20  }

Actual

call void @dx.op.discard(i32 82, i1 true), !dbg !57   ; line:8  col:5
call void @dx.op.discard(i32 82, i1 true), !dbg !62   ; line:12 col:9
call void @dx.op.discard(i32 82, i1 true), !dbg !65   ; line:15 col:9
call void @dx.op.discard(i32 82, i1 true), !dbg !66   ; line:15 col:16

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the attached discard_location.zip and run the reported dxc command to reproduce the generated LLVM and its debug locations. Trace how the four discard forms in the HLSL source produce their metadata, then verify the output locations match the annotated source lines and columns.

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
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.