Fix non-deterministic DXIL/PDB output for resource arrays (#8171)#8175
Merged
damyanp merged 5 commits intomicrosoft:mainfrom Feb 21, 2026
Merged
Fix non-deterministic DXIL/PDB output for resource arrays (#8171)#8175damyanp merged 5 commits intomicrosoft:mainfrom
damyanp merged 5 commits intomicrosoft:mainfrom
Conversation
bogner
approved these changes
Feb 19, 2026
Collaborator
bogner
left a comment
There was a problem hiding this comment.
If we were doing a larger refactor here I would strongly suggest that we modify the algorithm into a stricter insert-than-query approach, especially given how painfully close it is to one today.
However, for a small code change that trades some extra memory overhead for determinism this looks perfectly reasonable.
jenatali
approved these changes
Feb 19, 2026
tex3d
approved these changes
Feb 19, 2026
tex3d
approved these changes
Feb 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
DxilMutateResourceToHandle iterates a DenseSet<Value *> to process ConstantExpr GEPs on resource array globals. DenseSet iteration order depends on pointer hash values, which vary across runs due to ASLR. For each GEP, mutateCandidates() destroys the old ConstantExpr and creates a new one, prepending it to the global's use list. The non-deterministic processing order produces a non-deterministic use list, which TranslateDxilResourceUses later iterates to create named handles - resulting in different name suffixes across compilations.
The fix is to change MutateValSet from DenseSet<Value *> to SetVector<Value *>, which preserves insertion order while maintaining O(1) lookup. Since collectCandidates() traverses the IR in a deterministic order, the insertion order is stable, producing a deterministic use list and consistent handle names.
Fixes #8171
Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com