This is an archive of the discontinued LLVM Phabricator instance.

[MC] Reject CFI advance_loc separated by a non-private label for Mach-O
ClosedPublic

Authored by MaskRay on Jun 16 2023, 1:11 PM.

Details

Summary

Due to Mach-O's .subsections_via_symbols mechanism, non-private labels cannot
appear between .cfi_startproc/.cfi_endproc. Compilers do not produce such
labels, but hand-written assembly may. Give an error. Unfortunately,
emitDwarfAdvanceFrameAddr generated MCExpr doesn't have location
informatin.

Note: evaluateKnownAbsolute is to force folding A-B to a constant even if A and
B are separate by a non-private label. The function is a workaround for some
Mach-O assembl issues and should generally be avoided.

Diff Detail

Event Timeline

MaskRay created this revision.Jun 16 2023, 1:11 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 16 2023, 1:11 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
MaskRay requested review of this revision.Jun 16 2023, 1:11 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 16 2023, 1:11 PM
efriedma accepted this revision.Jun 26 2023, 12:58 PM

LGTM

We could consider adding an SMLoc field to MCDwarfCallFrameFragment; other fragments have a location field (for similar reasons, I assume). But that doesn't need to block this fix.

This revision is now accepted and ready to land.Jun 26 2023, 12:58 PM

LGTM

We could consider adding an SMLoc field to MCDwarfCallFrameFragment; other fragments have a location field (for similar reasons, I assume). But that doesn't need to block this fix.

Thank you!
To get SMLoc, I think we'll need to change functions like llvm/include/llvm/MC/MCDwarf.h:createAdjustCfaOffset and FrameEmitterImpl::emitCFIInstructions, quite a few changes.
I'll need to investigate this area more to prepare for --gsframe support...

re: https://reviews.llvm.org/D153167#4657202

oops. copied the wrong link into that commit message.