[llvm] [InferAddressSpaces] Infer pointer stored and then loaded from global variable (PR #159755)
Wenju He via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 25 18:54:02 PST 2025
================
@@ -335,13 +349,25 @@ static bool isAddressExpression(const Value &V, const DataLayout &DL,
}
case Instruction::IntToPtr:
return isNoopPtrIntCastPair(Op, DL, TTI);
+ case Instruction::Load: {
+ const auto *LI = cast<LoadInst>(Op);
+ if (LI->getType()->isPtrOrPtrVectorTy()) {
+ // Heuristic: treat load-of-GV as an address expression only if the GV is
+ // locally accessed by load and store.
+ if (const auto *GV = dyn_cast<GlobalVariable>(LI->getPointerOperand()))
+ return isLocallyAccessedBySimpleLoadsStores(GV, LI->getFunction());
+ }
+ return TTI->getAssumedAddrSpace(&V) != UninitializedAddressSpace;
----------------
wenju-he wrote:
> The assumed address space check should take precedence over this special treatment
done
https://github.com/llvm/llvm-project/pull/159755
More information about the llvm-commits
mailing list