Previous sp can be computed based from only frame pointer and short offset. ra and s0 can be restored from stack with constant fp offset.
Unified · Split
| @@ -911,18 +911,14 @@ ST_FUNC void gfunc_epilog(void) · 910 unmodified lines | ||
| 911 | 911 | loc = (loc - num_va_regs * 8); |
| 912 | 912 | d = v = (-loc + 15) & -16; |
| 913 | 913 | |
| 914 | − if (v >= (1 << 11)) { | |
| 915 | − d = 16; | |
| 916 | − o(0x37 | (5 << 7) | UPPER(v-16)); //lui t0, upper(v) | |
| 917 | − EI(0x13, 0, 5, 5, SIGN11(v-16)); // addi t0, t0, lo(v) | |
| 918 | − ER(0x33, 0, 2, 2, 5, 0); // add sp, sp, t0 | |
| 919 | − } | |
| 920 | − EI(0x03, 3, 1, 2, d - 8 - num_va_regs * 8); // ld ra, v-8(sp) | |
| 921 | − EI(0x03, 3, 8, 2, d - 16 - num_va_regs * 8); // ld s0, v-16(sp) | |
| 922 | − EI(0x13, 0, 2, 2, d); // addi sp, sp, v | |
| 923 | − EI(0x67, 0, 0, 1, 0); // jalr x0, 0(x1), aka ret | |
| 914 | + EI(0x13, 0, 2, 8, num_va_regs * 8); // addi sp, s0, num_va_regs*8 | |
| 915 | + EI(0x03, 3, 1, 8, -8); // ld ra, -8(s0) | |
| 916 | + EI(0x03, 3, 8, 8, -16); // ld s0, -16(s0) | |
| 917 | + EI(0x67, 0, 0, 1, 0); // jalr x0, 0(x1), aka ret | |
| 918 | + | |
| 924 | 919 | large_ofs_ind = ind; |
| 925 | 920 | if (v >= (1 << 11)) { |
| 921 | + d = 16; | |
| 926 | 922 | EI(0x13, 0, 8, 2, d - num_va_regs * 8); // addi s0, sp, d |
| 927 | 923 | o(0x37 | (5 << 7) | UPPER(v-16)); //lui t0, upper(v) |
| 928 | 924 | EI(0x13, 0, 5, 5, SIGN11(v-16)); // addi t0, t0, lo(v) |