[llvm] 1799a71 - [llvm-ml] Disallow '{' and '}' at the start of a statement

Sergei Barannikov via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 25 09:44:21 PST 2023


Author: Sergei Barannikov
Date: 2023-01-25T20:44:00+03:00
New Revision: 1799a714a7a77ba6feaf33e09c554c6127ebbae6

URL: https://github.com/llvm/llvm-project/commit/1799a714a7a77ba6feaf33e09c554c6127ebbae6
DIFF: https://github.com/llvm/llvm-project/commit/1799a714a7a77ba6feaf33e09c554c6127ebbae6.diff

LOG: [llvm-ml] Disallow '{' and '}' at the start of a statement

'{', '}' and (conditionally) '*' were allowed at the start of a
statement. This behavior was copied from AsmParser, where they were
added to support Hexagon bundles (braces) and BFP memory instructions
(the star).
MASM dialect is x86-specific and does not allow these symbols to be
used at the beginning of an instruction.

Worth noting that '{' is a valid first character in AT&T syntax
(e.g. "{vex} vpmadd52huq ..."); MASM variant is to omit the braces.

Reviewed By: epastor

Differential Revision: https://reviews.llvm.org/D142321

Added: 
    llvm/test/tools/llvm-ml/label_errors.asm

Modified: 
    llvm/lib/MC/MCParser/MasmParser.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/MC/MCParser/MasmParser.cpp b/llvm/lib/MC/MCParser/MasmParser.cpp
index f38dad417aed4..570dcab34fb96 100644
--- a/llvm/lib/MC/MCParser/MasmParser.cpp
+++ b/llvm/lib/MC/MCParser/MasmParser.cpp
@@ -2125,20 +2125,6 @@ bool MasmParser::parseStatement(ParseStatementInfo &Info,
     // Treat '.' as a valid identifier in this context.
     Lex();
     IDVal = ".";
-  } else if (Lexer.is(AsmToken::LCurly)) {
-    // Treat '{' as a valid identifier in this context.
-    Lex();
-    IDVal = "{";
-
-  } else if (Lexer.is(AsmToken::RCurly)) {
-    // Treat '}' as a valid identifier in this context.
-    Lex();
-    IDVal = "}";
-  } else if (Lexer.is(AsmToken::Star) &&
-             getTargetParser().starIsStartOfStatement()) {
-    // Accept '*' as a valid start of statement.
-    Lex();
-    IDVal = "*";
   } else if (Lexer.is(AsmToken::Real)) {
     // Treat ".<number>" as a valid identifier in this context.
     IDVal = getTok().getString();

diff  --git a/llvm/test/tools/llvm-ml/label_errors.asm b/llvm/test/tools/llvm-ml/label_errors.asm
new file mode 100644
index 0000000000000..85d9569c93fd9
--- /dev/null
+++ b/llvm/test/tools/llvm-ml/label_errors.asm
@@ -0,0 +1,8 @@
+; RUN: not llvm-ml -filetype=s %s /Fo - 2>&1 \
+; RUN:   | FileCheck %s --implicit-check-not="{{[0-9]+:[0-9]+: error:}}"
+
+.code
+
+; These used to be valid label names.
+{: ; CHECK: [[@LINE]]:1: error: unexpected token at start of statement
+}: ; CHECK: [[@LINE]]:1: error: unexpected token at start of statement


        


More information about the llvm-commits mailing list