Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix RemoveUnstructuredLoopExits when an exiting edge jumps out multiple levels of loops. #6668

Merged
merged 4 commits into from
Jun 6, 2024

Conversation

dneto0
Copy link
Collaborator

@dneto0 dneto0 commented May 31, 2024

Before doing any major surgery on an exit from loop L, ensure that if an exit edge from L goes to block X, then X is in L's parent loop or no loop at all.

Add test cases:

  • a reduced test case where the exiting block does not dominate its own loop latch.
  • a reduced test case where the exiting block is the latch for its own loop. This reproduces the assert triggered by the original HLSL.
  • the original HLSL that triggered this bug fix.
  • the intermediate module from the original HLSL, taken just before the attempt to remove unstructured loop exits.

@dneto0 dneto0 requested a review from a team as a code owner May 31, 2024 23:22
@dneto0 dneto0 force-pushed the issue-163 branch 2 times, most recently from e62783e to 55338e7 Compare May 31, 2024 23:50
@dneto0
Copy link
Collaborator Author

dneto0 commented Jun 3, 2024

yeah, I need to fix this. I thought I was running with ASAN but I wasn't.

@amaiorano amaiorano requested a review from llvm-beanz June 4, 2024 17:01
Copy link
Contributor

@dmpots dmpots left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the fix!

I appreciate the comments and level of detail. A totally optional suggestion would be to add some ascii art to the test or comment to clarify the situation. Sometimes a picture can really help the understanding.

@dneto0
Copy link
Collaborator Author

dneto0 commented Jun 5, 2024

LGTM, thanks for the fix!

I appreciate the comments and level of detail. A totally optional suggestion would be to add some ascii art to the test or comment to clarify the situation. Sometimes a picture can really help the understanding.

Indeed pictures are great. I've added ASCII art depictions of the CFGs for the two reduced test cases. The "regression" case is a mess, and doesn't provide extra insight.

@dneto0
Copy link
Collaborator Author

dneto0 commented Jun 6, 2024

The failures are weird; I can't explain them by this change.

An error is caused by this warning (with warnings-as-error):

2024-06-05T21:40:26.6478030Z D:\a\1\s\projects\dxilconv\include\ShaderBinary\ShaderBinary.h(381,10): warning C4201: nonstandard extension used: nameless struct/union [D:\a\1\projects\dxilconv\lib\ShaderBinary\ShaderBinary.vcxproj]

The source at that spot has a pragma that appears to guard the warning.

I'll try a no-change amend commit to kick off the bots again.

…le levels of loops

Before doing any major surgery on an exit from loop L, ensure that if an
exit edge from L goes to block X, then X is in L's parent loop or no
loop at all.

Add test cases:
- a reduced test case where the exiting block does not dominate its own
  loop latch.
- a reduced test case where the exiting block is the latch for its own
  loop. This reproduces the assert triggered by the original HLSL.
- the original HLSL that triggered this bug fix.
- the intermediate module from the original HLSL, taken just before
  the attempt to remove unstructured loop exits.
@dneto0
Copy link
Collaborator Author

dneto0 commented Jun 6, 2024

Trying again by rebasing against latest main.

@llvm-beanz
Copy link
Collaborator

The Windows build failures here seem to be related to a VM image update that occurred last night. Our builds work fine on VM image 20240514.3.0, and fail on 20240603.1.0.

Given that I'm fairly confident this PR isn't related to the issues I'm going to bypass the merge checks to merge the PR.

@llvm-beanz llvm-beanz merged commit 8206fbd into microsoft:main Jun 6, 2024
9 of 12 checks passed
llvm-beanz added a commit to llvm-beanz/DirectXShaderCompiler that referenced this pull request Jun 10, 2024
We do not want this change to stick around forever but we need it to
work around the broken GitHub runner images:

actions/runner-images#10004

Related microsoft#6668
amaiorano added a commit to amaiorano/DirectXShaderCompiler that referenced this pull request Jun 11, 2024
…t multiple levels of loops. (microsoft#6668)"

This reverts commit 8206fbd.
Reason for revert: since landing this, new asserts/crashes have been
found.
llvm-beanz added a commit that referenced this pull request Jun 11, 2024
This PR contains two changes:
1) Moves a pragma to disable a warning, which seems to be required by
the new compiler.
2) Adds a preprocessor define to workaround the crashes caused by the
runner image mismatching C++ runtime versions.

The second change we will want to revert once the runner images are
fixed. The issue tracking the runner images is:

actions/runner-images#10004

Related #6668
amaiorano added a commit to amaiorano/DirectXShaderCompiler that referenced this pull request Jun 11, 2024
…t multiple levels of loops. (microsoft#6668)"

This reverts commit 8206fbd.
Reason for revert: since landing this, new asserts/crashes have been
found.
amaiorano added a commit that referenced this pull request Jun 11, 2024
…t multiple levels of loops. (#6668)" (#6685)

This reverts commit 8206fbd.

Reason for revert: since landing this, new asserts/crashes have been
found.
pow2clk pushed a commit to pow2clk/DirectXShaderCompiler that referenced this pull request Jul 16, 2024
This PR contains two changes:
1) Moves a pragma to disable a warning, which seems to be required by
the new compiler.
2) Adds a preprocessor define to workaround the crashes caused by the
runner image mismatching C++ runtime versions.

The second change we will want to revert once the runner images are
fixed. The issue tracking the runner images is:

actions/runner-images#10004

Related microsoft#6668

(cherry picked from commit 0b9acdb)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants