diff --git a/llvm/include/llvm/CodeGen/Register.h b/llvm/include/llvm/CodeGen/Register.h --- a/llvm/include/llvm/CodeGen/Register.h +++ b/llvm/include/llvm/CodeGen/Register.h @@ -40,10 +40,6 @@ /// frame index in a variable that normally holds a register. isStackSlot() /// returns true if Reg is in the range used for stack slots. /// - /// Note that isVirtualRegister() and isPhysicalRegister() cannot handle stack - /// slots, so if a variable may contains a stack slot, always check - /// isStackSlot() first. - /// static bool isStackSlot(unsigned Reg) { return MCRegister::isStackSlot(Reg); } @@ -69,8 +65,7 @@ /// Return true if the specified register number is in /// the virtual register namespace. static bool isVirtualRegister(unsigned Reg) { - assert(!isStackSlot(Reg) && "Not a register! Check isStackSlot() first."); - return Reg & MCRegister::VirtualRegFlag; + return Reg & MCRegister::VirtualRegFlag && !isStackSlot(Reg); } /// Convert a virtual register number to a 0-based index. diff --git a/llvm/include/llvm/MC/MCRegister.h b/llvm/include/llvm/MC/MCRegister.h --- a/llvm/include/llvm/MC/MCRegister.h +++ b/llvm/include/llvm/MC/MCRegister.h @@ -46,9 +46,6 @@ /// register. StackSlot values do not exist in the MC layer, see /// Register::isStackSlot() for the more information on them. /// - /// Note that isVirtualRegister() and isPhysicalRegister() cannot handle stack - /// slots, so if a variable may contains a stack slot, always check - /// isStackSlot() first. static bool isStackSlot(unsigned Reg) { return !(Reg & VirtualRegFlag) && uint32_t(Reg & ~VirtualRegFlag) >= FirstStackSlot; @@ -57,8 +54,8 @@ /// Return true if the specified register number is in /// the physical register namespace. static bool isPhysicalRegister(unsigned Reg) { - assert(!isStackSlot(Reg) && "Not a register! Check isStackSlot() first."); - return Reg >= FirstPhysicalReg && !(Reg & VirtualRegFlag); + return Reg >= FirstPhysicalReg && !(Reg & VirtualRegFlag) && + !isStackSlot(Reg); } /// Return true if the specified register number is in the physical register