RegisterCoalescer: Do not look for regclass of IMPLICIT_DEF.
authorMatthias Braun <matze@braunis.de>
Mon, 16 Feb 2015 22:05:12 +0000 (22:05 +0000)
committerMatthias Braun <matze@braunis.de>
Mon, 16 Feb 2015 22:05:12 +0000 (22:05 +0000)
IMPLICIT_DEF is a generic instruction and has no (fixed) output register
class defined. The rematerialization code of the register coalescer
should not scan the instruction description for a register class.

This fixes a problem showing up in
test/CodeGen/R600/subreg-coalescer-crash.ll with subregister liveness
enabled.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229443 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/RegisterCoalescer.cpp

index 65b0e5026f095a8c4f71f4645bec1771149bf333..edcd7b22d3cbc9e2b19d7c15e2183129e0896ce7 100644 (file)
@@ -913,12 +913,13 @@ bool RegisterCoalescer::reMaterializeTrivialDef(CoalescerPair &CP,
     const TargetRegisterClass *NewRC = CP.getNewRC();
     unsigned NewIdx = NewMI->getOperand(0).getSubReg();
 
-    if (NewIdx)
-      NewRC = TRI->getMatchingSuperRegClass(NewRC, DefRC, NewIdx);
-    else
-      NewRC = TRI->getCommonSubClass(NewRC, DefRC);
-
-    assert(NewRC && "subreg chosen for remat incompatible with instruction");
+    if (DefRC != nullptr) {
+      if (NewIdx)
+        NewRC = TRI->getMatchingSuperRegClass(NewRC, DefRC, NewIdx);
+      else
+        NewRC = TRI->getCommonSubClass(NewRC, DefRC);
+      assert(NewRC && "subreg chosen for remat incompatible with instruction");
+    }
     MRI->setRegClass(DstReg, NewRC);
 
     updateRegDefsUses(DstReg, DstReg, DstIdx);