]> granicus.if.org Git - llvm/commitdiff
Move the old pass manager infrastructure into a legacy namespace and
authorChandler Carruth <chandlerc@gmail.com>
Sat, 9 Nov 2013 12:26:54 +0000 (12:26 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Sat, 9 Nov 2013 12:26:54 +0000 (12:26 +0000)
give the files a legacy prefix in the right directory. Use forwarding
headers in the old locations to paper over the name change for most
clients during the transitional period.

No functionality changed here! This is just clearing some space to
reduce renaming churn later on with a new system.

Even when the new stuff starts to go in, it is going to be hidden behind
a flag and off-by-default as it is still WIP and under development.

This patch is specifically designed so that very little out-of-tree code
has to change. I'm going to work as hard as I can to keep that the case.
Only direct forward declarations of the PassManager class are impacted
by this change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194324 91177308-0d34-0410-b5e6-96231b3b80d8

13 files changed:
include/llvm/Analysis/LoopPass.h
include/llvm/Analysis/RegionPass.h
include/llvm/CodeGen/Passes.h
include/llvm/IR/LegacyPassManager.h [new file with mode: 0644]
include/llvm/IR/LegacyPassManagers.h [moved from include/llvm/PassManagers.h with 99% similarity]
include/llvm/PassManager.h
include/llvm/Target/TargetMachine.h
include/llvm/Transforms/IPO/PassManagerBuilder.h
lib/Analysis/IPA/CallGraphSCCPass.cpp
lib/IR/CMakeLists.txt
lib/IR/LegacyPassManager.cpp [moved from lib/IR/PassManager.cpp with 99% similarity]
unittests/IR/CMakeLists.txt
unittests/IR/LegacyPassManagerTest.cpp [moved from unittests/IR/PassManagerTest.cpp with 97% similarity]

index 5767c1916b39fbf908f5552344848f258c4ce71f..5926610d1aa651bde39e4031e69285eba85646b6 100644 (file)
@@ -16,8 +16,8 @@
 #define LLVM_ANALYSIS_LOOPPASS_H
 
 #include "llvm/Analysis/LoopInfo.h"
+#include "llvm/IR/LegacyPassManagers.h"
 #include "llvm/Pass.h"
-#include "llvm/PassManagers.h"
 #include <deque>
 
 namespace llvm {
index 6ae31911780894357c80a083b60ea623c2213702..3907ad9c7dd5ebb69ebacf9e4cda58fbe0618f91 100644 (file)
@@ -18,8 +18,8 @@
 
 #include "llvm/Analysis/RegionInfo.h"
 #include "llvm/IR/Function.h"
+#include "llvm/IR/LegacyPassManagers.h"
 #include "llvm/Pass.h"
-#include "llvm/PassManagers.h"
 #include <deque>
 
 namespace llvm {
index 7df4cbff51ce493d3e4e8706b56ae4f6dceeb2ac..ae4a2fa0bf83e417f5fe3a238f1d27f215f38c1b 100644 (file)
@@ -25,7 +25,6 @@ class FunctionPass;
 class MachineFunctionPass;
 class PassConfigImpl;
 class PassInfo;
-class PassManagerBase;
 class ScheduleDAGInstrs;
 class TargetLowering;
 class TargetLoweringBase;
@@ -33,6 +32,12 @@ class TargetRegisterClass;
 class raw_ostream;
 struct MachineSchedContext;
 
+// The old pass manager infrastructure is hidden in a legacy namespace now.
+namespace legacy {
+class PassManagerBase;
+}
+using legacy::PassManagerBase;
+
 /// Discriminated union of Pass ID types.
 ///
 /// The PassConfig API prefers dealing with IDs because they are safer and more
diff --git a/include/llvm/IR/LegacyPassManager.h b/include/llvm/IR/LegacyPassManager.h
new file mode 100644 (file)
index 0000000..fa1436e
--- /dev/null
@@ -0,0 +1,111 @@
+//===- LegacyPassManager.h - Legacy Container for Passes --------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines the legacy PassManager class.  This class is used to hold,
+// maintain, and optimize execution of Passes.  The PassManager class ensures
+// that analysis results are available before a pass runs, and that Pass's are
+// destroyed when the PassManager is destroyed.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_IR_LEGACYPASSMANAGER_H
+#define LLVM_IR_LEGACYPASSMANAGER_H
+
+#include "llvm/Pass.h"
+#include "llvm/Support/CBindingWrapping.h"
+
+namespace llvm {
+
+class Pass;
+class Module;
+
+namespace legacy {
+
+class PassManagerImpl;
+class FunctionPassManagerImpl;
+
+/// PassManagerBase - An abstract interface to allow code to add passes to
+/// a pass manager without having to hard-code what kind of pass manager
+/// it is.
+class PassManagerBase {
+public:
+  virtual ~PassManagerBase();
+
+  /// add - Add a pass to the queue of passes to run.  This passes ownership of
+  /// the Pass to the PassManager.  When the PassManager is destroyed, the pass
+  /// will be destroyed as well, so there is no need to delete the pass.  This
+  /// implies that all passes MUST be allocated with 'new'.
+  virtual void add(Pass *P) = 0;
+};
+
+/// PassManager manages ModulePassManagers
+class PassManager : public PassManagerBase {
+public:
+
+  PassManager();
+  ~PassManager();
+
+  /// add - Add a pass to the queue of passes to run.  This passes ownership of
+  /// the Pass to the PassManager.  When the PassManager is destroyed, the pass
+  /// will be destroyed as well, so there is no need to delete the pass.  This
+  /// implies that all passes MUST be allocated with 'new'.
+  void add(Pass *P);
+
+  /// run - Execute all of the passes scheduled for execution.  Keep track of
+  /// whether any of the passes modifies the module, and if so, return true.
+  bool run(Module &M);
+
+private:
+  /// PassManagerImpl_New is the actual class. PassManager is just the
+  /// wraper to publish simple pass manager interface
+  PassManagerImpl *PM;
+};
+
+/// FunctionPassManager manages FunctionPasses and BasicBlockPassManagers.
+class FunctionPassManager : public PassManagerBase {
+public:
+  /// FunctionPassManager ctor - This initializes the pass manager.  It needs,
+  /// but does not take ownership of, the specified Module.
+  explicit FunctionPassManager(Module *M);
+  ~FunctionPassManager();
+
+  /// add - Add a pass to the queue of passes to run.  This passes
+  /// ownership of the Pass to the PassManager.  When the
+  /// PassManager_X is destroyed, the pass will be destroyed as well, so
+  /// there is no need to delete the pass.
+  /// This implies that all passes MUST be allocated with 'new'.
+  void add(Pass *P);
+
+  /// run - Execute all of the passes scheduled for execution.  Keep
+  /// track of whether any of the passes modifies the function, and if
+  /// so, return true.
+  ///
+  bool run(Function &F);
+
+  /// doInitialization - Run all of the initializers for the function passes.
+  ///
+  bool doInitialization();
+
+  /// doFinalization - Run all of the finalizers for the function passes.
+  ///
+  bool doFinalization();
+
+private:
+  FunctionPassManagerImpl *FPM;
+  Module *M;
+};
+
+} // End legacy namespace
+
+// Create wrappers for C Binding types (see CBindingWrapping.h).
+DEFINE_STDCXX_CONVERSION_FUNCTIONS(legacy::PassManagerBase, LLVMPassManagerRef)
+
+} // End llvm namespace
+
+#endif
similarity index 99%
rename from include/llvm/PassManagers.h
rename to include/llvm/IR/LegacyPassManagers.h
index 7afb0a0fbf90cf572fe2ba65176b724ea4727c60..d256a3e92ccf771cb57d3c781e1ea54c1023db28 100644 (file)
@@ -1,4 +1,4 @@
-//===- llvm/PassManagers.h - Pass Infrastructure classes  -------*- C++ -*-===//
+//===- LegacyPassManagers.h - Legacy Pass Infrastructure --------*- C++ -*-===//
 //
 //                     The LLVM Compiler Infrastructure
 //
index b6a8186a4e809b2049b01bfcdf143cd9778bfb65..2a191b339931a80b222fb7d35fbb1208e7b81193 100644 (file)
 //
 //===----------------------------------------------------------------------===//
 //
-// This file defines the PassManager class.  This class is used to hold,
-// maintain, and optimize execution of Passes.  The PassManager class ensures
-// that analysis results are available before a pass runs, and that Pass's are
-// destroyed when the PassManager is destroyed.
+// This is a legacy redirect header for the old PassManager. It is intended to
+// be used by clients that have not been converted to be aware of the new pass
+// management infrastructure being built for LLVM, which is every client
+// initially. Eventually this header (and the legacy management layer) will go
+// away, but we want to minimize changes to out-of-tree users of LLVM in the
+// interim.
+//
+// Note that this header *must not* be included into the same file as the new
+// pass management infrastructure is included. Things will break spectacularly.
+// If you are starting that conversion, you should switch to explicitly
+// including LegacyPassManager.h and using the legacy namespace.
 //
 //===----------------------------------------------------------------------===//
 
 #ifndef LLVM_PASSMANAGER_H
 #define LLVM_PASSMANAGER_H
 
-#include "llvm/Pass.h"
-#include "llvm/Support/CBindingWrapping.h"
+#include "llvm/IR/LegacyPassManager.h"
 
 namespace llvm {
 
-class Pass;
-class Module;
-
-class PassManagerImpl;
-class FunctionPassManagerImpl;
-
-/// PassManagerBase - An abstract interface to allow code to add passes to
-/// a pass manager without having to hard-code what kind of pass manager
-/// it is.
-class PassManagerBase {
-public:
-  virtual ~PassManagerBase();
-
-  /// add - Add a pass to the queue of passes to run.  This passes ownership of
-  /// the Pass to the PassManager.  When the PassManager is destroyed, the pass
-  /// will be destroyed as well, so there is no need to delete the pass.  This
-  /// implies that all passes MUST be allocated with 'new'.
-  virtual void add(Pass *P) = 0;
-};
-
-/// PassManager manages ModulePassManagers
-class PassManager : public PassManagerBase {
-public:
-
-  PassManager();
-  ~PassManager();
-
-  /// add - Add a pass to the queue of passes to run.  This passes ownership of
-  /// the Pass to the PassManager.  When the PassManager is destroyed, the pass
-  /// will be destroyed as well, so there is no need to delete the pass.  This
-  /// implies that all passes MUST be allocated with 'new'.
-  void add(Pass *P);
-
-  /// run - Execute all of the passes scheduled for execution.  Keep track of
-  /// whether any of the passes modifies the module, and if so, return true.
-  bool run(Module &M);
-
-private:
-  /// PassManagerImpl_New is the actual class. PassManager is just the
-  /// wraper to publish simple pass manager interface
-  PassManagerImpl *PM;
-};
-
-/// FunctionPassManager manages FunctionPasses and BasicBlockPassManagers.
-class FunctionPassManager : public PassManagerBase {
-public:
-  /// FunctionPassManager ctor - This initializes the pass manager.  It needs,
-  /// but does not take ownership of, the specified Module.
-  explicit FunctionPassManager(Module *M);
-  ~FunctionPassManager();
-
-  /// add - Add a pass to the queue of passes to run.  This passes
-  /// ownership of the Pass to the PassManager.  When the
-  /// PassManager_X is destroyed, the pass will be destroyed as well, so
-  /// there is no need to delete the pass.
-  /// This implies that all passes MUST be allocated with 'new'.
-  void add(Pass *P);
-
-  /// run - Execute all of the passes scheduled for execution.  Keep
-  /// track of whether any of the passes modifies the function, and if
-  /// so, return true.
-  ///
-  bool run(Function &F);
-
-  /// doInitialization - Run all of the initializers for the function passes.
-  ///
-  bool doInitialization();
-
-  /// doFinalization - Run all of the finalizers for the function passes.
-  ///
-  bool doFinalization();
-
-private:
-  FunctionPassManagerImpl *FPM;
-  Module *M;
-};
-
-// Create wrappers for C Binding types (see CBindingWrapping.h).
-DEFINE_STDCXX_CONVERSION_FUNCTIONS(PassManagerBase, LLVMPassManagerRef)
+// Pull these into the llvm namespace so that existing code that expects it
+// there can find it.
+using legacy::PassManagerBase;
+using legacy::PassManager;
+using legacy::FunctionPassManager;
 
-} // End llvm namespace
+}
 
 #endif
index fd7228a513a983db9e47c15b238f4c2f7f0516f3..91e4715eea3afe027e5f58de9c2ff1c7ed80fd31 100644 (file)
@@ -29,7 +29,6 @@ class GlobalValue;
 class MCAsmInfo;
 class MCCodeGenInfo;
 class MCContext;
-class PassManagerBase;
 class Target;
 class DataLayout;
 class TargetLibraryInfo;
@@ -47,6 +46,12 @@ class VectorTargetTransformInfo;
 class formatted_raw_ostream;
 class raw_ostream;
 
+// The old pass manager infrastructure is hidden in a legacy namespace now.
+namespace legacy {
+class PassManagerBase;
+}
+using legacy::PassManagerBase;
+
 //===----------------------------------------------------------------------===//
 ///
 /// TargetMachine - Primary interface to the complete machine description for
index 75631b31e19de52d23ec7b2f5f13e20b57bdbf11..3648a3dd6b00c6a3daa1612ef69192d8a0981449 100644 (file)
 #include <vector>
 
 namespace llvm {
-  class TargetLibraryInfo;
-  class PassManagerBase;
-  class Pass;
-  class FunctionPassManager;
+class TargetLibraryInfo;
+class Pass;
+
+// The old pass manager infrastructure is hidden in a legacy namespace now.
+namespace legacy {
+class PassManagerBase;
+class FunctionPassManager;
+}
+using legacy::PassManagerBase;
+using legacy::FunctionPassManager;
 
 /// PassManagerBuilder - This class is used to set up a standard optimization
 /// sequence for languages like C and C++, allowing some APIs to customize the
index a0d788f34a3c6065fdeab7bc2cb479765aded2f6..182beca3643efb1de56695fc7a016993d33f4d3e 100644 (file)
@@ -22,7 +22,7 @@
 #include "llvm/Analysis/CallGraph.h"
 #include "llvm/IR/Function.h"
 #include "llvm/IR/IntrinsicInst.h"
-#include "llvm/PassManagers.h"
+#include "llvm/IR/LegacyPassManagers.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/Timer.h"
index c2a4ee3aae14a745960c8b18efb87bd5d34dccab..2ad5fdb25be1aa603d1acbbede23a29a84604d13 100644 (file)
@@ -6,10 +6,10 @@ add_llvm_library(LLVMCore
   ConstantFold.cpp
   Constants.cpp
   Core.cpp
+  DIBuilder.cpp
   DataLayout.cpp
   DebugInfo.cpp
   DebugLoc.cpp
-  DIBuilder.cpp
   Dominators.cpp
   Function.cpp
   GCOV.cpp
@@ -23,10 +23,10 @@ add_llvm_library(LLVMCore
   LLVMContext.cpp
   LLVMContextImpl.cpp
   LeakDetector.cpp
+  LegacyPassManager.cpp
   Metadata.cpp
   Module.cpp
   Pass.cpp
-  PassManager.cpp
   PassRegistry.cpp
   PrintModulePass.cpp
   Type.cpp
similarity index 99%
rename from lib/IR/PassManager.cpp
rename to lib/IR/LegacyPassManager.cpp
index 8d2e2ca89bacf92555c44141637f065f9d9d6aa0..a431d8256d70bd07864fb392582aa245a6064c6a 100644 (file)
@@ -1,4 +1,4 @@
-//===- PassManager.cpp - LLVM Pass Infrastructure Implementation ----------===//
+//===- LegacyPassManager.cpp - LLVM Pass Infrastructure Implementation ----===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -7,16 +7,16 @@
 //
 //===----------------------------------------------------------------------===//
 //
-// This file implements the LLVM Pass Manager infrastructure.
+// This file implements the legacy LLVM Pass Manager infrastructure.
 //
 //===----------------------------------------------------------------------===//
 
 
-#include "llvm/PassManagers.h"
 #include "llvm/Assembly/PrintModulePass.h"
 #include "llvm/Assembly/Writer.h"
+#include "llvm/IR/LegacyPassManager.h"
 #include "llvm/IR/Module.h"
-#include "llvm/PassManager.h"
+#include "llvm/IR/LegacyPassManagers.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/ErrorHandling.h"
 #include <algorithm>
 #include <map>
 using namespace llvm;
+using namespace llvm::legacy;
 
 // See PassManagers.h for Pass Manager infrastructure overview.
 
-namespace llvm {
-
 //===----------------------------------------------------------------------===//
 // Pass debugging information.  Often it is useful to find out what pass is
 // running when a crash occurs in a utility.  When this library is compiled with
@@ -40,10 +39,12 @@ namespace llvm {
 // pass name to be printed before it executes.
 //
 
+namespace {
 // Different debug levels that can be enabled...
 enum PassDebugLevel {
   Disabled, Arguments, Structure, Executions, Details
 };
+}
 
 static cl::opt<enum PassDebugLevel>
 PassDebugging("debug-pass", cl::Hidden,
@@ -56,8 +57,10 @@ PassDebugging("debug-pass", cl::Hidden,
   clEnumVal(Details   , "print pass details when it is executed"),
                              clEnumValEnd));
 
+namespace {
 typedef llvm::cl::list<const llvm::PassInfo *, bool, PassNameParser>
 PassOptionList;
+}
 
 // Print IR out before/after specified passes.
 static PassOptionList
@@ -106,8 +109,6 @@ static bool ShouldPrintAfterPass(const PassInfo *PI) {
   return PrintAfterAll || ShouldPrintBeforeOrAfterPass(PI, PrintAfter);
 }
 
-} // End of llvm namespace
-
 /// isPassDebuggingExecutionsOrMore - Return true if -debug-pass=Executions
 /// or higher is specified.
 bool PMDataManager::isPassDebuggingExecutionsOrMore() const {
@@ -149,7 +150,6 @@ void PassManagerPrettyStackEntry::print(raw_ostream &OS) const {
 
 
 namespace {
-
 //===----------------------------------------------------------------------===//
 // BBPassManager
 //
@@ -206,10 +206,10 @@ public:
 };
 
 char BBPassManager::ID = 0;
-}
+} // End anonymous namespace
 
 namespace llvm {
-
+namespace legacy {
 //===----------------------------------------------------------------------===//
 // FunctionPassManagerImpl
 //
@@ -277,7 +277,10 @@ public:
 void FunctionPassManagerImpl::anchor() {}
 
 char FunctionPassManagerImpl::ID = 0;
+} // End of legacy namespace
+} // End of llvm namespace
 
+namespace {
 //===----------------------------------------------------------------------===//
 // MPPassManager
 //
@@ -372,6 +375,10 @@ public:
 };
 
 char MPPassManager::ID = 0;
+} // End anonymous namespace
+
+namespace llvm {
+namespace legacy {
 //===----------------------------------------------------------------------===//
 // PassManagerImpl
 //
@@ -437,6 +444,7 @@ public:
 void PassManagerImpl::anchor() {}
 
 char PassManagerImpl::ID = 0;
+} // End of legacy namespace
 } // End of llvm namespace
 
 namespace {
index c53043ef80e11d232eedaf57364a8ab411f3d671..1ab8e384c8ab37b3cac46b626a72e9020d3e3f2f 100644 (file)
@@ -10,9 +10,9 @@ set(IRSources
   DominatorTreeTest.cpp
   IRBuilderTest.cpp
   InstructionsTest.cpp
+  LegacyPassManagerTest.cpp
   MDBuilderTest.cpp
   MetadataTest.cpp
-  PassManagerTest.cpp
   PatternMatch.cpp
   TypeBuilderTest.cpp
   TypesTest.cpp
similarity index 97%
rename from unittests/IR/PassManagerTest.cpp
rename to unittests/IR/LegacyPassManagerTest.cpp
index 48514fc568677e7ee512eb2d434ea885be51f844..11841bdeac0dddaff59f30ec8248a662cfad705b 100644 (file)
@@ -1,4 +1,4 @@
-//===- llvm/unittest/IR/PassManager.cpp - PassManager unit tests ----------===//
+//===- llvm/unittest/IR/LegacyPassManager.cpp - Legacy PassManager tests --===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -6,6 +6,13 @@
 // License. See LICENSE.TXT for details.
 //
 //===----------------------------------------------------------------------===//
+//
+// This unit test exercises the legacy pass manager infrastructure. We use the
+// old names as well to ensure that the source-level compatibility wrapper
+// works for out-of-tree code that expects to include llvm/PassManager.h and
+// subclass the core pass classes.
+//
+//===----------------------------------------------------------------------===//
 
 #include "llvm/PassManager.h"
 #include "llvm/ADT/SmallVector.h"