[llvm] r245315 - MIR Parser: Implicit register verifier should accept unexpected implicit

Alex Lorenz via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 18 10:17:13 PDT 2015


Author: arphaman
Date: Tue Aug 18 12:17:13 2015
New Revision: 245315

URL: http://llvm.org/viewvc/llvm-project?rev=245315&view=rev
Log:
MIR Parser: Implicit register verifier should accept unexpected implicit
subregister operands.

Modified:
    llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp
    llvm/trunk/test/CodeGen/MIR/X86/implicit-register-flag.mir

Modified: llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp?rev=245315&r1=245314&r2=245315&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp (original)
+++ llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp Tue Aug 18 12:17:13 2015
@@ -695,6 +695,19 @@ bool MIParser::verifyImplicitOperands(
       if (ImplicitOperand.isIdenticalTo(Operand))
         continue;
       if (Operand.isReg() && Operand.isImplicit()) {
+        // Check if this implicit register is a subregister of an explicit
+        // register operand.
+        bool IsImplicitSubRegister = false;
+        for (size_t K = 0, E = Operands.size(); K < E; ++K) {
+          const auto &Op = Operands[K].Operand;
+          if (Op.isReg() && !Op.isImplicit() &&
+              TRI->isSubRegister(Op.getReg(), Operand.getReg())) {
+            IsImplicitSubRegister = true;
+            break;
+          }
+        }
+        if (IsImplicitSubRegister)
+          continue;
         return error(Operands[J].Begin,
                      Twine("expected an implicit register operand '") +
                          printImplicitRegisterFlag(ImplicitOperand) + " %" +

Modified: llvm/trunk/test/CodeGen/MIR/X86/implicit-register-flag.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/MIR/X86/implicit-register-flag.mir?rev=245315&r1=245314&r2=245315&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/MIR/X86/implicit-register-flag.mir (original)
+++ llvm/trunk/test/CodeGen/MIR/X86/implicit-register-flag.mir Tue Aug 18 12:17:13 2015
@@ -16,6 +16,16 @@
     ret i32 %a
   }
 
+  define i1 @implicit_subregister1() {
+  entry:
+    ret i1 false
+  }
+
+  define i16 @implicit_subregister2() {
+  entry:
+    ret i16 0
+  }
+
 ...
 ---
 name:            foo
@@ -36,3 +46,23 @@ body: |
     %eax = COPY %edi
     RETQ %eax
 ...
+---
+name:            implicit_subregister1
+body: |
+  bb.0.entry:
+  ; Verify that the implicit register verifier won't report an error on implicit
+  ; subregisters.
+  ; CHECK-LABEL: name: implicit_subregister1
+  ; CHECK: dead %eax = XOR32rr undef %eax, undef %eax, implicit-def dead %eflags, implicit-def %al
+    dead %eax = XOR32rr undef %eax, undef %eax, implicit-def dead %eflags, implicit-def %al
+    RETQ killed %al
+...
+---
+name:            implicit_subregister2
+body: |
+  bb.0.entry:
+  ; CHECK-LABEL: name: implicit_subregister2
+  ; CHECK: dead %r15 = XOR64rr undef %r15, undef %r15, implicit-def dead %eflags, implicit-def %r15w
+    dead %r15 = XOR64rr undef %r15, undef %r15, implicit-def dead %eflags, implicit-def %r15w
+    RETQ killed %r15w
+...




More information about the llvm-commits mailing list