This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] Track frame registers through VReg and local allocation
AbandonedPublic

Authored by dschuff on Jan 17 2020, 4:57 PM.

Details

Reviewers
None
Summary

This change has 2 components:

Target-independent: add a method getDwarfFrameBase to TargetFrameLowering. It
describes how the Dwarf frame base will be encoded. That can be a register (the
default), the CFA (which replaces NVPTX-specific logic in DwarfCompileUnit), or
a DW_OP_WASM_location descriptr.

WebAssembly: Allow WebAssemblyFunctionInfo::getFrameRegister to return the
correct virtual register instead of FP32/SP32 after WebAssemblyReplacePhysRegs
has run. Make WebAssemblyExplicitLocals store the local it allocates for the
frame register. Use this local information to implement getDwarfFrameBase

The result is that the DW_AT_frame_base attribute is correctly encoded for each
subprogram, and each param and local variable has a correct DW_AT_location that
uses DW_OP_fbreg to refer to the frame base.

Diff Detail

Event Timeline

dschuff created this revision.Jan 17 2020, 4:57 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 17 2020, 4:57 PM

Oops, this is just the diff from D71681 (which was committed as rG3a05c3969c18 and reverted), but not the whole patch.
I'll reland the whole thing together, but if @yurydelendik or @sunfish have comments I'm happy to hear them.

The previous patch was reverted because exempting the frame pointer register from LIS.splitSeparateComponents() causes the MachineInstrVerifier to complain whenever there is interesting modification of the stack pointer in the middle of the function (it basically enforces that the range has in fact been split). Those are the same cases where we can't just use a single DW_AT_frame_base for the whole function (we'll probably need CFI), so our debug info is basically just incorrect for those cases. But with this code we don't fail the verifier. The behavior is the same otherwise.

The modifications to the frame pointer also get stackified when this happens (as intended), so assuming we want to keep doing that, we'll have to update the CFI info every time we modify those values. That logic may actually be similar to what we need to do for optimized debug info (e.g. when we have DEBUG_VALUEs referring to those stackified registers).

Unit tests: pass. 61934 tests passed, 0 failed and 783 were skipped.

clang-tidy: unknown.

clang-format: fail. Please format your changes with clang-format by running git-clang-format HEAD^ or applying this patch.

Build artifacts: diff.json, clang-format.patch, CMakeCache.txt, console-log.txt, test-results.xml

dschuff abandoned this revision.Jan 17 2020, 5:27 PM

This was (re)landed as rGff171acf8