[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 05:54:14 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());
----------------
Can't you access the operator operand anyway and still handle constant expressions?


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