This is an archive of the discontinued LLVM Phabricator instance.

[ARM64][SEH] PR54879: Packed Unwind Info when Homing Int Param Regs
AbandonedPublic

Authored by zzheng on May 11 2022, 4:54 PM.

Details

Summary

Try to fix: https://github.com/llvm/llvm-project/issues/54879

When checking if the epilogue is symmetric to or a subset of the prologue,
unwinding NOP should be skipped.

Diff Detail

Event Timeline

zzheng created this revision.May 11 2022, 4:54 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 11 2022, 4:54 PM
zzheng requested review of this revision.May 11 2022, 4:54 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 11 2022, 4:54 PM
apazos added inline comments.May 11 2022, 5:25 PM
llvm/lib/MC/MCWin64EH.cpp
652

Can you add a comment for checking the number of nops is 4, to be clear the pattern you are looking for

efriedma added inline comments.May 11 2022, 6:27 PM
llvm/lib/MC/MCWin64EH.cpp
640

We also use checkPackedEpilog() for to compute the epilogue offset in xdata records; we can't mess with the result for the sake of analyzing packed unwind. If you need a different analysis, please split it into a separate function, or use a flag. (Probably easier to understand if you split it into a separate function?)

855

Could use a comment explaining where "5" here comes from.

I think if H == 1, we need to reject PackedEpilogOffset == 0 and PackedEpilogOffset == 1. If the unwinder sees packed unwind, it will assume the epilogue doesn't contain any nops. So if the epilogue does in fact contain nops for some reason, the stack offsets will get messed up.

mstorsjo added inline comments.May 12 2022, 4:28 AM
llvm/lib/MC/MCWin64EH.cpp
640

+1, indeed. If we should tolerate a differing epilogue for the case of packed unwind info, we need a separate function to determine if an epilogue matches a prologue, for a specific packed form. Otherwise, we'd end up trying to share epilogues with prologues (for the non-packed format) where they actually don't match.

However, I'd like to take this whole issue back to the drawing board first; let me follow up on the bug report, to first exactly nail the expected behaviour.

llvm/test/MC/AArch64/seh-packed-unwind.s
509

If we would proceed with this patch, then we must also change the behaviour for the existing testcase for func5. For a specific packed form of unwind data, there can't be any ambiguity whether an epilog contains nops or not - we can't allow both cases. Let me follow up on the original bug report on that topic.

zzheng abandoned this revision.May 18 2022, 9:59 AM

As discussed in https://github.com/llvm/llvm-project/issues/54879, we decide not to pack unwind info when homing int param regs.
See: https://reviews.llvm.org/D125876