diff --git a/llvm/include/llvm/CodeGen/MachineBasicBlock.h b/llvm/include/llvm/CodeGen/MachineBasicBlock.h index 9c563d761c1d9..be3621a8d1d0b 100644 --- a/llvm/include/llvm/CodeGen/MachineBasicBlock.h +++ b/llvm/include/llvm/CodeGen/MachineBasicBlock.h @@ -134,8 +134,10 @@ class MachineBasicBlock MCRegister PhysReg; LaneBitmask LaneMask; - RegisterMaskPair(MCPhysReg PhysReg, LaneBitmask LaneMask) - : PhysReg(PhysReg), LaneMask(LaneMask) {} + RegisterMaskPair(MCRegister PhysReg, LaneBitmask LaneMask) + : PhysReg(PhysReg), LaneMask(LaneMask) { + assert(PhysReg.isPhysical()); + } bool operator==(const RegisterMaskPair &other) const { return PhysReg == other.PhysReg && LaneMask == other.LaneMask; diff --git a/llvm/lib/CodeGen/MachineBasicBlock.cpp b/llvm/lib/CodeGen/MachineBasicBlock.cpp index 37fe37fd6e423..8e30ce79a2cd7 100644 --- a/llvm/lib/CodeGen/MachineBasicBlock.cpp +++ b/llvm/lib/CodeGen/MachineBasicBlock.cpp @@ -598,6 +598,7 @@ void MachineBasicBlock::printAsOperand(raw_ostream &OS, } void MachineBasicBlock::removeLiveIn(MCRegister Reg, LaneBitmask LaneMask) { + assert(Reg.isPhysical()); LiveInVector::iterator I = find_if( LiveIns, [Reg](const RegisterMaskPair &LI) { return LI.PhysReg == Reg; }); if (I == LiveIns.end()) @@ -616,6 +617,7 @@ MachineBasicBlock::removeLiveIn(MachineBasicBlock::livein_iterator I) { } bool MachineBasicBlock::isLiveIn(MCRegister Reg, LaneBitmask LaneMask) const { + assert(Reg.isPhysical()); livein_iterator I = find_if( LiveIns, [Reg](const RegisterMaskPair &LI) { return LI.PhysReg == Reg; }); return I != livein_end() && (I->LaneMask & LaneMask).any(); @@ -1657,6 +1659,7 @@ MachineBasicBlock::LivenessQueryResult MachineBasicBlock::computeRegisterLiveness(const TargetRegisterInfo *TRI, MCRegister Reg, const_iterator Before, unsigned Neighborhood) const { + assert(Reg.isPhysical()); unsigned N = Neighborhood; // Try searching forwards from Before, looking for reads or defs. diff --git a/llvm/lib/CodeGen/RegAllocFast.cpp b/llvm/lib/CodeGen/RegAllocFast.cpp index bb118dd9e1867..8a54d5c901f59 100644 --- a/llvm/lib/CodeGen/RegAllocFast.cpp +++ b/llvm/lib/CodeGen/RegAllocFast.cpp @@ -503,7 +503,7 @@ bool RegAllocFastImpl::mayBeSpillFromInlineAsmBr(const MachineInstr &MI) const { if (MBB->isInlineAsmBrIndirectTarget() && TII->isStoreToStackSlot(MI, FI) && MFI->isSpillSlotObjectIndex(FI)) for (const auto &Op : MI.operands()) - if (Op.isReg() && MBB->isLiveIn(Op.getReg())) + if (Op.isReg() && Op.getReg().isValid() && MBB->isLiveIn(Op.getReg())) return true; return false; }