Skip to content

Commit

Permalink
[X86] X86tcret_1reg - use cast<> instead of dyn_cast<> to avoid deref…
Browse files Browse the repository at this point in the history
…erence of nullptr

The pointer is always dereferenced, so assert the cast is correct instead of returning nullptr
  • Loading branch information
RKSimon committed Feb 17, 2022
1 parent f1877eb commit ada6bcc
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions llvm/lib/Target/X86/X86InstrCompiler.td
Expand Up @@ -1239,8 +1239,7 @@ def X86tcret_1reg : PatFrag<(ops node:$ptr, node:$off),
(X86tcret node:$ptr, node:$off), [{
// X86tcret args: (*chain, ptr, imm, regs..., glue)
unsigned NumRegs = 1;
LoadSDNode* ld = dyn_cast<LoadSDNode>(N->getOperand(1));
const SDValue& BasePtr = ld->getBasePtr();
const SDValue& BasePtr = cast<LoadSDNode>(N->getOperand(1))->getBasePtr();
if (isa<FrameIndexSDNode>(BasePtr))
NumRegs = 3;
else if (BasePtr->getNumOperands() && isa<GlobalAddressSDNode>(BasePtr->getOperand(0)))
Expand Down

0 comments on commit ada6bcc

Please sign in to comment.