@@ -760,7 +760,7 @@ PreservedAnalyses GVNPass::run(Function &F, FunctionAnalysisManager &AM) {
760
760
auto &AA = AM.getResult <AAManager>(F);
761
761
auto *MemDep =
762
762
isMemDepEnabled () ? &AM.getResult <MemoryDependenceAnalysis>(F) : nullptr ;
763
- auto * LI = AM.getCachedResult <LoopAnalysis>(F);
763
+ auto & LI = AM.getResult <LoopAnalysis>(F);
764
764
auto *MSSA = AM.getCachedResult <MemorySSAAnalysis>(F);
765
765
auto &ORE = AM.getResult <OptimizationRemarkEmitterAnalysis>(F);
766
766
bool Changed = runImpl (F, AC, DT, TLI, AA, MemDep, LI, &ORE,
@@ -772,8 +772,7 @@ PreservedAnalyses GVNPass::run(Function &F, FunctionAnalysisManager &AM) {
772
772
PA.preserve <TargetLibraryAnalysis>();
773
773
if (MSSA)
774
774
PA.preserve <MemorySSAAnalysis>();
775
- if (LI)
776
- PA.preserve <LoopAnalysis>();
775
+ PA.preserve <LoopAnalysis>();
777
776
return PA;
778
777
}
779
778
@@ -1434,8 +1433,7 @@ void GVNPass::eliminatePartiallyRedundantLoad(
1434
1433
if (auto *RangeMD = Load->getMetadata (LLVMContext::MD_range))
1435
1434
NewLoad->setMetadata (LLVMContext::MD_range, RangeMD);
1436
1435
if (auto *AccessMD = Load->getMetadata (LLVMContext::MD_access_group))
1437
- if (LI &&
1438
- LI->getLoopFor (Load->getParent ()) == LI->getLoopFor (UnavailableBlock))
1436
+ if (LI->getLoopFor (Load->getParent ()) == LI->getLoopFor (UnavailableBlock))
1439
1437
NewLoad->setMetadata (LLVMContext::MD_access_group, AccessMD);
1440
1438
1441
1439
// We do not propagate the old load's debug location, because the new
@@ -1743,9 +1741,6 @@ bool GVNPass::PerformLoadPRE(LoadInst *Load, AvailValInBlkVect &ValuesPerBlock,
1743
1741
bool GVNPass::performLoopLoadPRE (LoadInst *Load,
1744
1742
AvailValInBlkVect &ValuesPerBlock,
1745
1743
UnavailBlkVect &UnavailableBlocks) {
1746
- if (!LI)
1747
- return false ;
1748
-
1749
1744
const Loop *L = LI->getLoopFor (Load->getParent ());
1750
1745
// TODO: Generalize to other loop blocks that dominate the latch.
1751
1746
if (!L || L->getHeader () != Load->getParent ())
@@ -1914,7 +1909,7 @@ bool GVNPass::processNonLocalLoad(LoadInst *Load) {
1914
1909
// Step 4: Eliminate partial redundancy.
1915
1910
if (!isPREEnabled () || !isLoadPREEnabled ())
1916
1911
return Changed;
1917
- if (!isLoadInLoopPREEnabled () && LI && LI ->getLoopFor (Load->getParent ()))
1912
+ if (!isLoadInLoopPREEnabled () && LI->getLoopFor (Load->getParent ()))
1918
1913
return Changed;
1919
1914
1920
1915
if (performLoopLoadPRE (Load, ValuesPerBlock, UnavailableBlocks) ||
@@ -2686,7 +2681,7 @@ bool GVNPass::processInstruction(Instruction *I) {
2686
2681
// / runOnFunction - This is the main transformation entry point for a function.
2687
2682
bool GVNPass::runImpl (Function &F, AssumptionCache &RunAC, DominatorTree &RunDT,
2688
2683
const TargetLibraryInfo &RunTLI, AAResults &RunAA,
2689
- MemoryDependenceResults *RunMD, LoopInfo * LI,
2684
+ MemoryDependenceResults *RunMD, LoopInfo & LI,
2690
2685
OptimizationRemarkEmitter *RunORE, MemorySSA *MSSA) {
2691
2686
AC = &RunAC;
2692
2687
DT = &RunDT;
@@ -2696,7 +2691,7 @@ bool GVNPass::runImpl(Function &F, AssumptionCache &RunAC, DominatorTree &RunDT,
2696
2691
MD = RunMD;
2697
2692
ImplicitControlFlowTracking ImplicitCFT;
2698
2693
ICF = &ImplicitCFT;
2699
- this ->LI = LI;
2694
+ this ->LI = & LI;
2700
2695
VN.setMemDep (MD);
2701
2696
ORE = RunORE;
2702
2697
InvalidBlockRPONumbers = true ;
@@ -2710,7 +2705,7 @@ bool GVNPass::runImpl(Function &F, AssumptionCache &RunAC, DominatorTree &RunDT,
2710
2705
// Merge unconditional branches, allowing PRE to catch more
2711
2706
// optimization opportunities.
2712
2707
for (BasicBlock &BB : llvm::make_early_inc_range (F)) {
2713
- bool removedBlock = MergeBlockIntoPredecessor (&BB, &DTU, LI, MSSAU, MD);
2708
+ bool removedBlock = MergeBlockIntoPredecessor (&BB, &DTU, & LI, MSSAU, MD);
2714
2709
if (removedBlock)
2715
2710
++NumGVNBlocks;
2716
2711
@@ -3286,8 +3281,6 @@ class llvm::gvn::GVNLegacyPass : public FunctionPass {
3286
3281
if (skipFunction (F))
3287
3282
return false ;
3288
3283
3289
- auto &LIWP = getAnalysis<LoopInfoWrapperPass>();
3290
-
3291
3284
auto *MSSAWP = getAnalysisIfAvailable<MemorySSAWrapperPass>();
3292
3285
return Impl.runImpl (
3293
3286
F, getAnalysis<AssumptionCacheTracker>().getAssumptionCache (F),
@@ -3297,7 +3290,7 @@ class llvm::gvn::GVNLegacyPass : public FunctionPass {
3297
3290
Impl.isMemDepEnabled ()
3298
3291
? &getAnalysis<MemoryDependenceWrapperPass>().getMemDep ()
3299
3292
: nullptr ,
3300
- &LIWP .getLoopInfo (),
3293
+ getAnalysis<LoopInfoWrapperPass>() .getLoopInfo (),
3301
3294
&getAnalysis<OptimizationRemarkEmitterWrapperPass>().getORE (),
3302
3295
MSSAWP ? &MSSAWP->getMSSA () : nullptr );
3303
3296
}
0 commit comments