This is an archive of the discontinued LLVM Phabricator instance.

[MC] [Win64EH] Fix the calculation of the end of epilogs
ClosedPublic

Authored by mstorsjo on Aug 8 2022, 6:01 AM.

Details

Summary

Exclude the terminating end opcode from the epilog - it doesn't
correspond to an actual instruction that is included in the epilog
itself (within the .seh_startepilogue/.seh_endepilogue range).

In most (all?) cases, an epilog is followed by a matching terminating
instruction though (a ret or a branch to a tail call), but it's not
strictly within the .seh_startepilogue/.seh_endepilogue range.

This fixes a number of failed asserts in cases where the codegen
has incorrectly reoredered SEH opcodes so they don't match up
exactly with their instructions.

However this still just avoids failing the assertion; the root cause
of generating unexpected epilogs is still present (and fixing that is
a less obvious issue).

Diff Detail

Event Timeline

mstorsjo created this revision.Aug 8 2022, 6:01 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 8 2022, 6:01 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
mstorsjo requested review of this revision.Aug 8 2022, 6:01 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 8 2022, 6:01 AM
efriedma accepted this revision.Aug 8 2022, 9:15 AM

LGTM

This revision is now accepted and ready to land.Aug 8 2022, 9:15 AM
This revision was landed with ongoing or failed builds.Aug 8 2022, 1:05 PM
This revision was automatically updated to reflect the committed changes.