@@ -113,8 +113,6 @@ static cl::opt<bool>
113
113
GVNEnableSplitBackedgeInLoadPRE (" enable-split-backedge-in-load-pre" ,
114
114
cl::init (false ));
115
115
static cl::opt<bool > GVNEnableMemDep (" enable-gvn-memdep" , cl::init(true ));
116
- static cl::opt<bool > GVNEnableMemorySSA (" enable-gvn-memoryssa" ,
117
- cl::init (false ));
118
116
119
117
static cl::opt<uint32_t > MaxNumDeps (
120
118
" gvn-max-num-deps" , cl::Hidden, cl::init(100 ),
@@ -822,10 +820,6 @@ bool GVNPass::isMemDepEnabled() const {
822
820
return Options.AllowMemDep .value_or (GVNEnableMemDep);
823
821
}
824
822
825
- bool GVNPass::isMemorySSAEnabled () const {
826
- return Options.AllowMemorySSA .value_or (GVNEnableMemorySSA);
827
- }
828
-
829
823
PreservedAnalyses GVNPass::run (Function &F, FunctionAnalysisManager &AM) {
830
824
// FIXME: The order of evaluation of these 'getResult' calls is very
831
825
// significant! Re-ordering these variables will cause GVN when run alone to
@@ -838,10 +832,7 @@ PreservedAnalyses GVNPass::run(Function &F, FunctionAnalysisManager &AM) {
838
832
auto *MemDep =
839
833
isMemDepEnabled () ? &AM.getResult <MemoryDependenceAnalysis>(F) : nullptr ;
840
834
auto &LI = AM.getResult <LoopAnalysis>(F);
841
- auto *MSSA =
842
- isMemorySSAEnabled () ? &AM.getResult <MemorySSAAnalysis>(F) : nullptr ;
843
- assert (!(MemDep && MSSA) &&
844
- " Should not use both MemDep and MemorySSA simultaneously!" );
835
+ auto *MSSA = AM.getCachedResult <MemorySSAAnalysis>(F);
845
836
auto &ORE = AM.getResult <OptimizationRemarkEmitterAnalysis>(F);
846
837
bool Changed = runImpl (F, AC, DT, TLI, AA, MemDep, LI, &ORE,
847
838
MSSA ? &MSSA->getMSSA () : nullptr );
@@ -870,9 +861,7 @@ void GVNPass::printPipeline(
870
861
OS << (*Options.AllowLoadPRESplitBackedge ? " " : " no-" )
871
862
<< " split-backedge-load-pre;" ;
872
863
if (Options.AllowMemDep != std::nullopt)
873
- OS << (*Options.AllowMemDep ? " " : " no-" ) << " memdep;" ;
874
- if (Options.AllowMemorySSA != std::nullopt)
875
- OS << (*Options.AllowMemorySSA ? " " : " no-" ) << " memoryssa" ;
864
+ OS << (*Options.AllowMemDep ? " " : " no-" ) << " memdep" ;
876
865
OS << ' >' ;
877
866
}
878
867
@@ -3304,18 +3293,16 @@ class llvm::gvn::GVNLegacyPass : public FunctionPass {
3304
3293
public:
3305
3294
static char ID; // Pass identification, replacement for typeid
3306
3295
3307
- explicit GVNLegacyPass (bool MemDepAnalysis = GVNEnableMemDep,
3308
- bool MemSSAAnalysis = GVNEnableMemorySSA)
3309
- : FunctionPass(ID), Impl(GVNOptions()
3310
- .setMemDep(MemDepAnalysis)
3311
- .setMemorySSA(MemSSAAnalysis)) {
3296
+ explicit GVNLegacyPass (bool NoMemDepAnalysis = !GVNEnableMemDep)
3297
+ : FunctionPass(ID), Impl(GVNOptions().setMemDep(!NoMemDepAnalysis)) {
3312
3298
initializeGVNLegacyPassPass (*PassRegistry::getPassRegistry ());
3313
3299
}
3314
3300
3315
3301
bool runOnFunction (Function &F) override {
3316
3302
if (skipFunction (F))
3317
3303
return false ;
3318
3304
3305
+ auto *MSSAWP = getAnalysisIfAvailable<MemorySSAWrapperPass>();
3319
3306
return Impl.runImpl (
3320
3307
F, getAnalysis<AssumptionCacheTracker>().getAssumptionCache (F),
3321
3308
getAnalysis<DominatorTreeWrapperPass>().getDomTree (),
@@ -3326,9 +3313,7 @@ class llvm::gvn::GVNLegacyPass : public FunctionPass {
3326
3313
: nullptr ,
3327
3314
getAnalysis<LoopInfoWrapperPass>().getLoopInfo (),
3328
3315
&getAnalysis<OptimizationRemarkEmitterWrapperPass>().getORE (),
3329
- Impl.isMemorySSAEnabled ()
3330
- ? &getAnalysis<MemorySSAWrapperPass>().getMSSA ()
3331
- : nullptr );
3316
+ MSSAWP ? &MSSAWP->getMSSA () : nullptr );
3332
3317
}
3333
3318
3334
3319
void getAnalysisUsage (AnalysisUsage &AU) const override {
@@ -3344,8 +3329,7 @@ class llvm::gvn::GVNLegacyPass : public FunctionPass {
3344
3329
AU.addPreserved <TargetLibraryInfoWrapperPass>();
3345
3330
AU.addPreserved <LoopInfoWrapperPass>();
3346
3331
AU.addRequired <OptimizationRemarkEmitterWrapperPass>();
3347
- if (Impl.isMemorySSAEnabled ())
3348
- AU.addRequired <MemorySSAWrapperPass>();
3332
+ AU.addPreserved <MemorySSAWrapperPass>();
3349
3333
}
3350
3334
3351
3335
private:
@@ -3357,7 +3341,6 @@ char GVNLegacyPass::ID = 0;
3357
3341
INITIALIZE_PASS_BEGIN (GVNLegacyPass, " gvn" , " Global Value Numbering" , false , false )
3358
3342
INITIALIZE_PASS_DEPENDENCY(AssumptionCacheTracker)
3359
3343
INITIALIZE_PASS_DEPENDENCY(MemoryDependenceWrapperPass)
3360
- INITIALIZE_PASS_DEPENDENCY(MemorySSAWrapperPass)
3361
3344
INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
3362
3345
INITIALIZE_PASS_DEPENDENCY(TargetLibraryInfoWrapperPass)
3363
3346
INITIALIZE_PASS_DEPENDENCY(AAResultsWrapperPass)
@@ -3366,4 +3349,6 @@ INITIALIZE_PASS_DEPENDENCY(OptimizationRemarkEmitterWrapperPass)
3366
3349
INITIALIZE_PASS_END(GVNLegacyPass, " gvn" , " Global Value Numbering" , false , false )
3367
3350
3368
3351
// The public interface to this file...
3369
- FunctionPass *llvm::createGVNPass() { return new GVNLegacyPass (); }
3352
+ FunctionPass *llvm::createGVNPass(bool NoMemDepAnalysis) {
3353
+ return new GVNLegacyPass (NoMemDepAnalysis);
3354
+ }
0 commit comments