-
Notifications
You must be signed in to change notification settings - Fork 11.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[NewPM] Remove SimpleLoopUnswitchLegacyPass #72934
[NewPM] Remove SimpleLoopUnswitchLegacyPass #72934
Conversation
This pass isn't used anywhere in upstream and thus doesn't have any test coverage. For these reasons, remove it.
@llvm/pr-subscribers-llvm-transforms Author: Aiden Grossman (boomanaiden154) ChangesThis pass isn't used anywhere in upstream and thus doesn't have any test coverage. For these reasons, remove it. Full diff: https://github.com/llvm/llvm-project/pull/72934.diff 4 Files Affected:
diff --git a/llvm/include/llvm/InitializePasses.h b/llvm/include/llvm/InitializePasses.h
index 2305db4f775d49c..f750157850bb2ac 100644
--- a/llvm/include/llvm/InitializePasses.h
+++ b/llvm/include/llvm/InitializePasses.h
@@ -292,7 +292,6 @@ void initializeScopedNoAliasAAWrapperPassPass(PassRegistry&);
void initializeSeparateConstOffsetFromGEPLegacyPassPass(PassRegistry &);
void initializeShadowStackGCLoweringPass(PassRegistry&);
void initializeShrinkWrapPass(PassRegistry&);
-void initializeSimpleLoopUnswitchLegacyPassPass(PassRegistry&);
void initializeSingleLoopExtractorPass(PassRegistry&);
void initializeSinkingLegacyPassPass(PassRegistry&);
void initializeSjLjEHPreparePass(PassRegistry&);
diff --git a/llvm/include/llvm/Transforms/Scalar/SimpleLoopUnswitch.h b/llvm/include/llvm/Transforms/Scalar/SimpleLoopUnswitch.h
index 68c121560b13ee8..417e9668527bd1d 100644
--- a/llvm/include/llvm/Transforms/Scalar/SimpleLoopUnswitch.h
+++ b/llvm/include/llvm/Transforms/Scalar/SimpleLoopUnswitch.h
@@ -79,11 +79,6 @@ class SimpleLoopUnswitchPass : public PassInfoMixin<SimpleLoopUnswitchPass> {
function_ref<StringRef(StringRef)> MapClassName2PassName);
};
-/// Create the legacy pass object for the simple loop unswitcher.
-///
-/// See the documentaion for `SimpleLoopUnswitchPass` for details.
-Pass *createSimpleLoopUnswitchLegacyPass(bool NonTrivial = false);
-
} // end namespace llvm
#endif // LLVM_TRANSFORMS_SCALAR_SIMPLELOOPUNSWITCH_H
diff --git a/llvm/lib/Transforms/Scalar/Scalar.cpp b/llvm/lib/Transforms/Scalar/Scalar.cpp
index 80db06b03a901b3..f5c6b48fed9f0bb 100644
--- a/llvm/lib/Transforms/Scalar/Scalar.cpp
+++ b/llvm/lib/Transforms/Scalar/Scalar.cpp
@@ -47,7 +47,6 @@ void llvm::initializeScalarOpts(PassRegistry &Registry) {
initializeSROALegacyPassPass(Registry);
initializeCFGSimplifyPassPass(Registry);
initializeStructurizeCFGLegacyPassPass(Registry);
- initializeSimpleLoopUnswitchLegacyPassPass(Registry);
initializeSinkingLegacyPassPass(Registry);
initializeTailCallElimPass(Registry);
initializeTLSVariableHoistLegacyPassPass(Registry);
diff --git a/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp b/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
index e9e6ead9ccb7419..55606473765239b 100644
--- a/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
+++ b/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
@@ -24,7 +24,6 @@
#include "llvm/Analysis/LoopAnalysisManager.h"
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Analysis/LoopIterator.h"
-#include "llvm/Analysis/LoopPass.h"
#include "llvm/Analysis/MemorySSA.h"
#include "llvm/Analysis/MemorySSAUpdater.h"
#include "llvm/Analysis/MustExecute.h"
@@ -46,8 +45,6 @@
#include "llvm/IR/ProfDataUtils.h"
#include "llvm/IR/Use.h"
#include "llvm/IR/Value.h"
-#include "llvm/InitializePasses.h"
-#include "llvm/Pass.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
@@ -3714,105 +3711,3 @@ void SimpleLoopUnswitchPass::printPipeline(
OS << (Trivial ? "" : "no-") << "trivial";
OS << '>';
}
-
-namespace {
-
-class SimpleLoopUnswitchLegacyPass : public LoopPass {
- bool NonTrivial;
-
-public:
- static char ID; // Pass ID, replacement for typeid
-
- explicit SimpleLoopUnswitchLegacyPass(bool NonTrivial = false)
- : LoopPass(ID), NonTrivial(NonTrivial) {
- initializeSimpleLoopUnswitchLegacyPassPass(
- *PassRegistry::getPassRegistry());
- }
-
- bool runOnLoop(Loop *L, LPPassManager &LPM) override;
-
- void getAnalysisUsage(AnalysisUsage &AU) const override {
- AU.addRequired<AssumptionCacheTracker>();
- AU.addRequired<TargetTransformInfoWrapperPass>();
- AU.addRequired<MemorySSAWrapperPass>();
- AU.addPreserved<MemorySSAWrapperPass>();
- getLoopAnalysisUsage(AU);
- }
-};
-
-} // end anonymous namespace
-
-bool SimpleLoopUnswitchLegacyPass::runOnLoop(Loop *L, LPPassManager &LPM) {
- if (skipLoop(L))
- return false;
-
- Function &F = *L->getHeader()->getParent();
-
- LLVM_DEBUG(dbgs() << "Unswitching loop in " << F.getName() << ": " << *L
- << "\n");
- auto &DT = getAnalysis<DominatorTreeWrapperPass>().getDomTree();
- auto &LI = getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
- auto &AC = getAnalysis<AssumptionCacheTracker>().getAssumptionCache(F);
- auto &AA = getAnalysis<AAResultsWrapperPass>().getAAResults();
- auto &TTI = getAnalysis<TargetTransformInfoWrapperPass>().getTTI(F);
- MemorySSA *MSSA = &getAnalysis<MemorySSAWrapperPass>().getMSSA();
- MemorySSAUpdater MSSAU(MSSA);
-
- auto *SEWP = getAnalysisIfAvailable<ScalarEvolutionWrapperPass>();
- auto *SE = SEWP ? &SEWP->getSE() : nullptr;
-
- auto UnswitchCB = [&L, &LPM](bool CurrentLoopValid, bool PartiallyInvariant,
- bool InjectedCondition,
- ArrayRef<Loop *> NewLoops) {
- // If we did a non-trivial unswitch, we have added new (cloned) loops.
- for (auto *NewL : NewLoops)
- LPM.addLoop(*NewL);
-
- // If the current loop remains valid, re-add it to the queue. This is
- // a little wasteful as we'll finish processing the current loop as well,
- // but it is the best we can do in the old PM.
- if (CurrentLoopValid) {
- // If the current loop has been unswitched using a partially invariant
- // condition or injected invariant condition, we should not re-add the
- // current loop to avoid unswitching on the same condition again.
- if (!PartiallyInvariant && !InjectedCondition)
- LPM.addLoop(*L);
- } else
- LPM.markLoopAsDeleted(*L);
- };
-
- auto DestroyLoopCB = [&LPM](Loop &L, StringRef /* Name */) {
- LPM.markLoopAsDeleted(L);
- };
-
- if (VerifyMemorySSA)
- MSSA->verifyMemorySSA();
- bool Changed =
- unswitchLoop(*L, DT, LI, AC, AA, TTI, true, NonTrivial, UnswitchCB, SE,
- &MSSAU, nullptr, nullptr, DestroyLoopCB);
-
- if (VerifyMemorySSA)
- MSSA->verifyMemorySSA();
-
- // Historically this pass has had issues with the dominator tree so verify it
- // in asserts builds.
- assert(DT.verify(DominatorTree::VerificationLevel::Fast));
-
- return Changed;
-}
-
-char SimpleLoopUnswitchLegacyPass::ID = 0;
-INITIALIZE_PASS_BEGIN(SimpleLoopUnswitchLegacyPass, "simple-loop-unswitch",
- "Simple unswitch loops", false, false)
-INITIALIZE_PASS_DEPENDENCY(AssumptionCacheTracker)
-INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
-INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass)
-INITIALIZE_PASS_DEPENDENCY(LoopPass)
-INITIALIZE_PASS_DEPENDENCY(MemorySSAWrapperPass)
-INITIALIZE_PASS_DEPENDENCY(TargetTransformInfoWrapperPass)
-INITIALIZE_PASS_END(SimpleLoopUnswitchLegacyPass, "simple-loop-unswitch",
- "Simple unswitch loops", false, false)
-
-Pass *llvm::createSimpleLoopUnswitchLegacyPass(bool NonTrivial) {
- return new SimpleLoopUnswitchLegacyPass(NonTrivial);
-}
|
You can test this locally with the following command:git-clang-format --diff 2ca028ce7c6de5f1350440012355a65383b8729a 797778af351878111f11c5972be4fa321bffc082 -- llvm/include/llvm/InitializePasses.h llvm/include/llvm/Transforms/Scalar/SimpleLoopUnswitch.h llvm/lib/Transforms/Scalar/Scalar.cpp llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp View the diff from clang-format here.diff --git a/llvm/include/llvm/InitializePasses.h b/llvm/include/llvm/InitializePasses.h
index f750157850..7abd6d4638 100644
--- a/llvm/include/llvm/InitializePasses.h
+++ b/llvm/include/llvm/InitializePasses.h
@@ -291,7 +291,7 @@ void initializeScavengerTestPass(PassRegistry&);
void initializeScopedNoAliasAAWrapperPassPass(PassRegistry&);
void initializeSeparateConstOffsetFromGEPLegacyPassPass(PassRegistry &);
void initializeShadowStackGCLoweringPass(PassRegistry&);
-void initializeShrinkWrapPass(PassRegistry&);
+void initializeShrinkWrapPass(PassRegistry &);
void initializeSingleLoopExtractorPass(PassRegistry&);
void initializeSinkingLegacyPassPass(PassRegistry&);
void initializeSjLjEHPreparePass(PassRegistry&);
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This pass isn't used anywhere in upstream and thus doesn't have any test coverage. For these reasons, remove it.