From fdb264e2635c6b02e7543f6a4bac675e62275696 Mon Sep 17 00:00:00 2001 From: "Andrew V. Tischenko" Date: Fri, 26 May 2017 13:23:34 +0000 Subject: [PATCH] The fix for PR22004: X86AsmParser.cpp asserts: OperandStack.size() > 1 && "Too few operands." llvm-svn: 303985 --- llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp | 5 +++-- llvm/test/MC/X86/pr22004.s | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 llvm/test/MC/X86/pr22004.s diff --git a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp index 32ab475..e5d3209 100644 --- a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp +++ b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp @@ -1316,16 +1316,17 @@ bool X86AsmParser::ParseIntelExpression(IntelExprStateMachine &SM, SMLoc &End) { while (!Done) { bool UpdateLocLex = true; + AsmToken::TokenKind TK = getLexer().getKind(); // The period in the dot operator (e.g., [ebx].foo.bar) is parsed as an // identifier. Don't try an parse it as a register. - if (PrevTK != AsmToken::Error && Tok.getString().startswith(".")) + if (PrevTK != AsmToken::Error && Tok.getString().startswith(".") && + TK != AsmToken::Identifier) break; // If we're parsing an immediate expression, we don't expect a '['. if (SM.getStopOnLBrac() && getLexer().getKind() == AsmToken::LBrac) break; - AsmToken::TokenKind TK = getLexer().getKind(); switch (TK) { default: { if (SM.isValidEndState()) { diff --git a/llvm/test/MC/X86/pr22004.s b/llvm/test/MC/X86/pr22004.s new file mode 100644 index 0000000..3ef1526 --- /dev/null +++ b/llvm/test/MC/X86/pr22004.s @@ -0,0 +1,3 @@ +// RUN: llvm-mc -triple x86_64-unknown-unknown -x86-asm-syntax=intel %s + +lea rax, qword ptr [rip + .L.str] -- 2.7.4