[llvm] [InferAddressSpaces] Infer pointer stored and then loaded from global variable (PR #159755)
Wenju He via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 22 01:47:02 PDT 2025
================
@@ -304,10 +304,24 @@ static bool isNoopPtrIntCastPair(const Operator *I2P, const DataLayout &DL,
(P2IOp0AS == I2PAS || TTI->isNoopAddrSpaceCast(P2IOp0AS, I2PAS));
}
+// Returns true if every user of a given GV are "simple" loads or stores in the
+// same function, with the store actually writing to GV.
+static bool isLocallyAccessedBySimpleLoadsStores(const GlobalVariable *GV,
+ const Function *F) {
+ return all_of(GV->users(), [=](const User *U) {
+ if (const auto *SI = dyn_cast<StoreInst>(U))
+ return SI->getPointerOperand() == GV && SI->getFunction() == F;
----------------
wenju-he wrote:
> Can you add negative tests for the data use and the wrong function
done
https://github.com/llvm/llvm-project/pull/159755
More information about the llvm-commits
mailing list