Commit 773b012
authored
Fix invalid IR from scalarrepl-param-hlsl in ReplaceConstantWithInst (#6556)
ReplaceConstantWithInst(C, V) replaces uses of C in the current function
with V. If such a use C is an instruction I, the it replaces uses of C
in I with V. However, this function did not make sure to only perform
this replacement if V dominates I. As a result, it may end up replacing
uses of C in instructions before the definition of V.
The fix is to lazily compute the dominator tree in
ReplaceConstantWithInst so that we can guard the replacement with that
dominance check.1 parent 7db2fc1 commit 773b012
5 files changed
Lines changed: 328 additions & 7 deletions
File tree
- lib/Transforms/Scalar
- tools/clang/test/DXC/Passes/ScalarReplHLSL
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3271 | 3271 | | |
3272 | 3272 | | |
3273 | 3273 | | |
3274 | | - | |
| 3274 | + | |
| 3275 | + | |
| 3276 | + | |
| 3277 | + | |
3275 | 3278 | | |
| 3279 | + | |
3276 | 3280 | | |
| 3281 | + | |
| 3282 | + | |
| 3283 | + | |
| 3284 | + | |
| 3285 | + | |
| 3286 | + | |
| 3287 | + | |
| 3288 | + | |
| 3289 | + | |
| 3290 | + | |
| 3291 | + | |
| 3292 | + | |
3277 | 3293 | | |
3278 | 3294 | | |
3279 | 3295 | | |
3280 | 3296 | | |
3281 | 3297 | | |
3282 | | - | |
| 3298 | + | |
| 3299 | + | |
| 3300 | + | |
| 3301 | + | |
3283 | 3302 | | |
3284 | 3303 | | |
3285 | 3304 | | |
| |||
3288 | 3307 | | |
3289 | 3308 | | |
3290 | 3309 | | |
3291 | | - | |
| 3310 | + | |
| 3311 | + | |
3292 | 3312 | | |
3293 | 3313 | | |
3294 | 3314 | | |
| 3315 | + | |
3295 | 3316 | | |
3296 | 3317 | | |
3297 | 3318 | | |
| |||
3531 | 3552 | | |
3532 | 3553 | | |
3533 | 3554 | | |
3534 | | - | |
| 3555 | + | |
| 3556 | + | |
3535 | 3557 | | |
3536 | 3558 | | |
3537 | 3559 | | |
3538 | 3560 | | |
3539 | 3561 | | |
3540 | 3562 | | |
3541 | 3563 | | |
3542 | | - | |
| 3564 | + | |
| 3565 | + | |
3543 | 3566 | | |
3544 | 3567 | | |
3545 | 3568 | | |
| |||
5449 | 5472 | | |
5450 | 5473 | | |
5451 | 5474 | | |
5452 | | - | |
| 5475 | + | |
5453 | 5476 | | |
5454 | | - | |
| 5477 | + | |
5455 | 5478 | | |
5456 | 5479 | | |
5457 | 5480 | | |
| |||
Lines changed: 45 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 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
0 commit comments