[llvm-branch-commits] [llvm] d55d680 - [MC] Consume EndOfStatement in .cfi_{sections, endproc}
Scott Linder via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Fri Dec 4 14:34:55 PST 2020
Author: Scott Linder
Date: 2020-12-04T22:30:29Z
New Revision: d55d6806ad728f76c8721d3fee294545f5833fac
URL: https://github.com/llvm/llvm-project/commit/d55d6806ad728f76c8721d3fee294545f5833fac
DIFF: https://github.com/llvm/llvm-project/commit/d55d6806ad728f76c8721d3fee294545f5833fac.diff
LOG: [MC] Consume EndOfStatement in .cfi_{sections,endproc}
Previously these directives were always interpreted as having an extra
blank line after them.
Reviewed By: MaskRay
Differential Revision: https://reviews.llvm.org/D92612
Added:
llvm/test/MC/AsmParser/round-trip.s
Modified:
llvm/lib/MC/MCParser/AsmParser.cpp
llvm/test/MC/ELF/cfi.s
Removed:
################################################################################
diff --git a/llvm/lib/MC/MCParser/AsmParser.cpp b/llvm/lib/MC/MCParser/AsmParser.cpp
index 936d2b004225..6a7ae3b73ecd 100644
--- a/llvm/lib/MC/MCParser/AsmParser.cpp
+++ b/llvm/lib/MC/MCParser/AsmParser.cpp
@@ -4077,6 +4077,9 @@ bool AsmParser::parseDirectiveCFISections() {
Debug = true;
}
+ if (parseToken(AsmToken::EndOfStatement))
+ return addErrorSuffix(" in '.cfi_sections' directive");
+
getStreamer().emitCFISections(EH, Debug);
return false;
}
@@ -4104,6 +4107,8 @@ bool AsmParser::parseDirectiveCFIStartProc() {
/// parseDirectiveCFIEndProc
/// ::= .cfi_endproc
bool AsmParser::parseDirectiveCFIEndProc() {
+ if (parseToken(AsmToken::EndOfStatement))
+ return addErrorSuffix(" in '.cfi_endproc' directive");
getStreamer().emitCFIEndProc();
return false;
}
diff --git a/llvm/test/MC/AsmParser/round-trip.s b/llvm/test/MC/AsmParser/round-trip.s
new file mode 100644
index 000000000000..4e5fb3961746
--- /dev/null
+++ b/llvm/test/MC/AsmParser/round-trip.s
@@ -0,0 +1,15 @@
+# RUN: llvm-mc -preserve-comments -triple i386-unknown-unknown %s >%t-1.s
+# RUN: llvm-mc -preserve-comments -triple i386-unknown-unknown %t-1.s >%t-2.s
+# RUN:
diff %t-1.s %t-2.s
+
+# Test that various assembly round-trips when run through MC; the first
+# transition from hand-written to "canonical" output may introduce some small
+#
diff erences, so we don't include the initial input in the comparison.
+
+.text
+
+# Some of these CFI instructions didn't consume the end of statement
+# consistently, which led to extra empty lines in the output.
+.cfi_sections .debug_frame
+.cfi_startproc
+.cfi_endproc
diff --git a/llvm/test/MC/ELF/cfi.s b/llvm/test/MC/ELF/cfi.s
index 8f26eaddbbfb..d1d9029bf493 100644
--- a/llvm/test/MC/ELF/cfi.s
+++ b/llvm/test/MC/ELF/cfi.s
@@ -1,4 +1,5 @@
// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | llvm-readobj -S --sr --sd - | FileCheck %s
+// RUN: not llvm-mc -triple=x86_64 -o - -defsym=ERR=1 %s 2>&1 | FileCheck %s --check-prefix=ERR
f1:
.cfi_startproc
@@ -435,3 +436,20 @@ f37:
// CHECK-NEXT: 0x6E4 R_X86_64_PC32 .text 0x21
// CHECK-NEXT: ]
// CHECK: }
+
+.ifdef ERR
+// ERR: [[#@LINE+1]]:15: error: Expected an identifier
+.cfi_sections $
+// ERR: [[#@LINE+1]]:28: error: unexpected token in '.cfi_sections' directive
+.cfi_sections .debug_frame $
+// ERR: [[#@LINE+1]]:39: error: unexpected token in '.cfi_sections' directive
+.cfi_sections .debug_frame, .eh_frame $
+
+// ERR: [[#@LINE+1]]:16: error: unexpected token in '.cfi_startproc' directive
+.cfi_startproc $
+// ERR: [[#@LINE+1]]:23: error: unexpected token in '.cfi_startproc' directive
+.cfi_startproc simple $
+
+// ERR: [[#@LINE+1]]:14: error: unexpected token in '.cfi_endproc' directive
+.cfi_endproc $
+.endif
More information about the llvm-branch-commits
mailing list