[llvm] [InferAddressSpaces] Infer pointer stored and then loaded from global variable (PR #159755)

Juan Manuel Martinez CaamaƱo via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 19 04:56:09 PDT 2025


================
@@ -561,9 +600,11 @@ InferAddressSpacesImpl::collectFlatAddressExpressions(Function &F) const {
       PushPtrOperand(GEP->getPointerOperand());
     } else if (auto *LI = dyn_cast<LoadInst>(&I))
       PushPtrOperand(LI->getPointerOperand());
-    else if (auto *SI = dyn_cast<StoreInst>(&I))
+    else if (auto *SI = dyn_cast<StoreInst>(&I)) {
+      if (SI->getValueOperand()->getType()->isPtrOrPtrVectorTy())
+        PushPtrOperand(SI->getValueOperand());
----------------
jmmartinez wrote:

Nitpick: add a local to avoid repetition.

```suggestion
    else if (auto *SI = dyn_cast<StoreInst>(&I)) {
      Value* V = SI->getValueOperand();
      if (V->getType()->isPtrOrPtrVectorTy())
        PushPtrOperand(V);
```

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


More information about the llvm-commits mailing list