Description
Cranelift on RISCV (when frame pointers are enabled) generated code where the fp
register always points to the next frame pointer like so:
---- frame ----
ra,
fp, <- fp points here
...
---- frame ----
while LLVM generates code where fp
points one word above the frame like so:
---- frame ---- <- fp points here
ra,
fp,
...
---- frame ----
While this is not a problem in isolation it means that stack walkers (for backtraces, perf stack traces, unwinding) cannot walk across a boundary where LLVM generated code calls cranelift generated code and vice-versa.
Since we cannot really change LLVMs behavior cranelift should match LLVM even though that means a really nasty breaking change for cranelift consumers that rely on the frame pointer position (nasty since code would continue to compile just be broken at runtime in weird ways).
AFAIK supporting this change in wasmtime would be quite trivial, it would just mean changing this from 0
to -2 * size_of::<usize>()
which would mean this assertion no longer holds
and the corresponding code in
save_last_wasm_exit_fp_pc
needs to be adjustedwasmtime/crates/cranelift/src/compiler.rs
Lines 1173 to 1176 in 70a3793