Commit 2f357a9
authored
Fix assert due to unreachable discard (#7289)
When emitting discard in an unreachable code context (e.g. after an
infinite loop), DXC would assert (if asserts enabled), or trigger a
UBSAN failure because the discard instruction would have no parent. When
an infinite loop is emitted during CodeGen, the InsertPt is cleared,
thus subsequent discard instructions would be created, but no parent
set. We skip emitting discard in this case, which follows the same
pattern as is done for EmitIfStmt, and EmitSwitchStmt.1 parent a13938d commit 2f357a9
File tree
2 files changed
+25
-0
lines changed- tools/clang
- lib/CodeGen
- test/DXC/FinishCodeGen
2 files changed
+25
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
525 | 525 | | |
526 | 526 | | |
527 | 527 | | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
528 | 532 | | |
529 | 533 | | |
530 | 534 | | |
| |||
Lines changed: 21 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 | + | |
0 commit comments