Commit 4301eae
authored
Use fewer scratch locals in IRBuilder (#8608)
When popping children for an expression, greedily pop none-typed
expressions below the last value-producing expression in the stack,
packaging all the popped instructions into a new block. This avoids
leaving the none-typed expressions on top of the stack, which is good
because having them on top of the stack would force the use of a scratch
local when the next operand is popped.
Besides producing better IR with fewer scratch locals, this also has the
benefit of better round-tripping IR through binaries. The binary writer
has an optimization where it will elide unnamed blocks because they
cannot possibly be branch targets, but this could create "stacky" code
that would previously introduce a scratch local when it was parsed back
into IR. Now IRBuilder just recreates exactly the unnamed block that had
been present in the IR in first place.
While we don't generally guarantee that we can perfectly round-trip IR
through binaries, this reduces the number of cases where round-trips
lead to increased code size.
Fixes #8413.1 parent ea98200 commit 4301eae
File tree
7 files changed
+136
-201
lines changed- src
- wasm
- test
- lit
- basic
- passes
7 files changed
+136
-201
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
713 | 713 | | |
714 | 714 | | |
715 | 715 | | |
716 | | - | |
717 | | - | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
718 | 721 | | |
719 | 722 | | |
720 | 723 | | |
721 | 724 | | |
722 | 725 | | |
723 | | - | |
724 | | - | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
725 | 730 | | |
726 | 731 | | |
727 | 732 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | | - | |
| 64 | + | |
65 | 65 | | |
66 | | - | |
67 | | - | |
68 | | - | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
72 | | - | |
| 72 | + | |
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
76 | | - | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
77 | 85 | | |
78 | | - | |
| 86 | + | |
79 | 87 | | |
80 | | - | |
| 88 | + | |
81 | 89 | | |
82 | 90 | | |
83 | 91 | | |
84 | 92 | | |
85 | 93 | | |
86 | | - | |
| 94 | + | |
87 | 95 | | |
88 | 96 | | |
89 | 97 | | |
| |||
99 | 107 | | |
100 | 108 | | |
101 | 109 | | |
102 | | - | |
| 110 | + | |
103 | 111 | | |
104 | 112 | | |
105 | 113 | | |
| |||
113 | 121 | | |
114 | 122 | | |
115 | 123 | | |
116 | | - | |
| 124 | + | |
117 | 125 | | |
118 | 126 | | |
119 | | - | |
| 127 | + | |
120 | 128 | | |
121 | 129 | | |
122 | 130 | | |
123 | 131 | | |
124 | 132 | | |
125 | 133 | | |
126 | | - | |
| 134 | + | |
127 | 135 | | |
128 | 136 | | |
129 | 137 | | |
| |||
379 | 387 | | |
380 | 388 | | |
381 | 389 | | |
382 | | - | |
383 | | - | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
384 | 394 | | |
385 | 395 | | |
386 | 396 | | |
| |||
458 | 468 | | |
459 | 469 | | |
460 | 470 | | |
461 | | - | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
462 | 482 | | |
463 | 483 | | |
464 | 484 | | |
465 | 485 | | |
466 | | - | |
| 486 | + | |
467 | 487 | | |
468 | 488 | | |
469 | 489 | | |
| |||
489 | 509 | | |
490 | 510 | | |
491 | 511 | | |
492 | | - | |
| 512 | + | |
493 | 513 | | |
494 | 514 | | |
495 | 515 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2383 | 2383 | | |
2384 | 2384 | | |
2385 | 2385 | | |
2386 | | - | |
2387 | | - | |
2388 | | - | |
2389 | | - | |
2390 | | - | |
2391 | | - | |
| 2386 | + | |
| 2387 | + | |
| 2388 | + | |
| 2389 | + | |
2392 | 2390 | | |
2393 | 2391 | | |
2394 | 2392 | | |
2395 | 2393 | | |
2396 | | - | |
| 2394 | + | |
2397 | 2395 | | |
2398 | 2396 | | |
2399 | 2397 | | |
| |||
2416 | 2414 | | |
2417 | 2415 | | |
2418 | 2416 | | |
2419 | | - | |
2420 | | - | |
2421 | | - | |
2422 | | - | |
| 2417 | + | |
| 2418 | + | |
2423 | 2419 | | |
2424 | 2420 | | |
2425 | 2421 | | |
2426 | | - | |
| 2422 | + | |
2427 | 2423 | | |
2428 | | - | |
2429 | 2424 | | |
2430 | 2425 | | |
2431 | 2426 | | |
2432 | 2427 | | |
2433 | 2428 | | |
2434 | | - | |
| 2429 | + | |
2435 | 2430 | | |
2436 | 2431 | | |
2437 | | - | |
| 2432 | + | |
2438 | 2433 | | |
2439 | 2434 | | |
2440 | | - | |
| 2435 | + | |
2441 | 2436 | | |
2442 | 2437 | | |
2443 | | - | |
| 2438 | + | |
2444 | 2439 | | |
2445 | | - | |
| 2440 | + | |
2446 | 2441 | | |
2447 | 2442 | | |
2448 | 2443 | | |
2449 | | - | |
2450 | | - | |
2451 | | - | |
2452 | | - | |
| 2444 | + | |
| 2445 | + | |
2453 | 2446 | | |
2454 | | - | |
| 2447 | + | |
2455 | 2448 | | |
2456 | | - | |
| 2449 | + | |
2457 | 2450 | | |
2458 | | - | |
2459 | 2451 | | |
2460 | 2452 | | |
2461 | 2453 | | |
| |||
2464 | 2456 | | |
2465 | 2457 | | |
2466 | 2458 | | |
2467 | | - | |
| 2459 | + | |
2468 | 2460 | | |
2469 | 2461 | | |
2470 | 2462 | | |
| |||
This file was deleted.
0 commit comments