Commit 118e05d
committed
fix(ra): 消除寄存器分配的非确定性,使上板缓存生效
后端多处按指针地址迭代无序容器,导致同一份 IR 每次编译产出不同的
寄存器名与栈槽偏移(opcode 流相同,仅命名/布局变)。其后果是上板对
所有非平凡函数永远 cache miss
为 Value 增加单调递增的创建序号 getCreationId(),作为确定性全序排序键
(含已脱离 CFG 的残留指令也有稳定序号),并修正两处顺序敏感点:
- CodeGeneratorRiscV64::stackAlloc:栈槽候选改按 creationId 排序,替代
按 allocMap(unordered_map) 指针序分配,固定栈槽偏移
- GreedyRegAllocator::allocate:callInstNumbers 由 instNumbering
(std::map<Instruction*,int>) 指针序构建,排序后再用,固定分裂点等决策1 parent b9cc184 commit 118e05d
4 files changed
Lines changed: 28 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
716 | 716 | | |
717 | 717 | | |
718 | 718 | | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
719 | 725 | | |
720 | 726 | | |
721 | 727 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
127 | 130 | | |
128 | 131 | | |
129 | 132 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
13 | 20 | | |
14 | 21 | | |
15 | | - | |
| 22 | + | |
16 | 23 | | |
17 | 24 | | |
18 | 25 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
24 | 29 | | |
25 | 30 | | |
26 | 31 | | |
27 | 32 | | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
28 | 39 | | |
29 | 40 | | |
30 | 41 | | |
| |||
0 commit comments