From 29b7bfa64f9b7ecb33ec4c1de2a0f4f05f0c82e1 Mon Sep 17 00:00:00 2001 From: Nirav Dave Date: Thu, 14 Jul 2016 17:37:05 +0000 Subject: [PATCH] [X86][MC] Fix bracket expression parsing in intel-style assembly. Only perform struct field check on Identifier tokens. Fixes PR28547. Reviewers: rnk Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D22361 llvm-svn: 275445 --- lib/Target/X86/AsmParser/X86AsmParser.cpp | 7 +++++-- test/MC/X86/pr28547.s | 5 +++++ 2 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 test/MC/X86/pr28547.s diff --git a/lib/Target/X86/AsmParser/X86AsmParser.cpp b/lib/Target/X86/AsmParser/X86AsmParser.cpp index d016ae0c57d..4e0ad8bfe1f 100644 --- a/lib/Target/X86/AsmParser/X86AsmParser.cpp +++ b/lib/Target/X86/AsmParser/X86AsmParser.cpp @@ -1394,7 +1394,7 @@ X86AsmParser::ParseIntelBracExpression(unsigned SegReg, SMLoc Start, return ErrorOperand(BracLoc, "Expected '[' token!"); Parser.Lex(); // Eat '[' - SMLoc StartInBrac = Tok.getLoc(); + SMLoc StartInBrac = Parser.getTok().getLoc(); // Parse [ Symbol + ImmDisp ] and [ BaseReg + Scale*IndexReg + ImmDisp ]. We // may have already parsed an immediate displacement before the bracketed // expression. @@ -1423,7 +1423,10 @@ X86AsmParser::ParseIntelBracExpression(unsigned SegReg, SMLoc Start, // Parse struct field access. Intel requires a dot, but MSVC doesn't. MSVC // will in fact do global lookup the field name inside all global typedefs, // but we don't emulate that. - if (Tok.getString().find('.') != StringRef::npos) { + if ((Parser.getTok().getKind() == AsmToken::Identifier || + Parser.getTok().getKind() == AsmToken::Dot || + Parser.getTok().getKind() == AsmToken::Real) && + Parser.getTok().getString().find('.') != StringRef::npos) { const MCExpr *NewDisp; if (ParseIntelDotOperator(Disp, NewDisp)) return nullptr; diff --git a/test/MC/X86/pr28547.s b/test/MC/X86/pr28547.s new file mode 100644 index 00000000000..cb90c5a60c1 --- /dev/null +++ b/test/MC/X86/pr28547.s @@ -0,0 +1,5 @@ +// RUN: llvm-mc -triple x86_64-unknown-unknown %s + .intel_syntax +ones: + .float +1.0, +1.0, +1.0, +1.0 + vmovaps xmm15, xmmword ptr [rip+ones] # +1.0, +1.0, +1.0, +1.0