[llvm] 25752a4 - [X86AsmParser] IntelExpression: End of Statement should check for valid end state (#95677)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 15 18:30:23 PDT 2024
Author: v01dXYZ
Date: 2024-07-16T09:30:19+08:00
New Revision: 25752a40b8b224e3695edd506f304866f065ca9a
URL: https://github.com/llvm/llvm-project/commit/25752a40b8b224e3695edd506f304866f065ca9a
DIFF: https://github.com/llvm/llvm-project/commit/25752a40b8b224e3695edd506f304866f065ca9a.diff
LOG: [X86AsmParser] IntelExpression: End of Statement should check for valid end state (#95677)
The following commit bfb7099eeb9b6f62510b1db0cb93a8c3cfa68236 added a
special case for End of Statement that doesn't check if the state
machine is rightfully in a state where ending is valid.
This PR suggest to revert this change to make `EndOfStatement` processed
as any other tokens that are not consumable by the state machine.
Fixes https://github.com/llvm/llvm-project/issues/94446
---------
Co-authored-by: v01dxyz <v01dxyz at v01d.xyz>
Added:
llvm/test/MC/X86/intel-syntax-expr.s
Modified:
llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
index e49e96ceef6a4..daf982322bce9 100644
--- a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
+++ b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
@@ -475,7 +475,9 @@ class X86AsmParser : public MCTargetAsmParser {
unsigned getLength() const { return CurType.Length; }
int64_t getImm() { return Imm + IC.execute(); }
bool isValidEndState() const {
- return State == IES_RBRAC || State == IES_INTEGER;
+ return State == IES_RBRAC || State == IES_RPAREN ||
+ State == IES_INTEGER || State == IES_REGISTER ||
+ State == IES_OFFSET;
}
// Is the intel expression appended after an operand index.
@@ -1898,9 +1900,6 @@ bool X86AsmParser::ParseIntelExpression(IntelExprStateMachine &SM, SMLoc &End) {
case AsmToken::Error:
return Error(getLexer().getErrLoc(), getLexer().getErr());
break;
- case AsmToken::EndOfStatement:
- Done = true;
- break;
case AsmToken::Real:
// DotOperator: [ebx].0
UpdateLocLex = false;
diff --git a/llvm/test/MC/X86/intel-syntax-expr.s b/llvm/test/MC/X86/intel-syntax-expr.s
new file mode 100644
index 0000000000000..8aa083107dd85
--- /dev/null
+++ b/llvm/test/MC/X86/intel-syntax-expr.s
@@ -0,0 +1,8 @@
+// RUN: not llvm-mc -triple x86_64-unknown-unknown -x86-asm-syntax=intel %s 2>&1 | FileCheck %s
+
+// When the intel syntax is enabled, to parse an operand, X86AsmParser doesn't use the method parseExpression from AsmParser
+// but ParseIntelExpr which was not processing well an end of statement.
+
+// CHECK: error: unknown token in expression
+test:
+i-
More information about the llvm-commits
mailing list