Skip to content

Commit faed9cb

Browse files
jroelofsllvmbot
authored andcommitted
Allow .alt_entry symbols to pass the .cfi nesting check (llvm#82268)
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 (cherry picked from commit 5b91647)
1 parent 461274b commit faed9cb

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

llvm/lib/MC/MCParser/AsmParser.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
#include "llvm/MC/MCSection.h"
4545
#include "llvm/MC/MCStreamer.h"
4646
#include "llvm/MC/MCSymbol.h"
47+
#include "llvm/MC/MCSymbolMachO.h"
4748
#include "llvm/MC/MCTargetOptions.h"
4849
#include "llvm/MC/MCValue.h"
4950
#include "llvm/Support/Casting.h"
@@ -1950,7 +1951,8 @@ bool AsmParser::parseStatement(ParseStatementInfo &Info,
19501951
Lex();
19511952
}
19521953

1953-
if (MAI.hasSubsectionsViaSymbols() && CFIStartProcLoc && Sym->isExternal())
1954+
if (MAI.hasSubsectionsViaSymbols() && CFIStartProcLoc &&
1955+
Sym->isExternal() && !cast<MCSymbolMachO>(Sym)->isAltEntry())
19541956
return Error(StartTokLoc, "non-private labels cannot appear between "
19551957
".cfi_startproc / .cfi_endproc pairs") &&
19561958
Error(*CFIStartProcLoc, "previous .cfi_startproc was here");

llvm/test/MC/AArch64/cfi-bad-nesting-darwin.s

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
.p2align 2
99
_locomotive:
1010
.cfi_startproc
11+
; An N_ALT_ENTRY symbol can be defined in the middle of a subsection, so
12+
; these are opted out of the .cfi_{start,end}proc nesting check.
13+
.alt_entry _engineer
14+
_engineer:
1115
ret
1216

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

0 commit comments

Comments
 (0)