================
@@ -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
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits