Skip to content

Commit

Permalink
Allow .alt_entry symbols to pass the .cfi nesting check (llvm#82268)
Browse files Browse the repository at this point in the history
A symbol with an `N_ALT_ENTRY` attribute may be defined in the middle of
a subsection, so it is reasonable to opt them out of the
`.cfi_{start,end}proc` nesting check.

Fixes: llvm#82261
  • Loading branch information
jroelofs authored and mylai-mtk committed May 14, 2024
1 parent ea504e6 commit 2223554
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 3 additions & 1 deletion llvm/lib/MC/MCParser/AsmParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include "llvm/MC/MCSection.h"
#include "llvm/MC/MCStreamer.h"
#include "llvm/MC/MCSymbol.h"
#include "llvm/MC/MCSymbolMachO.h"
#include "llvm/MC/MCTargetOptions.h"
#include "llvm/MC/MCValue.h"
#include "llvm/Support/Casting.h"
Expand Down Expand Up @@ -1950,7 +1951,8 @@ bool AsmParser::parseStatement(ParseStatementInfo &Info,
Lex();
}

if (MAI.hasSubsectionsViaSymbols() && CFIStartProcLoc && Sym->isExternal())
if (MAI.hasSubsectionsViaSymbols() && CFIStartProcLoc &&
Sym->isExternal() && !cast<MCSymbolMachO>(Sym)->isAltEntry())
return Error(StartTokLoc, "non-private labels cannot appear between "
".cfi_startproc / .cfi_endproc pairs") &&
Error(*CFIStartProcLoc, "previous .cfi_startproc was here");
Expand Down
6 changes: 5 additions & 1 deletion llvm/test/MC/AArch64/cfi-bad-nesting-darwin.s
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
.p2align 2
_locomotive:
.cfi_startproc
; An N_ALT_ENTRY symbol can be defined in the middle of a subsection, so
; these are opted out of the .cfi_{start,end}proc nesting check.
.alt_entry _engineer
_engineer:
ret

; It is invalid to have a non-private label between .cfi_startproc and
Expand All @@ -17,7 +21,7 @@ _locomotive:
.p2align 2
_caboose:
; DARWIN: [[#@LINE-1]]:1: error: non-private labels cannot appear between .cfi_startproc / .cfi_endproc pairs
; DARWIN: [[#@LINE-10]]:2: error: previous .cfi_startproc was here
; DARWIN: [[#@LINE-14]]:2: error: previous .cfi_startproc was here
ret
.cfi_endproc

Expand Down

0 comments on commit 2223554

Please sign in to comment.