@@ -97,10 +97,9 @@ STATISTIC(NumGVNSimpl, "Number of instructions simplified");
97
97
STATISTIC (NumGVNEqProp, " Number of equalities propagated" );
98
98
STATISTIC (NumPRELoad, " Number of loads PRE'd" );
99
99
100
- static cl::opt<bool > EnablePRE (" enable-pre" ,
101
- cl::init (true ), cl::Hidden);
102
- static cl::opt<bool > EnableLoadPRE (" enable-load-pre" , cl::init(true ));
103
- static cl::opt<bool > EnableMemDep (" enable-gvn-memdep" , cl::init(true ));
100
+ static cl::opt<bool > GVNEnablePRE (" enable-pre" , cl::init(true ), cl::Hidden);
101
+ static cl::opt<bool > GVNEnableLoadPRE (" enable-load-pre" , cl::init(true ));
102
+ static cl::opt<bool > GVNEnableMemDep (" enable-gvn-memdep" , cl::init(true ));
104
103
105
104
// Maximum allowed recursion depth.
106
105
static cl::opt<uint32_t >
@@ -610,6 +609,17 @@ void GVN::ValueTable::verifyRemoved(const Value *V) const {
610
609
// GVN Pass
611
610
// ===----------------------------------------------------------------------===//
612
611
612
+ bool GVN::isPREEnabled () const {
613
+ return Options.AllowPRE .getValueOr (GVNEnablePRE);
614
+ }
615
+
616
+ bool GVN::isLoadPREEnabled () const {
617
+ return Options.AllowLoadPRE .getValueOr (GVNEnableLoadPRE);
618
+ }
619
+ bool GVN::isMemDepEnabled () const {
620
+ return Options.AllowMemDep .getValueOr (GVNEnableMemDep);
621
+ }
622
+
613
623
PreservedAnalyses GVN::run (Function &F, FunctionAnalysisManager &AM) {
614
624
// FIXME: The order of evaluation of these 'getResult' calls is very
615
625
// significant! Re-ordering these variables will cause GVN when run alone to
@@ -619,10 +629,11 @@ PreservedAnalyses GVN::run(Function &F, FunctionAnalysisManager &AM) {
619
629
auto &DT = AM.getResult <DominatorTreeAnalysis>(F);
620
630
auto &TLI = AM.getResult <TargetLibraryAnalysis>(F);
621
631
auto &AA = AM.getResult <AAManager>(F);
622
- auto &MemDep = AM.getResult <MemoryDependenceAnalysis>(F);
632
+ auto *MemDep =
633
+ isMemDepEnabled () ? &AM.getResult <MemoryDependenceAnalysis>(F) : nullptr ;
623
634
auto *LI = AM.getCachedResult <LoopAnalysis>(F);
624
635
auto &ORE = AM.getResult <OptimizationRemarkEmitterAnalysis>(F);
625
- bool Changed = runImpl (F, AC, DT, TLI, AA, & MemDep, LI, &ORE);
636
+ bool Changed = runImpl (F, AC, DT, TLI, AA, MemDep, LI, &ORE);
626
637
if (!Changed)
627
638
return PreservedAnalyses::all ();
628
639
PreservedAnalyses PA;
@@ -1383,7 +1394,7 @@ bool GVN::processNonLocalLoad(LoadInst *LI) {
1383
1394
}
1384
1395
1385
1396
// Step 4: Eliminate partial redundancy.
1386
- if (!EnablePRE || !EnableLoadPRE )
1397
+ if (!isPREEnabled () || !isLoadPREEnabled () )
1387
1398
return false ;
1388
1399
1389
1400
return PerformLoadPRE (LI, ValuesPerBlock, UnavailableBlocks);
@@ -2148,7 +2159,7 @@ bool GVN::runImpl(Function &F, AssumptionCache &RunAC, DominatorTree &RunDT,
2148
2159
++Iteration;
2149
2160
}
2150
2161
2151
- if (EnablePRE ) {
2162
+ if (isPREEnabled () ) {
2152
2163
// Fabricate val-num for dead-code in order to suppress assertion in
2153
2164
// performPRE().
2154
2165
assignValNumForDeadCode ();
@@ -2682,8 +2693,8 @@ class llvm::gvn::GVNLegacyPass : public FunctionPass {
2682
2693
public:
2683
2694
static char ID; // Pass identification, replacement for typeid
2684
2695
2685
- explicit GVNLegacyPass (bool NoMemDepAnalysis = !EnableMemDep )
2686
- : FunctionPass(ID), NoMemDepAnalysis( NoMemDepAnalysis) {
2696
+ explicit GVNLegacyPass (bool NoMemDepAnalysis = !GVNEnableMemDep )
2697
+ : FunctionPass(ID), Impl(GVNOptions().setMemDep(! NoMemDepAnalysis) ) {
2687
2698
initializeGVNLegacyPassPass (*PassRegistry::getPassRegistry ());
2688
2699
}
2689
2700
@@ -2698,9 +2709,9 @@ class llvm::gvn::GVNLegacyPass : public FunctionPass {
2698
2709
getAnalysis<DominatorTreeWrapperPass>().getDomTree (),
2699
2710
getAnalysis<TargetLibraryInfoWrapperPass>().getTLI (F),
2700
2711
getAnalysis<AAResultsWrapperPass>().getAAResults (),
2701
- NoMemDepAnalysis
2702
- ? nullptr
2703
- : &getAnalysis<MemoryDependenceWrapperPass>(). getMemDep () ,
2712
+ Impl. isMemDepEnabled ()
2713
+ ? &getAnalysis<MemoryDependenceWrapperPass>(). getMemDep ()
2714
+ : nullptr ,
2704
2715
LIWP ? &LIWP->getLoopInfo () : nullptr ,
2705
2716
&getAnalysis<OptimizationRemarkEmitterWrapperPass>().getORE ());
2706
2717
}
@@ -2710,7 +2721,7 @@ class llvm::gvn::GVNLegacyPass : public FunctionPass {
2710
2721
AU.addRequired <DominatorTreeWrapperPass>();
2711
2722
AU.addRequired <TargetLibraryInfoWrapperPass>();
2712
2723
AU.addRequired <LoopInfoWrapperPass>();
2713
- if (!NoMemDepAnalysis )
2724
+ if (Impl. isMemDepEnabled () )
2714
2725
AU.addRequired <MemoryDependenceWrapperPass>();
2715
2726
AU.addRequired <AAResultsWrapperPass>();
2716
2727
@@ -2723,7 +2734,6 @@ class llvm::gvn::GVNLegacyPass : public FunctionPass {
2723
2734
}
2724
2735
2725
2736
private:
2726
- bool NoMemDepAnalysis;
2727
2737
GVN Impl;
2728
2738
};
2729
2739
0 commit comments