Commit 7b5090c
committed
[cc] IR fixes
Summary of Fixes
1. Block reordering for register allocator liveness (cc/ir/inline.rs)
- Problem: After inlining, blocks were appended in arbitrary order to func.blocks. The register allocator's liveness analysis assumes blocks are in control flow order.
- Fix: Added reorder_blocks_topologically() function that reorders blocks using BFS from the entry block after inlining completes.
2. Inliner continuation block children detection (cc/ir/inline.rs)
- Problem: When checking if a block branches to the continuation, the code checked only the last instruction. But if the original callee had return followed by __builtin_unreachable(), the unreachable was cloned after the branch, making the check fail.
- Fix: Changed to check if any instruction in the block branches to continuation, not just the last.
3. DCE treating Asm as root (cc/ir/dce.rs)
- Problem: Opcode::Asm was not in the is_root() list, so DCE could eliminate inline assembly instructions.
- Fix: Added Opcode::Asm to the root opcodes list.
4. DCE tracking Asm input operands (cc/ir/dce.rs)
- Problem: The get_uses() function didn't include pseudos from inline assembly inputs, so DCE could eliminate code that produces values used by inline assembly.
- Fix: Added code to iterate through asm_data.inputs and add their pseudos to the uses list.
5. Global symbol remapping for inliner (cc/ir/inline.rs - from earlier)
- Added global_sym_map to ensure that when the same global symbol is referenced multiple times in an inlined function, they all map to the same caller pseudo ID.1 parent 45fc688 commit 7b5090c
File tree
6 files changed
+156
-24
lines changed- cc/ir
6 files changed
+156
-24
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
| 67 | + | |
67 | 68 | | |
68 | 69 | | |
69 | 70 | | |
| |||
91 | 92 | | |
92 | 93 | | |
93 | 94 | | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
94 | 102 | | |
95 | 103 | | |
96 | 104 | | |
97 | | - | |
98 | | - | |
99 | | - | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
100 | 111 | | |
101 | 112 | | |
102 | 113 | | |
103 | | - | |
| 114 | + | |
104 | 115 | | |
105 | 116 | | |
106 | 117 | | |
107 | | - | |
| 118 | + | |
108 | 119 | | |
109 | 120 | | |
110 | 121 | | |
| |||
128 | 139 | | |
129 | 140 | | |
130 | 141 | | |
131 | | - | |
132 | | - | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
133 | 145 | | |
134 | 146 | | |
135 | 147 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
200 | 200 | | |
201 | 201 | | |
202 | 202 | | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
203 | 206 | | |
204 | 207 | | |
205 | 208 | | |
| |||
239 | 242 | | |
240 | 243 | | |
241 | 244 | | |
242 | | - | |
243 | | - | |
| 245 | + | |
| 246 | + | |
244 | 247 | | |
245 | 248 | | |
246 | 249 | | |
| |||
249 | 252 | | |
250 | 253 | | |
251 | 254 | | |
252 | | - | |
| 255 | + | |
| 256 | + | |
253 | 257 | | |
254 | 258 | | |
255 | 259 | | |
| |||
308 | 312 | | |
309 | 313 | | |
310 | 314 | | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
311 | 327 | | |
312 | 328 | | |
313 | 329 | | |
| |||
636 | 652 | | |
637 | 653 | | |
638 | 654 | | |
639 | | - | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
640 | 659 | | |
641 | | - | |
642 | | - | |
643 | | - | |
644 | | - | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
645 | 663 | | |
646 | 664 | | |
647 | 665 | | |
| |||
681 | 699 | | |
682 | 700 | | |
683 | 701 | | |
684 | | - | |
| 702 | + | |
685 | 703 | | |
686 | 704 | | |
| 705 | + | |
687 | 706 | | |
688 | 707 | | |
689 | 708 | | |
690 | 709 | | |
691 | 710 | | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
692 | 722 | | |
693 | 723 | | |
694 | 724 | | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
695 | 728 | | |
696 | 729 | | |
697 | 730 | | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
698 | 792 | | |
699 | 793 | | |
700 | 794 | | |
| |||
768 | 862 | | |
769 | 863 | | |
770 | 864 | | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
771 | 874 | | |
772 | 875 | | |
773 | 876 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
612 | 612 | | |
613 | 613 | | |
614 | 614 | | |
615 | | - | |
616 | | - | |
| 615 | + | |
| 616 | + | |
617 | 617 | | |
618 | 618 | | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
619 | 623 | | |
620 | 624 | | |
621 | 625 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1050 | 1050 | | |
1051 | 1051 | | |
1052 | 1052 | | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
1053 | 1059 | | |
1054 | 1060 | | |
1055 | 1061 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1054 | 1054 | | |
1055 | 1055 | | |
1056 | 1056 | | |
| 1057 | + | |
| 1058 | + | |
1057 | 1059 | | |
1058 | 1060 | | |
1059 | 1061 | | |
| |||
1075 | 1077 | | |
1076 | 1078 | | |
1077 | 1079 | | |
| 1080 | + | |
1078 | 1081 | | |
1079 | 1082 | | |
1080 | 1083 | | |
| |||
1144 | 1147 | | |
1145 | 1148 | | |
1146 | 1149 | | |
1147 | | - | |
1148 | | - | |
1149 | | - | |
1150 | | - | |
1151 | | - | |
| 1150 | + | |
| 1151 | + | |
| 1152 | + | |
| 1153 | + | |
| 1154 | + | |
| 1155 | + | |
1152 | 1156 | | |
1153 | 1157 | | |
1154 | 1158 | | |
1155 | 1159 | | |
1156 | 1160 | | |
1157 | | - | |
| 1161 | + | |
1158 | 1162 | | |
1159 | 1163 | | |
1160 | 1164 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
666 | 666 | | |
667 | 667 | | |
668 | 668 | | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
669 | 672 | | |
670 | 673 | | |
671 | 674 | | |
| |||
0 commit comments