[PATCH] D26263: [WebAssembly] Emit a BasePointer when we have overly-aligned stack objects

Jacob Gravelle via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 3 11:53:08 PDT 2016


jgravelle-google added inline comments.


================
Comment at: test/CodeGen/WebAssembly/alignment.ll:34
+
+; CHECK:      copy_local $push[[L5:.+]]=, $[[BP]]
+; CHECK-NEXT: i32.store  __stack_pointer($pop{{.+}}), $pop[[L5]]
----------------
dschuff wrote:
> Seems like we should be storing directly from BP. Where does this `copy_local` come from?
> The epilog codegen looks ok; I guess this copy is the one generated in the prolog and gets moved down by the stackifier?
Huh. This is caused by us emitting a frame pointer, and register stackification doing magic to it.
tl;dr: Yes.

Prolog/epilogue:
# load __stack_pointer into SP
# copy SP into BP
# decrement SP by fixed amount
# store new SP as FP
# [rest of code]
# store BP into __stack_pointer

Reg stackify:
# Moves the single copy into BP to be next to its use
# Tees the two uses of the original load of __stack_pointer, stackifies one for use in computing FP, and saves one in BP

The good news is this just gets translated to get_local in s2wasm. And adding -wasm-explicit-locals models it that was as well, so there's no actual cost here, it's just kinda quirky.
... is what I've been able to piece together.



https://reviews.llvm.org/D26263





More information about the llvm-commits mailing list