[flang-commits] [clang] [flang] [lld] [llvm] [polly] [Option] Make Passes, Scalar, Instrumentation, and CGData options per-context (PR #232599)
Alexis Engelke via flang-commits
flang-commits at lists.llvm.org
Fri Oct 16 03:15:13 PDT 2026
================
@@ -4377,55 +4377,51 @@ class GVNLegacyPass : public FunctionPass {
public:
static char ID; // Pass identification, replacement for typeid.
- explicit GVNLegacyPass(
- bool MemDepAnalysis = valueOr(ScalarOptions::Global.enable_gvn_memdep,
- true),
- bool MemSSAAnalysis = ScalarOptions::Global.enable_gvn_memoryssa,
- bool ScalarPRE = true)
- : FunctionPass(ID), Impl(GVNOptions()
- .setMemDep(MemDepAnalysis)
- .setMemorySSA(MemSSAAnalysis)
- .setScalarPRE(ScalarPRE)) {
+ explicit GVNLegacyPass(bool ScalarPRE = true)
+ : FunctionPass(ID), Impl(GVNOptions().setScalarPRE(ScalarPRE)) {
initializeGVNLegacyPassPass(*PassRegistry::getPassRegistry());
}
bool runOnFunction(Function &F) override {
if (skipFunction(F))
return false;
- auto *MSSAWP = getAnalysisIfAvailable<MemorySSAWrapperPass>();
- if (Impl.isMemorySSAEnabled() && !MSSAWP)
- MSSAWP = &getAnalysis<MemorySSAWrapperPass>();
+ Impl.Opts = &F.getContext().getLibraryOptions().get<ScalarOptions>();
+ auto &DT = getAnalysis<DominatorTreeWrapperPass>().getDomTree();
+ auto &AA = getAnalysis<AAResultsWrapperPass>().getAAResults();
+ MemorySSA *MSSA = nullptr;
+ std::unique_ptr<MemorySSA> LocalMSSA;
+ if (auto *MSSAWP = getAnalysisIfAvailable<MemorySSAWrapperPass>()) {
+ MSSA = &MSSAWP->getMSSA();
+ } else if (Impl.isMemorySSAEnabled()) {
+ // getAnalysisUsage cannot read the context's -enable-gvn-memoryssa.
+ LocalMSSA = std::make_unique<MemorySSA>(F, &AA, &DT);
+ MSSA = LocalMSSA.get();
+ }
----------------
aengelke wrote:
A bit hacky, but the only user is AMDGPU which AFAIK doesn't use GVN w/MemorySSA. Is this code ever tested?
https://github.com/llvm/llvm-project/pull/232599
More information about the flang-commits
mailing list