microsoft / microsoft/DirectXShaderCompiler

Improve generated isArgumentListValid in DxilInstructions.h

Open
#7,962 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

@bogner commented here. Edited relevant bits for issue:

using the result of llvm::dyn_cast without checking for null is asking for a segfault. If this is known to be the right type we should be using llvm::cast instead.

It turns out that this function is never even called in this project, though it is a shared header that drivers use, so I'd be hesitant to just remove it.

I think the point of this method was to guarantee you won't index outside the call operands when calling get_*/set_* methods.

This method could be generated like this:

  bool isArgumentListValid() const {
    if (llvm::CallInst *CI = llvm::dyn_cast<llvm::CallInst>(Instr))
      if (1 == CI->getNumArgOperands())
        return true;
    return false;
  }

Originally posted by @tex3d in https://github.com/microsoft/DirectXShaderCompiler/pull/7947#discussion_r2582957787

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 by tracing how DxilInstructions.h is generated and locate the generated isArgumentListValid implementation. Confirm the generated method safely checks the instruction type and operand count before get_* or set_* access, while preserving the shared-header behavior described in the issue.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.