Skip to content

Fix recursive zero replacement bottoming out in scalars. - #6516

Merged
Antonio Maiorano (amaiorano) merged 4 commits into
microsoft:mainfrom
dneto0:sroa-fix
Apr 12, 2024
Merged

Antonio Maiorano (amaiorano) merged 4 commits into
microsoft:mainfrom
dneto0:sroa-fix

Conversation

@dneto0

Copy link
Copy Markdown
Collaborator

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
Copy Markdown
Collaborator Author

cc: Antonio Maiorano (@amaiorano)

@dneto0

Copy link
Copy Markdown
Collaborator Author

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

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

github-actions Bot commented Apr 10, 2024 •

Copy link
Copy Markdown
Contributor

✅ 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.
@amaiorano
Antonio Maiorano (amaiorano) merged commit dc84d72 into microsoft:main Apr 12, 2024
Antonio Maiorano (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.
Antonio Maiorano (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.
Mxr (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