From 0b3444cca97d777e5aa99f76907d423904ce3508 Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Thu, 31 Jul 2014 23:26:35 +0000 Subject: [PATCH] X86 MC: Don't crash on empty memory operand parens Instead, create an absolute memory operand. Fixes PR20504. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@214457 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/X86/AsmParser/X86AsmParser.cpp | 6 ++++-- test/MC/X86/x86_operands.s | 5 +++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/Target/X86/AsmParser/X86AsmParser.cpp b/lib/Target/X86/AsmParser/X86AsmParser.cpp index 78b56b744f8..85de47be091 100644 --- a/lib/Target/X86/AsmParser/X86AsmParser.cpp +++ b/lib/Target/X86/AsmParser/X86AsmParser.cpp @@ -1880,8 +1880,10 @@ std::unique_ptr X86AsmParser::ParseMemOperand(unsigned SegReg, 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, diff --git a/test/MC/X86/x86_operands.s b/test/MC/X86/x86_operands.s index b34713db863..2258a952774 100644 --- a/test/MC/X86/x86_operands.s +++ b/test/MC/X86/x86_operands.s @@ -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