Skip to content

Commit

Permalink
[NewPM] Remove LoopSinkLegacy Pass (#72811)
Browse files Browse the repository at this point in the history
This pass isn't used anywhere and thus has no test coverage. For these
reasons, remove it.
  • Loading branch information
boomanaiden154 committed Nov 20, 2023
1 parent d715e2c commit b9975ce
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 67 deletions.
1 change: 0 additions & 1 deletion llvm/include/llvm/InitializePasses.h
Expand Up @@ -157,7 +157,6 @@ void initializeLazyMachineBlockFrequencyInfoPassPass(PassRegistry&);
void initializeLazyValueInfoPrinterPass(PassRegistry&);
void initializeLazyValueInfoWrapperPassPass(PassRegistry&);
void initializeLegacyLICMPassPass(PassRegistry&);
void initializeLegacyLoopSinkPassPass(PassRegistry&);
void initializeLegalizerPass(PassRegistry&);
void initializeGISelCSEAnalysisWrapperPassPass(PassRegistry &);
void initializeGISelKnownBitsAnalysisPass(PassRegistry &);
Expand Down
1 change: 0 additions & 1 deletion llvm/include/llvm/LinkAllPasses.h
Expand Up @@ -87,7 +87,6 @@ namespace {
(void) llvm::createKCFIPass();
(void) llvm::createLCSSAPass();
(void) llvm::createLICMPass();
(void) llvm::createLoopSinkPass();
(void) llvm::createLazyValueInfoPass();
(void) llvm::createLoopExtractorPass();
(void) llvm::createLoopPredicationPass();
Expand Down
7 changes: 0 additions & 7 deletions llvm/include/llvm/Transforms/Scalar.h
Expand Up @@ -61,13 +61,6 @@ FunctionPass *createSROAPass(bool PreserveCFG = true);
//
Pass *createLICMPass();

//===----------------------------------------------------------------------===//
//
// LoopSink - This pass sinks invariants from preheader to loop body where
// frequency is lower than loop preheader.
//
Pass *createLoopSinkPass();

//===----------------------------------------------------------------------===//
//
// LoopPredication - This pass does loop predication on guards.
Expand Down
57 changes: 0 additions & 57 deletions llvm/lib/Transforms/Scalar/LoopSink.cpp
Expand Up @@ -36,13 +36,11 @@
#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/Analysis/BlockFrequencyInfo.h"
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Analysis/LoopPass.h"
#include "llvm/Analysis/MemorySSA.h"
#include "llvm/Analysis/MemorySSAUpdater.h"
#include "llvm/Analysis/ScalarEvolution.h"
#include "llvm/IR/Dominators.h"
#include "llvm/IR/Instructions.h"
#include "llvm/InitializePasses.h"
#include "llvm/Support/BranchProbability.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Transforms/Scalar.h"
Expand Down Expand Up @@ -390,58 +388,3 @@ PreservedAnalyses LoopSinkPass::run(Function &F, FunctionAnalysisManager &FAM) {

return PA;
}

namespace {
struct LegacyLoopSinkPass : public LoopPass {
static char ID;
LegacyLoopSinkPass() : LoopPass(ID) {
initializeLegacyLoopSinkPassPass(*PassRegistry::getPassRegistry());
}

bool runOnLoop(Loop *L, LPPassManager &LPM) override {
if (skipLoop(L))
return false;

BasicBlock *Preheader = L->getLoopPreheader();
if (!Preheader)
return false;

// Enable LoopSink only when runtime profile is available.
// With static profile, the sinking decision may be sub-optimal.
if (!Preheader->getParent()->hasProfileData())
return false;

AAResults &AA = getAnalysis<AAResultsWrapperPass>().getAAResults();
MemorySSA &MSSA = getAnalysis<MemorySSAWrapperPass>().getMSSA();
auto *SE = getAnalysisIfAvailable<ScalarEvolutionWrapperPass>();
bool Changed = sinkLoopInvariantInstructions(
*L, AA, getAnalysis<LoopInfoWrapperPass>().getLoopInfo(),
getAnalysis<DominatorTreeWrapperPass>().getDomTree(),
getAnalysis<BlockFrequencyInfoWrapperPass>().getBFI(),
MSSA, SE ? &SE->getSE() : nullptr);

if (VerifyMemorySSA)
MSSA.verifyMemorySSA();

return Changed;
}

void getAnalysisUsage(AnalysisUsage &AU) const override {
AU.setPreservesCFG();
AU.addRequired<BlockFrequencyInfoWrapperPass>();
getLoopAnalysisUsage(AU);
AU.addRequired<MemorySSAWrapperPass>();
AU.addPreserved<MemorySSAWrapperPass>();
}
};
}

char LegacyLoopSinkPass::ID = 0;
INITIALIZE_PASS_BEGIN(LegacyLoopSinkPass, "loop-sink", "Loop Sink", false,
false)
INITIALIZE_PASS_DEPENDENCY(LoopPass)
INITIALIZE_PASS_DEPENDENCY(BlockFrequencyInfoWrapperPass)
INITIALIZE_PASS_DEPENDENCY(MemorySSAWrapperPass)
INITIALIZE_PASS_END(LegacyLoopSinkPass, "loop-sink", "Loop Sink", false, false)

Pass *llvm::createLoopSinkPass() { return new LegacyLoopSinkPass(); }
1 change: 0 additions & 1 deletion llvm/lib/Transforms/Scalar/Scalar.cpp
Expand Up @@ -31,7 +31,6 @@ void llvm::initializeScalarOpts(PassRegistry &Registry) {
initializeInferAddressSpacesPass(Registry);
initializeInstSimplifyLegacyPassPass(Registry);
initializeLegacyLICMPassPass(Registry);
initializeLegacyLoopSinkPassPass(Registry);
initializeLoopDataPrefetchLegacyPassPass(Registry);
initializeLoopInstSimplifyLegacyPassPass(Registry);
initializeLoopPredicationLegacyPassPass(Registry);
Expand Down

3 comments on commit b9975ce

@ms178
Copy link

@ms178 ms178 commented on b9975ce Nov 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@boomanaiden154 FYI: This pass was used in Mesa by radeonsi and its deletion caused a build error, see: https://gitlab.freedesktop.org/mesa/mesa/-/issues/10192

@nikic
Copy link
Contributor

@nikic nikic commented on b9975ce Nov 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That code in mesa needs to be switched to the new pass manager. Though the LoopSink invocation in that pass pipeline is entirely useless anyway, as it is followed by LICM, which will undo anything LoopSink does. So just dropping it is fine in this case. Generally that pass pipeline looks really suspect (running Mem2Reg and then SROA -- wat?)

@boomanaiden154
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.