microsoft / microsoft/DirectXShaderCompiler

Rewriter : does not remove unused typedef statements and it lead to compile error

Open
#5,292 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Hello. I'm struggling with DXR for applying to existing shader code bases.
In the below code, dxr remove PSOutput type as it does not used in entryPoint, but does not remove typedef statement.
It leads to compile error.

dxr.exe -remove-unused-functions -remove-unused-globals -E ps_main

struct VSOutput { };
struct PSOutput {};
typedef PSOutput PSPointOutput;

float4 ps_main(VSOutput psIn) { return float4(0.f, 0.f, 0.f, 1.f); }

Here is dxr output

struct VSOutput { };
typedef PSOutput PSPointOutput;

float4 ps_main(VSOutput psIn) { return float4(0.f, 0.f, 0.f, 1.f); }

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

Reproduce the issue with the provided shader snippet and the dxr.exe command using -remove-unused-functions, -remove-unused-globals, and -E ps_main. Trace the rewriter's unused-declaration handling, focusing on why the typedef remains after PSOutput is removed; done means the rewritten shader no longer contains the unused typedef and compiles successfully.

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.