[PATCH] D105002: [InferAddressSpaces] NFC: Check type before casting operands to PtrToIntInst

Matt Arsenault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 28 06:22:07 PDT 2021


arsenm added inline comments.


================
Comment at: llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp:473
       if (isNoopPtrIntCastPair(cast<Operator>(I2P), *DL, TTI))
-        PushPtrOperand(
-            cast<PtrToIntInst>(I2P->getOperand(0))->getPointerOperand());
+        if (PtrToIntInst *P2I = dyn_cast<PtrToIntInst>(I2P->getOperand(0)))
+          PushPtrOperand(P2I->getPointerOperand());
----------------
rksharma wrote:
> rksharma wrote:
> > arsenm wrote:
> > > Can't you access the operator operand anyway and still handle constant expressions?
> > Are you saying something like,  
> > ```
> > PushPtrOperand(cast<Operator>(I2P->getOperand(0))->getOperand(0));
> > ```
> Yes, this will work because it does check for constant expressions inside PushPtrOperand
Yes


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105002/new/

https://reviews.llvm.org/D105002



More information about the llvm-commits mailing list