[llvm] [Attributor] Don't replace `AddrSpaceCast` with `ConstantPointerNull` (PR #126779)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 14 03:39:14 PST 2025


================
@@ -10970,6 +10970,15 @@ struct AAPotentialValuesImpl : AAPotentialValues {
       Value *NewV = getSingleValue(A, *this, getIRPosition(), Values);
       if (!NewV || NewV == &OldV)
         continue;
+      // FIXME: ConstantPointerNull represents a pointer with value 0, but it
+      // doesn’t necessarily mean a nullptr. `ptr addrspace(x) null` is not the
+      // same as `addrspacecast (ptr null to ptr addrspace(x))` if the nullptr
+      // in AS x is not zero. Therefore, we can't simply replace it.
+      if (isa<ConstantPointerNull>(NewV) && isa<ConstantExpr>(OldV)) {
----------------
nikic wrote:

> We still want to look through address space cast when analyzing potential pointer value and/or underlying object.

It's okay to do this for underlying objects, because the semantics allow it. But I don't think it's valid for PotentialValues.

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


More information about the llvm-commits mailing list