Commit a33e79e
delay-slot filler: reject candidates sitting in another branch's slot
sh_fill_branch_delays would chain-walk a delay-slot instruction OUT of
an earlier branch's slot to fill a later one. When the killed line was
the only thing between two branches, the lexical neighbour after the
emitted-stream collapse silently slid into the now-vacated slot — and
when that neighbour was itself a branch, we shipped a `bra` (or other
branch) literally inside a `jsr` delay slot. That's forbidden by the
SH7604 spec ("any branch, MOVA, or TRAPA in a delay slot is illegal").
HEAD's checked-in FUN_06040EA0.s line 60 was a concrete example.
Guard: before accepting candidate k, walk back one non-empty line; if
that's a branch, k is in its delay slot — refuse.
Two effects:
1. IPA Phase E.1b regtest now passes end-to-end. The synthesized
`add drh#16, r4` lands in jsr 1's delay slot (executed before the
branch fires, so both helpers see r4 = p1+16); the chain-walk
used to displace it past both calls into dead-code territory.
Also fixes an awk bug in the regtest itself: the prior pattern
`flag; /^_[a-zA-Z]/{if(seen)exit; seen=1}` exited at the FIRST
`_<letter>:` label (which is `_helper_a:`, drained before
`_caller:` in source order), so caller_body was always empty and
the test always failed regardless of compiler output.
2. Cleans up illegal-SH-2 emissions across the corpus. Net byte-
match impact: 4 functions improved (FUN_06040EA0 standalone +
FUN_06045378, FUN_060477FC, FUN_06047A08 in TU), 17 functions
drift +1 to +4 bytes (all in functions already 22..1024 bytes
off prod — line-shift noise, none breaking byte-match). The
improvements include cases where the chain-walk's illegal output
was the only thing keeping us from matching prod's spec-correct
sequencing.
No previously byte-matched (diff=0) function regressed. The IPA
mechanism itself is unchanged — this is a pre-existing filler bug
that the IPA test happened to surface because the synthesized add is
exactly the kind of instruction the chain-walk likes to grab.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>1 parent 943a487 commit a33e79e
5 files changed
Lines changed: 164 additions & 21 deletions
File tree
- saturn
- experiments/daytona_byte_match
- race_FUN_06044060
- race_tu1
- tools
- src
Lines changed: 45 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9669 | 9669 | | |
9670 | 9670 | | |
9671 | 9671 | | |
| 9672 | + | |
9672 | 9673 | | |
9673 | 9674 | | |
| 9675 | + | |
9674 | 9676 | | |
9675 | 9677 | | |
| 9678 | + | |
9676 | 9679 | | |
9677 | 9680 | | |
| 9681 | + | |
9678 | 9682 | | |
9679 | 9683 | | |
| 9684 | + | |
9680 | 9685 | | |
9681 | 9686 | | |
9682 | | - | |
| 9687 | + | |
9683 | 9688 | | |
9684 | 9689 | | |
9685 | 9690 | | |
| |||
11846 | 11851 | | |
11847 | 11852 | | |
11848 | 11853 | | |
| 11854 | + | |
11849 | 11855 | | |
11850 | 11856 | | |
11851 | | - | |
| 11857 | + | |
11852 | 11858 | | |
11853 | 11859 | | |
11854 | 11860 | | |
| |||
11874 | 11880 | | |
11875 | 11881 | | |
11876 | 11882 | | |
| 11883 | + | |
11877 | 11884 | | |
11878 | 11885 | | |
11879 | | - | |
| 11886 | + | |
11880 | 11887 | | |
11881 | 11888 | | |
11882 | 11889 | | |
| |||
14299 | 14306 | | |
14300 | 14307 | | |
14301 | 14308 | | |
| 14309 | + | |
14302 | 14310 | | |
14303 | 14311 | | |
14304 | | - | |
| 14312 | + | |
14305 | 14313 | | |
14306 | 14314 | | |
14307 | 14315 | | |
| |||
14379 | 14387 | | |
14380 | 14388 | | |
14381 | 14389 | | |
| 14390 | + | |
14382 | 14391 | | |
14383 | 14392 | | |
14384 | | - | |
| 14393 | + | |
14385 | 14394 | | |
14386 | 14395 | | |
14387 | 14396 | | |
| |||
14439 | 14448 | | |
14440 | 14449 | | |
14441 | 14450 | | |
| 14451 | + | |
14442 | 14452 | | |
14443 | 14453 | | |
14444 | | - | |
| 14454 | + | |
14445 | 14455 | | |
14446 | 14456 | | |
14447 | 14457 | | |
| |||
14499 | 14509 | | |
14500 | 14510 | | |
14501 | 14511 | | |
| 14512 | + | |
14502 | 14513 | | |
14503 | 14514 | | |
14504 | | - | |
| 14515 | + | |
14505 | 14516 | | |
14506 | 14517 | | |
14507 | 14518 | | |
| |||
14559 | 14570 | | |
14560 | 14571 | | |
14561 | 14572 | | |
| 14573 | + | |
14562 | 14574 | | |
14563 | 14575 | | |
14564 | | - | |
| 14576 | + | |
14565 | 14577 | | |
14566 | 14578 | | |
14567 | 14579 | | |
| |||
14619 | 14631 | | |
14620 | 14632 | | |
14621 | 14633 | | |
| 14634 | + | |
14622 | 14635 | | |
14623 | 14636 | | |
14624 | | - | |
| 14637 | + | |
14625 | 14638 | | |
14626 | 14639 | | |
14627 | 14640 | | |
| |||
15802 | 15815 | | |
15803 | 15816 | | |
15804 | 15817 | | |
| 15818 | + | |
15805 | 15819 | | |
15806 | 15820 | | |
15807 | 15821 | | |
| |||
17173 | 17187 | | |
17174 | 17188 | | |
17175 | 17189 | | |
| 17190 | + | |
17176 | 17191 | | |
17177 | 17192 | | |
17178 | 17193 | | |
| |||
17285 | 17300 | | |
17286 | 17301 | | |
17287 | 17302 | | |
| 17303 | + | |
17288 | 17304 | | |
17289 | 17305 | | |
17290 | 17306 | | |
| |||
17299 | 17315 | | |
17300 | 17316 | | |
17301 | 17317 | | |
| 17318 | + | |
17302 | 17319 | | |
17303 | 17320 | | |
17304 | 17321 | | |
| |||
17376 | 17393 | | |
17377 | 17394 | | |
17378 | 17395 | | |
| 17396 | + | |
17379 | 17397 | | |
17380 | 17398 | | |
17381 | 17399 | | |
| |||
17416 | 17434 | | |
17417 | 17435 | | |
17418 | 17436 | | |
| 17437 | + | |
17419 | 17438 | | |
17420 | 17439 | | |
17421 | 17440 | | |
| |||
17426 | 17445 | | |
17427 | 17446 | | |
17428 | 17447 | | |
| 17448 | + | |
17429 | 17449 | | |
17430 | 17450 | | |
| 17451 | + | |
17431 | 17452 | | |
17432 | 17453 | | |
17433 | 17454 | | |
17434 | 17455 | | |
17435 | | - | |
| 17456 | + | |
17436 | 17457 | | |
17437 | 17458 | | |
17438 | 17459 | | |
| |||
17477 | 17498 | | |
17478 | 17499 | | |
17479 | 17500 | | |
| 17501 | + | |
17480 | 17502 | | |
17481 | 17503 | | |
17482 | 17504 | | |
| |||
17510 | 17532 | | |
17511 | 17533 | | |
17512 | 17534 | | |
| 17535 | + | |
17513 | 17536 | | |
17514 | 17537 | | |
17515 | 17538 | | |
| |||
17519 | 17542 | | |
17520 | 17543 | | |
17521 | 17544 | | |
| 17545 | + | |
17522 | 17546 | | |
17523 | 17547 | | |
17524 | | - | |
| 17548 | + | |
| 17549 | + | |
17525 | 17550 | | |
17526 | 17551 | | |
17527 | 17552 | | |
| |||
17573 | 17598 | | |
17574 | 17599 | | |
17575 | 17600 | | |
| 17601 | + | |
17576 | 17602 | | |
17577 | 17603 | | |
17578 | 17604 | | |
| |||
17650 | 17676 | | |
17651 | 17677 | | |
17652 | 17678 | | |
| 17679 | + | |
17653 | 17680 | | |
17654 | 17681 | | |
17655 | 17682 | | |
| |||
18272 | 18299 | | |
18273 | 18300 | | |
18274 | 18301 | | |
| 18302 | + | |
18275 | 18303 | | |
18276 | 18304 | | |
18277 | | - | |
| 18305 | + | |
18278 | 18306 | | |
18279 | 18307 | | |
18280 | 18308 | | |
| |||
18319 | 18347 | | |
18320 | 18348 | | |
18321 | 18349 | | |
| 18350 | + | |
18322 | 18351 | | |
18323 | 18352 | | |
18324 | | - | |
| 18353 | + | |
18325 | 18354 | | |
18326 | 18355 | | |
18327 | 18356 | | |
| |||
20290 | 20319 | | |
20291 | 20320 | | |
20292 | 20321 | | |
| 20322 | + | |
20293 | 20323 | | |
20294 | 20324 | | |
20295 | 20325 | | |
| |||
20601 | 20631 | | |
20602 | 20632 | | |
20603 | 20633 | | |
| 20634 | + | |
20604 | 20635 | | |
20605 | 20636 | | |
20606 | | - | |
| 20637 | + | |
20607 | 20638 | | |
20608 | 20639 | | |
20609 | 20640 | | |
| |||
Lines changed: 10 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
215 | 215 | | |
216 | 216 | | |
217 | 217 | | |
218 | | - | |
219 | 218 | | |
| 219 | + | |
| 220 | + | |
220 | 221 | | |
221 | 222 | | |
222 | 223 | | |
| |||
352 | 353 | | |
353 | 354 | | |
354 | 355 | | |
355 | | - | |
356 | 356 | | |
| 357 | + | |
| 358 | + | |
357 | 359 | | |
358 | 360 | | |
359 | 361 | | |
| |||
537 | 539 | | |
538 | 540 | | |
539 | 541 | | |
540 | | - | |
541 | 542 | | |
| 543 | + | |
| 544 | + | |
542 | 545 | | |
543 | 546 | | |
544 | 547 | | |
| |||
551 | 554 | | |
552 | 555 | | |
553 | 556 | | |
| 557 | + | |
554 | 558 | | |
555 | 559 | | |
556 | 560 | | |
| |||
569 | 573 | | |
570 | 574 | | |
571 | 575 | | |
572 | | - | |
573 | 576 | | |
574 | 577 | | |
575 | 578 | | |
| |||
620 | 623 | | |
621 | 624 | | |
622 | 625 | | |
623 | | - | |
624 | 626 | | |
| 627 | + | |
| 628 | + | |
625 | 629 | | |
626 | 630 | | |
627 | 631 | | |
| |||
663 | 667 | | |
664 | 668 | | |
665 | 669 | | |
| 670 | + | |
666 | 671 | | |
667 | 672 | | |
668 | 673 | | |
| |||
947 | 952 | | |
948 | 953 | | |
949 | 954 | | |
950 | | - | |
951 | 955 | | |
952 | 956 | | |
953 | 957 | | |
| |||
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
60 | | - | |
61 | 60 | | |
| 61 | + | |
| 62 | + | |
62 | 63 | | |
63 | 64 | | |
64 | 65 | | |
| |||
0 commit comments