[llvm] r214457 - X86 MC: Don't crash on empty memory operand parens

Reid Kleckner reid at kleckner.net
Thu Jul 31 16:26:35 PDT 2014


Author: rnk
Date: Thu Jul 31 18:26:35 2014
New Revision: 214457

URL: http://llvm.org/viewvc/llvm-project?rev=214457&view=rev
Log:
X86 MC: Don't crash on empty memory operand parens

Instead, create an absolute memory operand.

Fixes PR20504.

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

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=214457&r1=214456&r2=214457&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp (original)
+++ llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp Thu Jul 31 18:26:35 2014
@@ -1880,8 +1880,10 @@ std::unique_ptr<X86Operand> X86AsmParser
     return nullptr;
   }
 
-  return X86Operand::CreateMem(SegReg, Disp, BaseReg, IndexReg, Scale,
-                               MemStart, MemEnd);
+  if (SegReg || BaseReg || IndexReg)
+    return X86Operand::CreateMem(SegReg, Disp, BaseReg, IndexReg, Scale,
+                                 MemStart, MemEnd);
+  return X86Operand::CreateMem(Disp, MemStart, MemEnd);
 }
 
 bool X86AsmParser::ParseInstruction(ParseInstructionInfo &Info, StringRef Name,

Modified: llvm/trunk/test/MC/X86/x86_operands.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/X86/x86_operands.s?rev=214457&r1=214456&r2=214457&view=diff
==============================================================================
--- llvm/trunk/test/MC/X86/x86_operands.s (original)
+++ llvm/trunk/test/MC/X86/x86_operands.s Thu Jul 31 18:26:35 2014
@@ -52,6 +52,11 @@
         call *%eax
 # CHECK: calll *4(%eax)
         call *4(%eax)
+foo:
+	calll foo()
+# CHECK: calll foo{{$}}
+	calll foo(,)
+# CHECK: calll foo{{$}}
 
 # CHECK: movl	%gs:8, %eax
 movl %gs:8, %eax





More information about the llvm-commits mailing list