[llvm] 797b68c - Revert "[MC][AsmParser] Diagnose improperly nested .cfi frames"

Martin Storsjö via llvm-commits llvm-commits at lists.llvm.org
Sun Nov 19 13:47:39 PST 2023


Author: Martin Storsjö
Date: 2023-11-19T23:22:03+02:00
New Revision: 797b68c0ba699994e1038ac33d3083541482bf19

URL: https://github.com/llvm/llvm-project/commit/797b68c0ba699994e1038ac33d3083541482bf19
DIFF: https://github.com/llvm/llvm-project/commit/797b68c0ba699994e1038ac33d3083541482bf19.diff

LOG: Revert "[MC][AsmParser] Diagnose improperly nested .cfi frames"

This reverts commit 4323da926f12672daec7f59384bd153a7cf28674.

This broke building libffi for ARM on Windows (and probably Darwin),
where one extern function intentionally falls through to another
one, while sharing one CFI region.

As long as one isn't using .subsections_via_symbols on MachO,
this probably shouldn't be a hard error.

Secondly, the tested pattern only produces an error on MachO and
COFF targets, but not for ELF, making the error case even more
inconsistent.

Reverting this commit for now, to figure out the best way forward.

Added: 
    

Modified: 
    lld/test/COFF/gc-dwarf-eh.s
    llvm/lib/MC/MCParser/AsmParser.cpp

Removed: 
    llvm/test/MC/AArch64/cfi-bad-nesting.s


################################################################################
diff  --git a/lld/test/COFF/gc-dwarf-eh.s b/lld/test/COFF/gc-dwarf-eh.s
index efe92d77fcb717c..757aa671c76933a 100644
--- a/lld/test/COFF/gc-dwarf-eh.s
+++ b/lld/test/COFF/gc-dwarf-eh.s
@@ -13,9 +13,9 @@
 	.def	_main; .scl	2; .type	32; .endef
 	.section	.text,"xr",one_only,_main
 	.globl	_main
-_main:
 	.cfi_startproc
 	.cfi_personality 0, ___gxx_personality_v0
+_main:
 	xorl	%eax, %eax
 	ret
 	.cfi_endproc
@@ -29,8 +29,8 @@ ___gxx_personality_v0:
 	.def	_unused; .scl	2; .type	32; .endef
 	.section	.text,"xr",one_only,_unused
 	.globl	_unused
-_unused:
 	.cfi_startproc
 	.cfi_personality 0, ___gxx_personality_v0
+_unused:
 	ret
 	.cfi_endproc

diff  --git a/llvm/lib/MC/MCParser/AsmParser.cpp b/llvm/lib/MC/MCParser/AsmParser.cpp
index 9c3fd476f21ba53..b36c5f067a95392 100644
--- a/llvm/lib/MC/MCParser/AsmParser.cpp
+++ b/llvm/lib/MC/MCParser/AsmParser.cpp
@@ -125,7 +125,6 @@ class AsmParser : public MCAsmParser {
   void *SavedDiagContext;
   std::unique_ptr<MCAsmParserExtension> PlatformParser;
   SMLoc StartTokLoc;
-  std::optional<SMLoc> CFIStartProcLoc;
 
   /// This is the current buffer index we're lexing from as managed by the
   /// SourceMgr object.
@@ -1950,11 +1949,6 @@ bool AsmParser::parseStatement(ParseStatementInfo &Info,
       Lex();
     }
 
-    if (CFIStartProcLoc && Sym->isExternal())
-      return Error(StartTokLoc, "non-private labels cannot appear between "
-                                ".cfi_startproc / .cfi_endproc pairs") &&
-             Error(*CFIStartProcLoc, "previous .cfi_startproc was here");
-
     if (discardLTOSymbol(IDVal))
       return false;
 
@@ -4199,8 +4193,6 @@ bool AsmParser::parseDirectiveCFISections() {
 /// parseDirectiveCFIStartProc
 /// ::= .cfi_startproc [simple]
 bool AsmParser::parseDirectiveCFIStartProc() {
-  CFIStartProcLoc = StartTokLoc;
-
   StringRef Simple;
   if (!parseOptionalToken(AsmToken::EndOfStatement)) {
     if (check(parseIdentifier(Simple) || Simple != "simple",
@@ -4221,11 +4213,8 @@ bool AsmParser::parseDirectiveCFIStartProc() {
 /// parseDirectiveCFIEndProc
 /// ::= .cfi_endproc
 bool AsmParser::parseDirectiveCFIEndProc() {
-  CFIStartProcLoc = std::nullopt;
-
   if (parseEOL())
     return true;
-
   getStreamer().emitCFIEndProc();
   return false;
 }

diff  --git a/llvm/test/MC/AArch64/cfi-bad-nesting.s b/llvm/test/MC/AArch64/cfi-bad-nesting.s
deleted file mode 100644
index 3a1a06e21394a74..000000000000000
--- a/llvm/test/MC/AArch64/cfi-bad-nesting.s
+++ /dev/null
@@ -1,23 +0,0 @@
-; RUN: not llvm-mc -triple arm64-apple-darwin %s -filetype=obj -o /dev/null 2>&1 | FileCheck %s
-
-; REQUIRES: aarch64-registered-target
-
-	.section	__TEXT,locomotive,regular,pure_instructions
-
-	.globl	_locomotive
-	.p2align	2
-_locomotive:
-	.cfi_startproc
-	ret
-
-	; It is invalid to have a non-private label between .cfi_startproc / .cfi_endproc
-	.section	__TEXT,__text,regular,pure_instructions
-	.globl	_caboose
-	.p2align	2
-_caboose:
-; CHECK: [[#@LINE-1]]:1: error: non-private labels cannot appear between .cfi_startproc / .cfi_endproc pairs
-; CHECK: [[#@LINE-9]]:2: error: previous .cfi_startproc was here
-	ret
-	.cfi_endproc
-
-.subsections_via_symbols
\ No newline at end of file


        


More information about the llvm-commits mailing list