[llvm] [GVN] MemorySSA for GVN: embed the memory state in symbolic expressions (PR #123218)
Antonio Frighetto via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 2 03:09:09 PDT 2025
================
@@ -595,15 +608,48 @@ uint32_t GVNPass::ValueTable::lookupOrAddCall(CallInst *C) {
return V;
}
+ if (MSSA && AA->onlyReadsMemory(C)) {
+ Expression Exp = createExpr(C);
+ addMemoryStateToExp(C, Exp);
+ auto [V, _] = assignExpNewValueNum(Exp);
+ ValueNumbering[C] = V;
+ return V;
+ }
+
ValueNumbering[C] = NextValueNumber;
return NextValueNumber++;
}
+/// Returns the value number for the specified load or store instruction.
+uint32_t GVNPass::ValueTable::lookupOrAddLoadStore(Instruction *I) {
----------------
antoniofrighetto wrote:
I assume it was historically called this way as to align with the other routines. Though, indeed, `lookupOrAddCall` doesn't seem to do any lookup either, except for calling back `lookupOrAdd` indirectly for the call-site args (which also happens here in lookupOrAddLoadStore for the memory state). I don't think we should do any VN lookup here as already done in lookupOrAdd. Changed to `computeLoadStoreVN`, hopefully should make more sense (I think `lookupOrAddCall` could be renamed too...).
https://github.com/llvm/llvm-project/pull/123218
More information about the llvm-commits
mailing list