Commit 737f1de
authored
Fix non-deterministic DXIL/PDB output for resource arrays (microsoft#8175)
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 microsoft#8171
Co-authored-by: Copilot [email protected]1 parent 720acdf commit 737f1de
3 files changed
Lines changed: 29 additions & 3 deletions
File tree
- docs
- lib/HLSL
- tools/clang/test/DXC
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
41 | 43 | | |
42 | 44 | | |
43 | 45 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
313 | 314 | | |
314 | 315 | | |
315 | 316 | | |
316 | | - | |
| 317 | + | |
317 | 318 | | |
318 | 319 | | |
319 | 320 | | |
| |||
613 | 614 | | |
614 | 615 | | |
615 | 616 | | |
616 | | - | |
| 617 | + | |
617 | 618 | | |
618 | 619 | | |
619 | 620 | | |
| |||
Lines changed: 23 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
0 commit comments