Skip to content

Conversation

@dneto0
Copy link
Collaborator

@dneto0 dneto0 commented Apr 9, 2024

During memcpy replacement, the scalarrepl-param-hlsl pass will replace certain uses of a zero-initialized global variable. The pass uses a recursive algorithm to replace uses of that global by a zero value. The current code expects the recursion to bottom out in an aggregate type. But it can bottom out in a scalar integer or scalar float.

This patch fixes the scalar cases.

Lit-based pass tests are included.

@dneto0
Copy link
Collaborator Author

dneto0 commented Apr 9, 2024

cc: @amaiorano

@dneto0
Copy link
Collaborator Author

dneto0 commented Apr 9, 2024

Let me know if I made the lit-based test correctly. I think I followed the intended pattern, using the utils/hct/ExtractIRForPass.py script. I had to modify %opt to %dxopt but otherwise it was straightforward

@amaiorano amaiorano requested a review from llvm-beanz April 10, 2024 00:16
During memcpy replacement, the scalarrepl-param-hlsl pass will replace
certain uses of a zero-initialized global variable.  The pass uses
a recursive algorithm to replace uses of that global by a zero value.
The current code expects the recursion to bottom out in an aggregate type.
But it can bottom out in a scalar integer or scalar float.

This patch fixes the scalar cases.

Lit-based pass tests are included.
@github-actions
Copy link
Contributor

github-actions bot commented Apr 10, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

Add more check lines to ensure we're examining the right code.
Generalize the matched patterns to accomodate local identifier
renames.
@dneto0 dneto0 requested a review from llvm-beanz April 10, 2024 20:10
@amaiorano amaiorano self-requested a review April 12, 2024 15:01
@amaiorano amaiorano merged commit dc84d72 into microsoft:main Apr 12, 2024
amaiorano added a commit to amaiorano/DirectXShaderCompiler that referenced this pull request Aug 9, 2024
This is the same fix as was done in
microsoft#6516
except that this is for replace uses of zero-init for instructions in
the entry block.
amaiorano added a commit that referenced this pull request Aug 12, 2024
This is the same fix as was done in
#6516 except that
this is for replace uses of zero-init for instructions in the entry
block.
SjMxr233 pushed a commit to ShaderHelper/DirectXShaderCompiler that referenced this pull request Jul 24, 2025
This is the same fix as was done in
microsoft#6516 except that
this is for replace uses of zero-init for instructions in the entry
block.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants