[llvm] r275445 - [X86][MC] Fix bracket expression parsing in intel-style assembly.

Nirav Dave via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 14 10:37:06 PDT 2016


Author: niravd
Date: Thu Jul 14 12:37:05 2016
New Revision: 275445

URL: http://llvm.org/viewvc/llvm-project?rev=275445&view=rev
Log:
[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

Added:
    llvm/trunk/test/MC/X86/pr28547.s
Modified:
    llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp

Modified: llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp?rev=275445&r1=275444&r2=275445&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp (original)
+++ llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp Thu Jul 14 12:37:05 2016
@@ -1394,7 +1394,7 @@ X86AsmParser::ParseIntelBracExpression(u
     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(u
   // 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;

Added: llvm/trunk/test/MC/X86/pr28547.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/X86/pr28547.s?rev=275445&view=auto
==============================================================================
--- llvm/trunk/test/MC/X86/pr28547.s (added)
+++ llvm/trunk/test/MC/X86/pr28547.s Thu Jul 14 12:37:05 2016
@@ -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




More information about the llvm-commits mailing list