[llvm] r244100 - MIR Parser: Report an error when parsing large immediate operands.

Alex Lorenz arphaman at gmail.com
Wed Aug 5 12:03:42 PDT 2015


Author: arphaman
Date: Wed Aug  5 14:03:42 2015
New Revision: 244100

URL: http://llvm.org/viewvc/llvm-project?rev=244100&view=rev
Log:
MIR Parser: Report an error when parsing large immediate operands.

Added:
    llvm/trunk/test/CodeGen/MIR/X86/large-immediate-operand-error.mir
Modified:
    llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp

Modified: llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp?rev=244100&r1=244099&r2=244100&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp (original)
+++ llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp Wed Aug  5 14:03:42 2015
@@ -552,8 +552,7 @@ bool MIParser::parseImmediateOperand(Mac
   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;

Added: llvm/trunk/test/CodeGen/MIR/X86/large-immediate-operand-error.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/MIR/X86/large-immediate-operand-error.mir?rev=244100&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/MIR/X86/large-immediate-operand-error.mir (added)
+++ llvm/trunk/test/CodeGen/MIR/X86/large-immediate-operand-error.mir Wed Aug  5 14:03:42 2015
@@ -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'
+...




More information about the llvm-commits mailing list