Commit 3eeb36b
authored
[CIR] Early return in emitCXXTryStmt if try block is empty (#1944)
Currently, in the case of an empty try block, we emit tryOp in scope and
revisit the catchers, and in the lowering pass, we have a check to
delete empty scopes, but we end up with scopes that contains `cir.yeild`
or an unconditioned jump to another scope which will not be deleted,
also for catchers we emits globals for type info.
But we can already ignore the try-catch statement if the try block is
empty, because that means also all catchers are dead code, which will
lead to not emitting any scopes that we know will be removed later and
also not emitting any unnecessary type info
Example of current emitted IR: https://godbolt.org/z/5d3jEe5K81 parent 8c0951a commit 3eeb36b
File tree
2 files changed
+36
-0
lines changed- clang
- lib/CIR/CodeGen
- test/CIR/CodeGen
2 files changed
+36
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
302 | 302 | | |
303 | 303 | | |
304 | 304 | | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
305 | 308 | | |
306 | 309 | | |
307 | 310 | | |
| |||
| 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 | + | |
0 commit comments