[llvm] [InferAddressSpaces] apply InferAddressSpaces to inttoptr-zext-ptrtoint address expression. (PR #79108)

via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 21 00:13:53 PDT 2024


================
@@ -356,8 +385,8 @@ getPointerOperands(const Value &V, const DataLayout &DL,
     return {II.getArgOperand(0)};
   }
   case Instruction::IntToPtr: {
-    assert(isNoopPtrIntCastPair(&Op, DL, TTI));
-    auto *P2I = cast<Operator>(Op.getOperand(0));
+    Operator *P2I = getNoopOrExtPtrIntCastPair(&Op, DL, TTI);
+    assert(P2I != nullptr);
----------------
yujc9 wrote:

I was a bit confused, `getNoopOrExtPtrIntCastPair` is also used to determine whether it is a `isAddressExpression` (line 335). Making it end in unreachable seems contradict with this purpose. Probably you mean separate `getNoopOrExtPtrIntCastPair` into two helper functions (also consider other two comments above), one tells it is `isNoopOrExtPtrIntCastPair` while the other one returns the desired operator?

https://github.com/llvm/llvm-project/pull/79108


More information about the llvm-commits mailing list