[LiveRange] Fix inaccurate verification of live-in PhysRegs

Fix verification that a PhysReg is live in to an MBB.
isLiveIn does not handle reg units, so cannot identify when a
register would be defined because its super register is partially
defined.
Additionally a PhysReg may be partial defined at block entry and
then fully defined before any use.

Reviewed By: foad, arsenm

Differential Revision: https://reviews.llvm.org/D157086
diff --git a/llvm/lib/CodeGen/LiveRangeCalc.cpp b/llvm/lib/CodeGen/LiveRangeCalc.cpp
index 26f6e1e..f7d9e5c 100644
--- a/llvm/lib/CodeGen/LiveRangeCalc.cpp
+++ b/llvm/lib/CodeGen/LiveRangeCalc.cpp
@@ -217,13 +217,18 @@
       report_fatal_error("Use not jointly dominated by defs.");
     }
 
-    if (Register::isPhysicalRegister(PhysReg) && !MBB->isLiveIn(PhysReg)) {
-      MBB->getParent()->verify();
+    if (Register::isPhysicalRegister(PhysReg)) {
       const TargetRegisterInfo *TRI = MRI->getTargetRegisterInfo();
-      errs() << "The register " << printReg(PhysReg, TRI)
-             << " needs to be live in to " << printMBBReference(*MBB)
-             << ", but is missing from the live-in list.\n";
-      report_fatal_error("Invalid global physical register");
+      bool IsLiveIn = MBB->isLiveIn(PhysReg);
+      for (MCRegAliasIterator Alias(PhysReg, TRI, false); !IsLiveIn && Alias.isValid(); ++Alias)
+        IsLiveIn = MBB->isLiveIn(*Alias);
+      if (!IsLiveIn) {
+        MBB->getParent()->verify();
+        errs() << "The register " << printReg(PhysReg, TRI)
+               << " needs to be live in to " << printMBBReference(*MBB)
+               << ", but is missing from the live-in list.\n";
+        report_fatal_error("Invalid global physical register");
+      }
     }
 #endif
     FoundUndef |= MBB->pred_empty();