This is an archive of the discontinued LLVM Phabricator instance.

[AArch64][Windows] Add llvm-readobj support for save_any_reg unwind opcode.
ClosedPublic

Authored by efriedma on Oct 4 2022, 2:03 PM.

Details

Summary

This is primarily used for Arm64EC, but it could be used for other non-standard calling conventions. The testcase is based on an Arm64EC thunk generated by MSVC.

The name save_any_reg comes from Microsoft documentation, but the full encoding isn't specified there; this is reverse-engineered from the behavior of the unwinder. (Thanks to Martin Storsjö for his example of how to write simple unwinder testcases by directly calling RtlVirtualUnwind.)

Diff Detail

Event Timeline

efriedma created this revision.Oct 4 2022, 2:03 PM
Herald added a project: Restricted Project. · View Herald Transcript
efriedma requested review of this revision.Oct 4 2022, 2:03 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 4 2022, 2:03 PM
Herald added a subscriber: MaskRay. · View Herald Transcript
mstorsjo accepted this revision.Oct 4 2022, 2:32 PM

LGTM, great work on reverse engineering this instruction!

I guess it would be useful to send a PR to the unwind info docs, to document your findings here too (even if the llvm-readobj code here is good enough documentation for our purposes here).

llvm/test/tools/llvm-readobj/COFF/arm64-unwind-save_any_reg.s
26

Would it be good to include cases with d registers and non-paired opcodes too?

This revision is now accepted and ready to land.Oct 4 2022, 2:32 PM

re: documentation, let's see what Microsoft says about your current patch. I mean, I'm willing to help writing up, but only if they're actually interested in taking changes.

llvm/test/tools/llvm-readobj/COFF/arm64-unwind-save_any_reg.s
26

I'm very confident the current testcase is correct because the decoded opcodes match what MSVC actually generates. I'd be less confident about other testcases... but I can add some extra tests to ensure the decoding doesn't blow up, at least.

This revision was landed with ongoing or failed builds.Oct 4 2022, 6:56 PM
This revision was automatically updated to reflect the committed changes.

re: documentation, let's see what Microsoft says about your current patch. I mean, I'm willing to help writing up, but only if they're actually interested in taking changes.

Ok, let's see how that one fares. OTOH, this one actually seems at least acknowledged in their other documentation, but who knows what their status/intent is wrt PAC.

Earlier I've had success with getting fixes merged in their docs, for inconsistencies/inaccuracies in the stuff that they do have documented though, but the review was fairly slow.