From: Simon Pilgrim Date: Tue, 8 Jun 2021 16:08:14 +0000 (+0100) Subject: PPCISelLowering.cpp - don't dereference a dyn_cast<>. X-Git-Tag: llvmorg-14-init~4552 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=01b77159e30b38613ab700d8bb128b006822c58c;p=platform%2Fupstream%2Fllvm.git PPCISelLowering.cpp - don't dereference a dyn_cast<>. dyn_cast<> can return nullptr which we would then dereference - use cast<> which will assert that the type is correct. --- diff --git a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp index aefa48d..013ce0c 100644 --- a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp +++ b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp @@ -13925,7 +13925,7 @@ static SDValue combineBVZEXTLOAD(SDNode *N, SelectionDAG &DAG) { if (Operand.getOpcode() != ISD::LOAD) return SDValue(); - LoadSDNode *LD = dyn_cast(Operand); + auto *LD = cast(Operand); EVT MemoryType = LD->getMemoryVT(); // This transformation is only valid if the we are loading either a byte, @@ -16571,9 +16571,7 @@ static SDValue combineADDToADDZE(SDNode *N, SelectionDAG &DAG, SDVTList VTs = DAG.getVTList(MVT::i64, MVT::Glue); SDValue Cmp = RHS.getOperand(0); SDValue Z = Cmp.getOperand(0); - auto *Constant = dyn_cast(Cmp.getOperand(1)); - - assert(Constant && "Constant Should not be a null pointer."); + auto *Constant = cast(Cmp.getOperand(1)); int64_t NegConstant = 0 - Constant->getSExtValue(); switch(cast(Cmp.getOperand(2))->get()) { @@ -17285,8 +17283,7 @@ PPC::AddrMode PPCTargetLowering::SelectOptimalAddrMode(const SDNode *Parent, if (Flags & PPC::MOF_RPlusSImm16) { SDValue Op0 = N.getOperand(0); SDValue Op1 = N.getOperand(1); - ConstantSDNode *CN = dyn_cast(Op1); - int16_t Imm = CN->getAPIntValue().getZExtValue(); + int16_t Imm = cast(Op1)->getAPIntValue().getZExtValue(); if (!Align || isAligned(*Align, Imm)) { Disp = DAG.getTargetConstant(Imm, DL, N.getValueType()); Base = Op0; @@ -17312,7 +17309,7 @@ PPC::AddrMode PPCTargetLowering::SelectOptimalAddrMode(const SDNode *Parent, // zero or load-immediate-shifted and the displacement will be // the low 16 bits of the address. else if (Flags & PPC::MOF_AddrIsSImm32) { - ConstantSDNode *CN = dyn_cast(N); + auto *CN = cast(N); EVT CNType = CN->getValueType(0); uint64_t CNImm = CN->getZExtValue(); // If this address fits entirely in a 16-bit sext immediate field, codegen