[libunwind] [libunwind][Mips] Fix the o32 register save/restore code for MIPS I (PR #246542)
Alex Rønne Petersen via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 26 19:28:25 PST 2026
================
@@ -277,10 +277,10 @@ DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
sw $8, (4 * 34)($4)
#endif
#ifdef __mips_hard_float
-#if defined(__mips_single_float)
- // A single-precision-only FPU has no sdc1. Each register still occupies
- // an 8-byte slot so that the context layout matches the other o32 FPU
- // configurations; only the low half of each slot is used.
+#if defined(__mips_single_float) || __mips == 1
----------------
alexrp wrote:
`mips_o32::getRegister()` expects to find e.g. `$f1` in the second half of `_floats[0]` for FP32, unlike single-float which expects to find it in `_floats[1]` (with one half of each element being unused). So we can't reuse the same assembly for MIPS 1 and single-float.
FP32 should look something like:
```asm
swc1 $f0, (4 * 36 + 8 * 0)($4)
swc1 $f1, (4 * 36 + 8 * 0 + 4)($4)
swc1 $f2, (4 * 36 + 8 * 2)($4)
swc1 $f3, (4 * 36 + 8 * 2 + 4)($4)
...etc...
```
I would also recommend making the condition `__mips_fpr == 32` rather than `__mips == 1` since FP32 is really what we're interested in here.
https://github.com/llvm/llvm-project/pull/246542
More information about the cfe-commits
mailing list