Index: llvm/include/llvm/CodeGen/MachineRegisterInfo.h =================================================================== --- llvm/include/llvm/CodeGen/MachineRegisterInfo.h +++ llvm/include/llvm/CodeGen/MachineRegisterInfo.h @@ -214,7 +214,8 @@ } bool shouldTrackSubRegLiveness(Register VReg) const { assert(VReg.isVirtual() && "Must pass a VReg"); - return shouldTrackSubRegLiveness(*getRegClass(VReg)); + const TargetRegisterClass *RC = getRegClassOrNull(VReg); + return LLVM_LIKELY(RC) ? shouldTrackSubRegLiveness(*RC) : false; } bool subRegLivenessEnabled() const { return TracksSubRegLiveness; Index: llvm/lib/CodeGen/MachineVerifier.cpp =================================================================== --- llvm/lib/CodeGen/MachineVerifier.cpp +++ llvm/lib/CodeGen/MachineVerifier.cpp @@ -3256,26 +3256,28 @@ assert(Register::isVirtualRegister(Reg)); verifyLiveRange(LI, Reg); - LaneBitmask Mask; - LaneBitmask MaxMask = MRI->getMaxLaneMaskForVReg(Reg); - for (const LiveInterval::SubRange &SR : LI.subranges()) { - if ((Mask & SR.LaneMask).any()) { - report("Lane masks of sub ranges overlap in live interval", MF); - report_context(LI); - } - if ((SR.LaneMask & ~MaxMask).any()) { - report("Subrange lanemask is invalid", MF); - report_context(LI); - } - if (SR.empty()) { - report("Subrange must not be empty", MF); - report_context(SR, LI.reg(), SR.LaneMask); - } - Mask |= SR.LaneMask; - verifyLiveRange(SR, LI.reg(), SR.LaneMask); - if (!LI.covers(SR)) { - report("A Subrange is not covered by the main range", MF); - report_context(LI); + if (LI.hasSubRanges()) { + LaneBitmask Mask; + LaneBitmask MaxMask = MRI->getMaxLaneMaskForVReg(Reg); + for (const LiveInterval::SubRange &SR : LI.subranges()) { + if ((Mask & SR.LaneMask).any()) { + report("Lane masks of sub ranges overlap in live interval", MF); + report_context(LI); + } + if ((SR.LaneMask & ~MaxMask).any()) { + report("Subrange lanemask is invalid", MF); + report_context(LI); + } + if (SR.empty()) { + report("Subrange must not be empty", MF); + report_context(SR, LI.reg(), SR.LaneMask); + } + Mask |= SR.LaneMask; + verifyLiveRange(SR, LI.reg(), SR.LaneMask); + if (!LI.covers(SR)) { + report("A Subrange is not covered by the main range", MF); + report_context(LI); + } } }