[llvm] [X86AsmParser] IntelExpression: End of Statement should check for valid end state (PR #95677)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 5 12:43:18 PDT 2024
https://github.com/v01dXYZ updated https://github.com/llvm/llvm-project/pull/95677
>From c00cb207498e9e7196b484af78bbfc7bec8491fb Mon Sep 17 00:00:00 2001
From: v01dxyz <v01dxyz at v01d.xyz>
Date: Sat, 15 Jun 2024 20:20:46 +0200
Subject: [PATCH 1/3] [X86AsmParser] IntelExpression: Check for valid end state
on EndOfStatement
Fixes https://github.com/llvm/llvm-project/issues/94446
---
llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
index 6623106109316..998a61e6980eb 100644
--- a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
+++ b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
@@ -473,7 +473,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.
@@ -1897,9 +1899,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;
>From 82996ee929560269942e075aa6c876d6411e8653 Mon Sep 17 00:00:00 2001
From: v01dxyz <v01dxyz at v01d.xyz>
Date: Fri, 5 Jul 2024 21:15:01 +0200
Subject: [PATCH 2/3] [X86AsmParser] test precommit for intel expr parser
---
llvm/test/MC/X86/intel-syntax-expr.s | 8 ++++++++
1 file changed, 8 insertions(+)
create mode 100644 llvm/test/MC/X86/intel-syntax-expr.s
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..acb1d3dea5b50
--- /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: LLVM ERROR: SmallVector unable to grow. Requested capacity (4294967296) is larger than maximum value for size type (4294967295)
+test:
+i-
>From 487ca637c234aab408d41e96e73c932d36f2fe94 Mon Sep 17 00:00:00 2001
From: v01dxyz <v01dxyz at v01d.xyz>
Date: Fri, 5 Jul 2024 21:17:39 +0200
Subject: [PATCH 3/3] [X86AsmParser] test for intel expr parser
---
llvm/test/MC/X86/intel-syntax-expr.s | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/llvm/test/MC/X86/intel-syntax-expr.s b/llvm/test/MC/X86/intel-syntax-expr.s
index acb1d3dea5b50..8aa083107dd85 100644
--- a/llvm/test/MC/X86/intel-syntax-expr.s
+++ b/llvm/test/MC/X86/intel-syntax-expr.s
@@ -3,6 +3,6 @@
// 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: LLVM ERROR: SmallVector unable to grow. Requested capacity (4294967296) is larger than maximum value for size type (4294967295)
+// CHECK: error: unknown token in expression
test:
i-
More information about the llvm-commits
mailing list