[X86] Use 'llvm_unreachable' instead of nullptr in unreachable code to

avoid static check fail

RegClassOrBank is an object of RegClassOrRegBank, which is defined as
using llvm::RegClassOrRegBank = typedef PointerUnion<const
TargetRegisterClass *, const RegisterBank *>
so control flow can not get here. Use ""llvm_unreachable" here to avoid
"null pointer" confusion.

Patch by Shengchen Kan (skan)

Differential Revision: https://reviews.llvm.org/D62006

Signed-off-by: pengfei <pengfei.wang@intel.com>
llvm-svn: 361912
This commit is contained in:
Pengfei Wang 2019-05-29 02:20:37 +00:00
parent 719322411c
commit 818c652643
2 changed files with 6 additions and 4 deletions

View File

@ -91,7 +91,9 @@ RegisterBankInfo::getRegBank(unsigned Reg, const MachineRegisterInfo &MRI,
return RB;
if (auto *RC = RegClassOrBank.dyn_cast<const TargetRegisterClass *>())
return &getRegBankFromRegClass(*RC);
return nullptr;
llvm_unreachable("RegClassOrBank is either a const RegisterBank* or "
"a const TargetRegisterClass*");
}
const TargetRegisterClass &

View File

@ -1610,8 +1610,8 @@ bool X86InstructionSelector::selectDivRem(MachineInstr &I,
assert(RegTy == MRI.getType(Op1Reg) && RegTy == MRI.getType(Op2Reg) &&
"Arguments and return value types must match");
const RegisterBank *RegRB = RBI.getRegBank(DstReg, MRI, TRI);
if (!RegRB || RegRB->getID() != X86::GPRRegBankID)
const RegisterBank &RegRB = *RBI.getRegBank(DstReg, MRI, TRI);
if (RegRB.getID() != X86::GPRRegBankID)
return false;
const static unsigned NumTypes = 4; // i8, i16, i32, i64
@ -1709,7 +1709,7 @@ bool X86InstructionSelector::selectDivRem(MachineInstr &I,
const DivRemEntry &TypeEntry = *OpEntryIt;
const DivRemEntry::DivRemResult &OpEntry = TypeEntry.ResultTable[OpIndex];
const TargetRegisterClass *RegRC = getRegClass(RegTy, *RegRB);
const TargetRegisterClass *RegRC = getRegClass(RegTy, RegRB);
if (!RBI.constrainGenericRegister(Op1Reg, *RegRC, MRI) ||
!RBI.constrainGenericRegister(Op2Reg, *RegRC, MRI) ||
!RBI.constrainGenericRegister(DstReg, *RegRC, MRI)) {