This is an archive of the discontinued LLVM Phabricator instance.

[ARM SEH 2] [llvm-readobj] Improve printing of Windows ARM packed unwind info
ClosedPublic

Authored by mstorsjo on May 15 2022, 2:30 PM.

Details

Summary

Fix a couple minor details in the existing logic for calculating
saved registers and stack adjustment.

Synthesize the corresponding prologues and epilogues and print them.
(This supersedes the previous printout of one single list of stored
registers; as there's lots of minor nuance differences in how
registers are pushed/popped in various corner cases, it's better to
print the full prologue/epilogue instead of trying to condense it
into one single list.)

Print the raw values of the fields Reg, R, L (LinkRegister) and C
(Chaining) instead of only printing the derived values.

Diff Detail

Event Timeline

mstorsjo created this revision.May 15 2022, 2:30 PM
mstorsjo requested review of this revision.May 15 2022, 2:30 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 15 2022, 2:30 PM
Herald added a subscriber: MaskRay. · View Herald Transcript

I assume it's illegal to use prologue/epilogue folding with R==1? Should we try to diagnose this?

I assume it's illegal to use prologue/epilogue folding with R==1? Should we try to diagnose this?

No, that does seem to be quite legal - the table at https://docs.microsoft.com/en-us/cpp/build/arm-exception-handling?view=msvc-160#packed-unwind-data listing the combinations of C/L/R/PF does seem to have lots of valid combinations with R=1 PF=1.

Can you add a testcase that has both a vpush and prologue folding?

The resulting stack layout would be weird, but I guess the reserved space would be usable.

mstorsjo updated this revision to Diff 430004.May 17 2022, 5:20 AM

Added a testcase for prolog/epilog folding in combination with float registers. (I also verified that it does match how RtlVirtualUnwind interprets it.)

efriedma added inline comments.May 17 2022, 4:55 PM
llvm/tools/llvm-readobj/ARMWinEHPrinter.cpp
1148

Drop the RF.Flag() != RuntimeFunctionFlag::RFF_PackedFragment check? (Similar to the reason you dropped the check for the "F" flag.)

mstorsjo updated this revision to Diff 430255.May 18 2022, 12:24 AM

Print the prologue for packed function fragments too.

mstorsjo updated this revision to Diff 430278.May 18 2022, 1:54 AM

Reverse the order of the printed prologue instructions, to match how they're printed in the non-packed cases (where they're printed in the same order as in the unwind data) and how they're printed for ARM64.

This revision is now accepted and ready to land.May 18 2022, 9:03 AM