llvm-project
d3f58f9e - [DebugInfo][WebAssembly] Anchor stack locals to the frame base (#211826)

Commit
31 days ago
[DebugInfo][WebAssembly] Anchor stack locals to the frame base (#211826) WebAssembly's stack pointer is not a register that can be described in DWARF. When a function has no virtual frame base, because its stack pointer is never explicitly referenced (e.g. a function whose only local is dead), the frame base falls back to the __stack_pointer global and the frame register is the physical SP. addMachineReg failed for that register, so addMachineRegExpression dropped the base and the caller emitted the frame offset with nothing under it: a bare DW_OP_plus_uconst that underflows the DWARF stack when the location is evaluated. ``` DW_AT_frame_base (DW_OP_WASM_location 0x3 0x0, DW_OP_stack_value) DW_AT_location (DW_OP_plus_uconst 0xc) ;; before DW_AT_location (DW_OP_fbreg +12) ;; after ``` A frame-relative location does not need the frame register to be describable on its own, since it is anchored through DW_AT_frame_base and DW_OP_fbreg. Take the same path already used for a virtual frame register so a physical one without a DWARF number is handled too. Assisted-by: Claude PS: I also updated the frame-base fallback comment in WebAssemblyFrameLowering: reads now work at the innermost frame, and the remaining limitation is that the __stack_pointer global does not describe outer frames.
Author
Parents
Loading