Index: llvm/include/llvm/Transforms/Utils/LoopUtils.h =================================================================== --- llvm/include/llvm/Transforms/Utils/LoopUtils.h +++ llvm/include/llvm/Transforms/Utils/LoopUtils.h @@ -513,8 +513,8 @@ /// If the branch condition of the header is partially invariant, return a pair /// containing the instructions to duplicate and a boolean Constant to update /// the condition in the loops created for the true or false successors. -Optional hasPartialIVCondition(Loop *L, unsigned MSSAThreshold, - MemorySSA *MSSA, AAResults *AA); +Optional hasPartialIVCondition(Loop &L, unsigned MSSAThreshold, + MemorySSA &MSSA, AAResults &AA); } // end namespace llvm Index: llvm/lib/Transforms/Scalar/LoopUnswitch.cpp =================================================================== --- llvm/lib/Transforms/Scalar/LoopUnswitch.cpp +++ llvm/lib/Transforms/Scalar/LoopUnswitch.cpp @@ -847,8 +847,8 @@ // metadata, to avoid unswitching the same loop multiple times. if (MSSA && !findOptionMDForLoop(CurrentLoop, "llvm.loop.unswitch.partial.disable")) { - if (auto Info = - llvm::hasPartialIVCondition(CurrentLoop, MSSAThreshold, MSSA, AA)) { + if (auto Info = llvm::hasPartialIVCondition(*CurrentLoop, MSSAThreshold, + *MSSA, *AA)) { assert(!Info->InstToDuplicate.empty() && "need at least a partially invariant condition"); LLVM_DEBUG(dbgs() << "loop-unswitch: Found partially invariant condition " Index: llvm/lib/Transforms/Utils/LoopUtils.cpp =================================================================== --- llvm/lib/Transforms/Utils/LoopUtils.cpp +++ llvm/lib/Transforms/Utils/LoopUtils.cpp @@ -1717,18 +1717,18 @@ /// If the branch condition of the header is partially invariant, return a pair /// containing the instructions to duplicate and a boolean Constant to update /// the condition in the loops created for the true or false successors. -Optional llvm::hasPartialIVCondition(Loop *L, +Optional llvm::hasPartialIVCondition(Loop &L, unsigned MSSAThreshold, - MemorySSA *MSSA, - AAResults *AA) { - auto *TI = dyn_cast(L->getHeader()->getTerminator()); + MemorySSA &MSSA, + AAResults &AA) { + auto *TI = dyn_cast(L.getHeader()->getTerminator()); if (!TI || !TI->isConditional()) return {}; auto *CondI = dyn_cast(TI->getCondition()); // The case with the condition outside the loop should already be handled // earlier. - if (!CondI || !L->contains(CondI)) + if (!CondI || !L.contains(CondI)) return {}; SmallVector InstToDuplicate; @@ -1741,7 +1741,7 @@ SmallVector AccessedLocs; while (!WorkList.empty()) { Instruction *I = dyn_cast(WorkList.pop_back_val()); - if (!I || !L->contains(I)) + if (!I || !L.contains(I)) continue; // TODO: support additional instructions. @@ -1754,7 +1754,7 @@ return {}; InstToDuplicate.push_back(I); - if (MemoryAccess *MA = MSSA->getMemoryAccess(I)) { + if (MemoryAccess *MA = MSSA.getMemoryAccess(I)) { if (auto *MemUse = dyn_cast_or_null(MA)) { // Queue the defining access to check for alias checks. AccessesToCheck.push_back(MemUse->getDefiningAccess()); @@ -1772,9 +1772,9 @@ return {}; SmallVector ExitingBlocks; - L->getExitingBlocks(ExitingBlocks); + L.getExitingBlocks(ExitingBlocks); auto HasNoClobbersOnPath = - [L, AA, &AccessedLocs, &ExitingBlocks, &InstToDuplicate, + [&L, &AA, &AccessedLocs, &ExitingBlocks, &InstToDuplicate, MSSAThreshold](BasicBlock *Succ, BasicBlock *Header, SmallVector AccessesToCheck) -> Optional { @@ -1791,7 +1791,7 @@ while (!WorkList.empty()) { BasicBlock *Current = WorkList.pop_back_val(); - if (!L->contains(Current)) + if (!L.contains(Current)) continue; const auto &SeenIns = Seen.insert(Current); if (!SeenIns.second) @@ -1829,9 +1829,9 @@ // For a MemoryDef, check if is aliases any of the location feeding // the original condition. if (auto *CurrentDef = dyn_cast(Current)) { - if (any_of(AccessedLocs, [AA, CurrentDef](MemoryLocation &Loc) { + if (any_of(AccessedLocs, [&AA, CurrentDef](MemoryLocation &Loc) { return isModSet( - AA->getModRefInfo(CurrentDef->getMemoryInst(), Loc)); + AA.getModRefInfo(CurrentDef->getMemoryInst(), Loc)); })) return {}; } @@ -1843,7 +1843,7 @@ // We could also allow loops with known trip counts without mustprogress, // but ScalarEvolution may not be available. Info.PathIsNoop &= - L->getHeader()->getParent()->mustProgress() || hasMustProgress(L); + L.getHeader()->getParent()->mustProgress() || hasMustProgress(&L); // If the path is considered a no-op so far, check if it reaches a // single exit block without any phis. This ensures no values from the @@ -1853,7 +1853,7 @@ if (!Seen.contains(Exiting)) continue; for (auto *Succ : successors(Exiting)) { - if (L->contains(Succ)) + if (L.contains(Succ)) continue; Info.PathIsNoop &= llvm::empty(Succ->phis()) && @@ -1878,12 +1878,12 @@ if (TI->getSuccessor(0) == TI->getSuccessor(1)) return {}; - if (auto Info = HasNoClobbersOnPath(TI->getSuccessor(0), L->getHeader(), + if (auto Info = HasNoClobbersOnPath(TI->getSuccessor(0), L.getHeader(), AccessesToCheck)) { Info->KnownValue = ConstantInt::getTrue(TI->getContext()); return Info; } - if (auto Info = HasNoClobbersOnPath(TI->getSuccessor(1), L->getHeader(), + if (auto Info = HasNoClobbersOnPath(TI->getSuccessor(1), L.getHeader(), AccessesToCheck)) { Info->KnownValue = ConstantInt::getFalse(TI->getContext()); return Info;