This is an archive of the discontinued LLVM Phabricator instance.

[MC] [Win64EH] Canonicalize ARM64 unwind opcodes
ClosedPublic

Authored by mstorsjo on Sep 9 2020, 4:42 AM.

Details

Summary

Convert 2-byte opcodes to equivalent 1-byte ones.

Adjust the existing exhaustive testcase to avoid being altered by the simplification rules (to keep that test exercising all individual opcodes).

Fix the assembler parser limits for register pairs; for .seh_save_regp and .seh_save_regp_x, we can allow up to x29, for a x29+x30 pair (which gets remapped to the UOP_SaveFPLR(X) opcodes), for .seh_save_fregp and .seh_save_fregpx, allow up to d14+d15.

Not creating .seh_save_next for float register pairs, as the actual unwinder implementation in current versions of Windows is buggy for that case.

This gives a minimal but measurable size reduction. (For a 6.5 MB DLL with 300 KB .xdata, the .xdata shrinks by 48 bytes.) Additionally it helps for further processing of the opcodes.

Diff Detail

Event Timeline

mstorsjo created this revision.Sep 9 2020, 4:42 AM
efriedma added inline comments.Sep 9 2020, 1:45 PM
llvm/lib/MC/MCWin64EH.cpp
561

I think at least save_r19r20_x has a different range from the corresponding long opcode.

570

Can we file a spec bug with Microsoft?

mstorsjo added inline comments.Sep 9 2020, 11:01 PM
llvm/lib/MC/MCWin64EH.cpp
561

Oh, good catch! Will fix. That will probably complicate one of the later patches though...

570

I discussed it with @TomTan and he said they've noticed it themselves, and they're planning to ship a fix later (late this year in insider previews, and they've noticed that neither MSVC nor Clang actually have produced this opcode so far), and they've also got some documentation update regarding these opcodes coming up. (The docs also say that another save_next after the last integer register will start restoring float registers, but it doesn't work that way in practice.)

mstorsjo updated this revision to Diff 290876.Sep 9 2020, 11:02 PM

Conditionally producing the save_r19r20_x opcode depending on offset, added a testcase with a too large offset that isn't canonicalized.

This revision is now accepted and ready to land.Sep 10 2020, 6:10 PM
This revision was automatically updated to reflect the committed changes.