MIR Parser: Run the machine verifier after initializing machine functions.
authorAlex Lorenz <arphaman@gmail.com>
Fri, 24 Jul 2015 17:44:49 +0000 (17:44 +0000)
committerAlex Lorenz <arphaman@gmail.com>
Fri, 24 Jul 2015 17:44:49 +0000 (17:44 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243128 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/MIRParser/MIRParser.cpp
test/CodeGen/MIR/X86/machine-instructions.mir
test/CodeGen/MIR/X86/machine-verifier.mir [new file with mode: 0644]

index a7c81ab390affc93a5b5276b32db248509522b56..383fde1101a9724e6d7e55353122d1660df57046 100644 (file)
@@ -325,6 +325,10 @@ bool MIRParserImpl::initializeMachineFunction(MachineFunction &MF) {
                                     PFS))
       return true;
   }
+  // FIXME: This is a temporary workaround until the reserved registers can be
+  // serialized.
+  MF.getRegInfo().freezeReservedRegs(MF);
+  MF.verify();
   return false;
 }
 
index 08f3d76486b15d32097be0c2d2af231dd6029d70..c319db0892b4edb3d763b7486905db59074422c4 100644 (file)
@@ -18,8 +18,8 @@ body:
  - id:           0
    name:         entry
    instructions:
-     # CHECK:      MOV32rr
-     # CHECK-NEXT: RETQ
-     - MOV32rr
-     - ' RETQ '
+     # CHECK:      MOV32rr
+     # CHECK-NEXT: RETQ
+     - '%eax = MOV32rr %eax'
+     - ' RETQ %eax'
 ...
diff --git a/test/CodeGen/MIR/X86/machine-verifier.mir b/test/CodeGen/MIR/X86/machine-verifier.mir
new file mode 100644 (file)
index 0000000..608a90e
--- /dev/null
@@ -0,0 +1,23 @@
+# RUN: not llc -march=x86-64 -start-after branch-folder -stop-after branch-folder -o /dev/null %s 2>&1 | FileCheck %s
+# This test ensures that the MIR parser runs the machine verifier after parsing.
+
+--- |
+
+  define i32 @inc(i32 %a) {
+  entry:
+    ret i32 %a
+  }
+
+...
+---
+name:            inc
+body:
+ - id:           0
+   name:         entry
+   liveins:      [ '%edi' ]
+   instructions:
+   # CHECK: *** Bad machine code: Too few operands ***
+   # CHECK: instruction: COPY2 operands expected, but 0 given.
+     - 'COPY'
+     - 'RETQ'
+...