Uses global.set as a reference point to track which local is used
for storing a WebAssembly frame pointer in the function.
Details
- Reviewers
- None
Diff Detail
- Repository
- rG LLVM Github Monorepo
- Build Status
Buildable 40481 Build 40591: arc lint + arc unit
Event Timeline
I think the general idea here makes sense, although as-is I'm afraid it might be brittle. I think for this to work, we'd need to ensure that the frame base stays in the designated local for the whole function, correct? i.e. we'd have to ensure it never gets stackified, which it currently could, right?
Come to think of it, do we know that the CFA is always correct in that case ? IIUC if SP gets stackified, we'd need to emit CFA definition instructions to ensure that the debugger could follow it from the local to the stack, possibly to another local, etc. I think that could work (e.g. we could use DW_CFA_def_cfa_expression) but I don't know that it would work out of the box. How are you handling this with wasmtime right now?
Ideally, that's correct. Though we need to take in account Philosophy behind LLVM debugging information . If producing a "stable" frame base location is a trade-off for producing an optimized code, the latter has to be favored.
Come to think of it, do we know that the CFA is always correct in that case ? IIUC if SP gets stackified, we'd need to emit CFA definition instructions to ensure that the debugger could follow it from the local to the stack, possibly to another local, etc.
Right, the moving/spilling (between registers) is not handled as this moment. :/ TODO
How are you handling this with wasmtime right now?
wasmtime, when transforms wasm DWARF into "native" DWARF, is able to process DW_AT_frame_base as a list that can define noncontinuous/different frame base locations for a single function. It is worth to note that during transform/compilation WebAssembly FP/SP abstraction will disappear as result of JIT/AOT compiler's work -- the wasm DWARF DW_AT_frame_base will be inlined into "native" DWARF expressions as transformed operators to match native instructions.
llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp | ||
---|---|---|
221 | needsSPWriteback(MF) is false when there is no calls -- we need different "anchor" than set_global |
needsSPWriteback(MF) is false when there is no calls -- we need different "anchor" than set_global