From 3f2058da16b6595a97745db43dd705421ce20bca Mon Sep 17 00:00:00 2001 From: Alex Lorenz Date: Wed, 5 Aug 2015 19:03:42 +0000 Subject: [PATCH] MIR Parser: Report an error when parsing large immediate operands. llvm-svn: 244100 --- llvm/lib/CodeGen/MIRParser/MIParser.cpp | 3 +-- .../MIR/X86/large-immediate-operand-error.mir | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 llvm/test/CodeGen/MIR/X86/large-immediate-operand-error.mir diff --git a/llvm/lib/CodeGen/MIRParser/MIParser.cpp b/llvm/lib/CodeGen/MIRParser/MIParser.cpp index 15f93ee..a30a4a9 100644 --- a/llvm/lib/CodeGen/MIRParser/MIParser.cpp +++ b/llvm/lib/CodeGen/MIRParser/MIParser.cpp @@ -552,8 +552,7 @@ bool MIParser::parseImmediateOperand(MachineOperand &Dest) { assert(Token.is(MIToken::IntegerLiteral)); const APSInt &Int = Token.integerValue(); if (Int.getMinSignedBits() > 64) - // TODO: Replace this with an error when we can parse CIMM Machine Operands. - llvm_unreachable("Can't parse large integer literals yet!"); + return error("integer literal is too large to be an immediate operand"); Dest = MachineOperand::CreateImm(Int.getExtValue()); lex(); return false; diff --git a/llvm/test/CodeGen/MIR/X86/large-immediate-operand-error.mir b/llvm/test/CodeGen/MIR/X86/large-immediate-operand-error.mir new file mode 100644 index 0000000..fead666 --- /dev/null +++ b/llvm/test/CodeGen/MIR/X86/large-immediate-operand-error.mir @@ -0,0 +1,20 @@ +# RUN: not llc -march=x86-64 -start-after branch-folder -stop-after branch-folder -o /dev/null %s 2>&1 | FileCheck %s + +--- | + + define i32 @foo() { + entry: + ret i32 42 + } + +... +--- +name: foo +body: + - id: 0 + name: entry + instructions: +# CHECK: [[@LINE+1]]:24: integer literal is too large to be an immediate operand + - '%eax = MOV32ri 12346127502983478823754212949184914' + - 'RETQ %eax' +... -- 2.7.4