[llvm] [NewPM] Remove CFGPrinterLegacyPass (PR #73414)

Aiden Grossman via llvm-commits llvm-commits at lists.llvm.org
Sat Nov 25 21:43:32 PST 2023


https://github.com/boomanaiden154 updated https://github.com/llvm/llvm-project/pull/73414

>From dcfe328ef56aeef775871c77ddde93c907851317 Mon Sep 17 00:00:00 2001
From: Aiden Grossman <agrossman154 at yahoo.com>
Date: Sat, 25 Nov 2023 14:46:51 -0800
Subject: [PATCH] [NewPM] Remove CFGPrinterLegacyPass

This pass has no test coverage in upstream LLVM, is not used anywhere in
upstream LLVM, and has a NewPM equivalent. For these reasons, remove it.
---
 llvm/include/llvm/Analysis/CFGPrinter.h |  5 ----
 llvm/include/llvm/InitializePasses.h    |  1 -
 llvm/lib/Analysis/Analysis.cpp          |  1 -
 llvm/lib/Analysis/CFGPrinter.cpp        | 37 -------------------------
 4 files changed, 44 deletions(-)

diff --git a/llvm/include/llvm/Analysis/CFGPrinter.h b/llvm/include/llvm/Analysis/CFGPrinter.h
index b814393fe2ee4af..3e5b57195b9eae2 100644
--- a/llvm/include/llvm/Analysis/CFGPrinter.h
+++ b/llvm/include/llvm/Analysis/CFGPrinter.h
@@ -342,9 +342,4 @@ struct DOTGraphTraits<DOTFuncInfo *> : public DefaultDOTGraphTraits {
 };
 } // End llvm namespace
 
-namespace llvm {
-class FunctionPass;
-FunctionPass *createCFGPrinterLegacyPassPass();
-} // End llvm namespace
-
 #endif
diff --git a/llvm/include/llvm/InitializePasses.h b/llvm/include/llvm/InitializePasses.h
index ebae24a525e2918..898265759a688fe 100644
--- a/llvm/include/llvm/InitializePasses.h
+++ b/llvm/include/llvm/InitializePasses.h
@@ -65,7 +65,6 @@ void initializeBranchRelaxationPass(PassRegistry&);
 void initializeBreakCriticalEdgesPass(PassRegistry&);
 void initializeBreakFalseDepsPass(PassRegistry&);
 void initializeCanonicalizeFreezeInLoopsPass(PassRegistry &);
-void initializeCFGPrinterLegacyPassPass(PassRegistry&);
 void initializeCFGSimplifyPassPass(PassRegistry&);
 void initializeCFGuardPass(PassRegistry&);
 void initializeCFGuardLongjmpPass(PassRegistry&);
diff --git a/llvm/lib/Analysis/Analysis.cpp b/llvm/lib/Analysis/Analysis.cpp
index 47d8e2e1d2522d0..f70cc4a9fb29843 100644
--- a/llvm/lib/Analysis/Analysis.cpp
+++ b/llvm/lib/Analysis/Analysis.cpp
@@ -24,7 +24,6 @@ void llvm::initializeAnalysis(PassRegistry &Registry) {
   initializeCallGraphWrapperPassPass(Registry);
   initializeCallGraphDOTPrinterPass(Registry);
   initializeCallGraphViewerPass(Registry);
-  initializeCFGPrinterLegacyPassPass(Registry);
   initializeCycleInfoWrapperPassPass(Registry);
   initializeDependenceAnalysisWrapperPassPass(Registry);
   initializeDominanceFrontierWrapperPassPass(Registry);
diff --git a/llvm/lib/Analysis/CFGPrinter.cpp b/llvm/lib/Analysis/CFGPrinter.cpp
index d9bf03992b9aa64..67a15197058b733 100644
--- a/llvm/lib/Analysis/CFGPrinter.cpp
+++ b/llvm/lib/Analysis/CFGPrinter.cpp
@@ -19,8 +19,6 @@
 
 #include "llvm/Analysis/CFGPrinter.h"
 #include "llvm/ADT/PostOrderIterator.h"
-#include "llvm/InitializePasses.h"
-#include "llvm/Pass.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/GraphWriter.h"
@@ -111,37 +109,6 @@ PreservedAnalyses CFGOnlyViewerPass::run(Function &F,
   return PreservedAnalyses::all();
 }
 
-namespace {
-struct CFGPrinterLegacyPass : public FunctionPass {
-  static char ID; // Pass identification, replacement for typeid
-  CFGPrinterLegacyPass() : FunctionPass(ID) {
-    initializeCFGPrinterLegacyPassPass(*PassRegistry::getPassRegistry());
-  }
-
-  bool runOnFunction(Function &F) override {
-    if (!CFGFuncName.empty() && !F.getName().contains(CFGFuncName))
-      return false;
-    auto *BPI = &getAnalysis<BranchProbabilityInfoWrapperPass>().getBPI();
-    auto *BFI = &getAnalysis<BlockFrequencyInfoWrapperPass>().getBFI();
-    writeCFGToDotFile(F, BFI, BPI, getMaxFreq(F, BFI));
-    return false;
-  }
-
-  void print(raw_ostream &OS, const Module * = nullptr) const override {}
-
-  void getAnalysisUsage(AnalysisUsage &AU) const override {
-    FunctionPass::getAnalysisUsage(AU);
-    AU.addRequired<BlockFrequencyInfoWrapperPass>();
-    AU.addRequired<BranchProbabilityInfoWrapperPass>();
-    AU.setPreservesAll();
-  }
-};
-} // namespace
-
-char CFGPrinterLegacyPass::ID = 0;
-INITIALIZE_PASS(CFGPrinterLegacyPass, "dot-cfg",
-                "Print CFG of function to 'dot' file", false, true)
-
 PreservedAnalyses CFGPrinterPass::run(Function &F,
                                       FunctionAnalysisManager &AM) {
   if (!CFGFuncName.empty() && !F.getName().contains(CFGFuncName))
@@ -189,10 +156,6 @@ void Function::viewCFGOnly(const BlockFrequencyInfo *BFI,
   viewCFG(true, BFI, BPI);
 }
 
-FunctionPass *llvm::createCFGPrinterLegacyPassPass() {
-  return new CFGPrinterLegacyPass();
-}
-
 /// Find all blocks on the paths which terminate with a deoptimize or 
 /// unreachable (i.e. all blocks which are post-dominated by a deoptimize 
 /// or unreachable). These paths are hidden if the corresponding cl::opts



More information about the llvm-commits mailing list