microsoft / microsoft/DirectXShaderCompiler

Typo and potential null dereference in HLMatrixBitcastLowerPass.cpp

Open
#5,328 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

https://github.com/microsoft/DirectXShaderCompiler/blob/8f2881e51178346547c2bf58c74691e05c5cf825/lib/HLSL/HLMatrixBitcastLowerPass.cpp#L229C28-L229C32

The LI below should be ST. The LI is from the previous if testing for U's type.

    } else if (LoadInst *LI = dyn_cast<LoadInst>(U)) {
    ...
    } else if (StoreInst *ST = dyn_cast<StoreInst>(U)) {
      Value *V = ST->getValueOperand();
      if (VectorType *Ty = dyn_cast<VectorType>(V->getType())) {
        IRBuilder<> Builder(LI); // <---- Should be `ST`
        Value *zeroIdx = Builder.getInt32(0);
        unsigned vecSize = Ty->getNumElements();
        for (unsigned i = 0; i < vecSize; i++) {
          Value *GEP = CreateEltGEP(A, i, zeroIdx, Builder);
          Value *Elt = Builder.CreateExtractElement(V, i);
          Builder.CreateStore(Elt, GEP);
        }
        ST->eraseFromParent();

I made an issue instead of a PR because I don't have a test case, just noticed this typo.

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 at lib/HLSL/HLMatrixBitcastLowerPass.cpp around line 229 and compare the load and store branches shown in the issue. Confirm that the store branch uses ST when constructing IRBuilder, then build or validate the compiler as appropriate; the issue provides no test case, so done means the typo and potential null dereference are corrected without changing the surrounding behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.