[llvm] r225145 - [PM] Switch the new pass manager to use a reference-based API for IR

Chandler Carruth chandlerc at gmail.com
Sun Jan 4 18:47:06 PST 2015


Author: chandlerc
Date: Sun Jan  4 20:47:05 2015
New Revision: 225145

URL: http://llvm.org/viewvc/llvm-project?rev=225145&view=rev
Log:
[PM] Switch the new pass manager to use a reference-based API for IR
units.

This was debated back and forth a bunch, but using references is now
clearly cleaner. Of all the code written using pointers thus far, in
only one place did it really make more sense to have a pointer. In most
cases, this just removes immediate dereferencing from the code. I think
it is much better to get errors on null IR units earlier, potentially
at compile time, than to delay it.

Most notably, the legacy pass manager uses references for its routines
and so as more and more code works with both, the use of pointers was
likely to become really annoying. I noticed this when I ported the
domtree analysis over and wrote the entire thing with references only to
have it fail to compile. =/ It seemed better to switch now than to
delay. We can, of course, revisit this is we learn that references are
really problematic in the API.

Modified:
    llvm/trunk/include/llvm/Analysis/CGSCCPassManager.h
    llvm/trunk/include/llvm/Analysis/LazyCallGraph.h
    llvm/trunk/include/llvm/Bitcode/BitcodeWriterPass.h
    llvm/trunk/include/llvm/IR/IRPrintingPasses.h
    llvm/trunk/include/llvm/IR/PassManager.h
    llvm/trunk/include/llvm/IR/Verifier.h
    llvm/trunk/lib/Analysis/CGSCCPassManager.cpp
    llvm/trunk/lib/Analysis/LazyCallGraph.cpp
    llvm/trunk/lib/Bitcode/Writer/BitcodeWriterPass.cpp
    llvm/trunk/lib/IR/IRPrintingPasses.cpp
    llvm/trunk/lib/IR/PassManager.cpp
    llvm/trunk/lib/IR/Verifier.cpp
    llvm/trunk/tools/opt/NewPMDriver.cpp
    llvm/trunk/tools/opt/Passes.cpp
    llvm/trunk/unittests/IR/PassManagerTest.cpp

Modified: llvm/trunk/include/llvm/Analysis/CGSCCPassManager.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/CGSCCPassManager.h?rev=225145&r1=225144&r2=225145&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/CGSCCPassManager.h (original)
+++ llvm/trunk/include/llvm/Analysis/CGSCCPassManager.h Sun Jan  4 20:47:05 2015
@@ -40,7 +40,7 @@ public:
   }
 
   /// \brief Run all of the CGSCC passes in this pass manager over a SCC.
-  PreservedAnalyses run(LazyCallGraph::SCC *C,
+  PreservedAnalyses run(LazyCallGraph::SCC &C,
                         CGSCCAnalysisManager *AM = nullptr);
 
   template <typename CGSCCPassT> void addPass(CGSCCPassT Pass) {
@@ -51,13 +51,13 @@ public:
 
 private:
   // Pull in the concept type and model template specialized for SCCs.
-  typedef detail::PassConcept<LazyCallGraph::SCC *, CGSCCAnalysisManager>
+  typedef detail::PassConcept<LazyCallGraph::SCC &, CGSCCAnalysisManager>
   CGSCCPassConcept;
   template <typename PassT>
   struct CGSCCPassModel
-      : detail::PassModel<LazyCallGraph::SCC *, CGSCCAnalysisManager, PassT> {
+      : detail::PassModel<LazyCallGraph::SCC &, CGSCCAnalysisManager, PassT> {
     CGSCCPassModel(PassT Pass)
-        : detail::PassModel<LazyCallGraph::SCC *, CGSCCAnalysisManager, PassT>(
+        : detail::PassModel<LazyCallGraph::SCC &, CGSCCAnalysisManager, PassT>(
               std::move(Pass)) {}
   };
 
@@ -70,11 +70,11 @@ private:
 /// \brief A function analysis manager to coordinate and cache analyses run over
 /// a module.
 class CGSCCAnalysisManager : public detail::AnalysisManagerBase<
-                                 CGSCCAnalysisManager, LazyCallGraph::SCC *> {
+                                 CGSCCAnalysisManager, LazyCallGraph::SCC &> {
   friend class detail::AnalysisManagerBase<CGSCCAnalysisManager,
-                                           LazyCallGraph::SCC *>;
+                                           LazyCallGraph::SCC &>;
   typedef detail::AnalysisManagerBase<CGSCCAnalysisManager,
-                                      LazyCallGraph::SCC *> BaseT;
+                                      LazyCallGraph::SCC &> BaseT;
   typedef BaseT::ResultConceptT ResultConceptT;
   typedef BaseT::PassConceptT PassConceptT;
 
@@ -110,17 +110,17 @@ private:
   operator=(const CGSCCAnalysisManager &) LLVM_DELETED_FUNCTION;
 
   /// \brief Get a function pass result, running the pass if necessary.
-  ResultConceptT &getResultImpl(void *PassID, LazyCallGraph::SCC *C);
+  ResultConceptT &getResultImpl(void *PassID, LazyCallGraph::SCC &C);
 
   /// \brief Get a cached function pass result or return null.
   ResultConceptT *getCachedResultImpl(void *PassID,
-                                      LazyCallGraph::SCC *C) const;
+                                      LazyCallGraph::SCC &C) const;
 
   /// \brief Invalidate a function pass result.
-  void invalidateImpl(void *PassID, LazyCallGraph::SCC *C);
+  void invalidateImpl(void *PassID, LazyCallGraph::SCC &C);
 
   /// \brief Invalidate the results for a function..
-  void invalidateImpl(LazyCallGraph::SCC *C, const PreservedAnalyses &PA);
+  void invalidateImpl(LazyCallGraph::SCC &C, const PreservedAnalyses &PA);
 
   /// \brief List of function analysis pass IDs and associated concept pointers.
   ///
@@ -129,7 +129,7 @@ private:
   /// half of a bijection and provides storage for the actual result concept.
   typedef std::list<
       std::pair<void *, std::unique_ptr<detail::AnalysisResultConcept<
-                            LazyCallGraph::SCC *>>>> CGSCCAnalysisResultListT;
+                            LazyCallGraph::SCC &>>>> CGSCCAnalysisResultListT;
 
   /// \brief Map type from function pointer to our custom list type.
   typedef DenseMap<LazyCallGraph::SCC *, CGSCCAnalysisResultListT>
@@ -187,7 +187,7 @@ public:
     /// Regardless of whether this analysis is marked as preserved, all of the
     /// analyses in the \c CGSCCAnalysisManager are potentially invalidated
     /// based on the set of preserved analyses.
-    bool invalidate(Module *M, const PreservedAnalyses &PA);
+    bool invalidate(Module &M, const PreservedAnalyses &PA);
 
   private:
     CGSCCAnalysisManager *CGAM;
@@ -219,7 +219,7 @@ public:
   /// In debug builds, it will also assert that the analysis manager is empty
   /// as no queries should arrive at the CGSCC analysis manager prior to
   /// this analysis being requested.
-  Result run(Module *M);
+  Result run(Module &M);
 
 private:
   static char PassID;
@@ -257,7 +257,7 @@ public:
     const ModuleAnalysisManager &getManager() const { return *MAM; }
 
     /// \brief Handle invalidation by ignoring it, this pass is immutable.
-    bool invalidate(LazyCallGraph::SCC *) { return false; }
+    bool invalidate(LazyCallGraph::SCC &) { return false; }
 
   private:
     const ModuleAnalysisManager *MAM;
@@ -283,7 +283,7 @@ public:
   /// \brief Run the analysis pass and create our proxy result object.
   /// Nothing to see here, it just forwards the \c MAM reference into the
   /// result.
-  Result run(LazyCallGraph::SCC *) { return Result(*MAM); }
+  Result run(LazyCallGraph::SCC &) { return Result(*MAM); }
 
 private:
   static char PassID;
@@ -323,7 +323,7 @@ public:
   }
 
   /// \brief Runs the CGSCC pass across every SCC in the module.
-  PreservedAnalyses run(Module *M, ModuleAnalysisManager *AM) {
+  PreservedAnalyses run(Module &M, ModuleAnalysisManager *AM) {
     assert(AM && "We need analyses to compute the call graph!");
 
     // Setup the CGSCC analysis manager from its proxy.
@@ -335,7 +335,7 @@ public:
 
     PreservedAnalyses PA = PreservedAnalyses::all();
     for (LazyCallGraph::SCC &C : CG.postorder_sccs()) {
-      PreservedAnalyses PassPA = Pass.run(&C, &CGAM);
+      PreservedAnalyses PassPA = Pass.run(C, &CGAM);
 
       // We know that the CGSCC pass couldn't have invalidated any other
       // SCC's analyses (that's the contract of a CGSCC pass), so
@@ -343,7 +343,7 @@ public:
       // FIXME: This isn't quite correct. We need to handle the case where the
       // pass updated the CG, particularly some child of the current SCC, and
       // invalidate its analyses.
-      CGAM.invalidate(&C, PassPA);
+      CGAM.invalidate(C, PassPA);
 
       // Then intersect the preserved set so that invalidation of module
       // analyses will eventually occur when the module pass completes.
@@ -409,7 +409,7 @@ public:
     /// Regardless of whether this analysis is marked as preserved, all of the
     /// analyses in the \c FunctionAnalysisManager are potentially invalidated
     /// based on the set of preserved analyses.
-    bool invalidate(LazyCallGraph::SCC *C, const PreservedAnalyses &PA);
+    bool invalidate(LazyCallGraph::SCC &C, const PreservedAnalyses &PA);
 
   private:
     FunctionAnalysisManager *FAM;
@@ -441,7 +441,7 @@ public:
   /// In debug builds, it will also assert that the analysis manager is empty
   /// as no queries should arrive at the function analysis manager prior to
   /// this analysis being requested.
-  Result run(LazyCallGraph::SCC *C);
+  Result run(LazyCallGraph::SCC &C);
 
 private:
   static char PassID;
@@ -479,7 +479,7 @@ public:
     const CGSCCAnalysisManager &getManager() const { return *CGAM; }
 
     /// \brief Handle invalidation by ignoring it, this pass is immutable.
-    bool invalidate(Function *) { return false; }
+    bool invalidate(Function &) { return false; }
 
   private:
     const CGSCCAnalysisManager *CGAM;
@@ -505,7 +505,7 @@ public:
   /// \brief Run the analysis pass and create our proxy result object.
   /// Nothing to see here, it just forwards the \c CGAM reference into the
   /// result.
-  Result run(Function *) { return Result(*CGAM); }
+  Result run(Function &) { return Result(*CGAM); }
 
 private:
   static char PassID;
@@ -541,21 +541,21 @@ public:
   }
 
   /// \brief Runs the function pass across every function in the module.
-  PreservedAnalyses run(LazyCallGraph::SCC *C, CGSCCAnalysisManager *AM) {
+  PreservedAnalyses run(LazyCallGraph::SCC &C, CGSCCAnalysisManager *AM) {
     FunctionAnalysisManager *FAM = nullptr;
     if (AM)
       // Setup the function analysis manager from its proxy.
       FAM = &AM->getResult<FunctionAnalysisManagerCGSCCProxy>(C).getManager();
 
     PreservedAnalyses PA = PreservedAnalyses::all();
-    for (LazyCallGraph::Node *N : *C) {
-      PreservedAnalyses PassPA = Pass.run(&N->getFunction(), FAM);
+    for (LazyCallGraph::Node *N : C) {
+      PreservedAnalyses PassPA = Pass.run(N->getFunction(), FAM);
 
       // We know that the function pass couldn't have invalidated any other
       // function's analyses (that's the contract of a function pass), so
       // directly handle the function analysis manager's invalidation here.
       if (FAM)
-        FAM->invalidate(&N->getFunction(), PassPA);
+        FAM->invalidate(N->getFunction(), PassPA);
 
       // Then intersect the preserved set so that invalidation of module
       // analyses will eventually occur when the module pass completes.

Modified: llvm/trunk/include/llvm/Analysis/LazyCallGraph.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/LazyCallGraph.h?rev=225145&r1=225144&r2=225145&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/LazyCallGraph.h (original)
+++ llvm/trunk/include/llvm/Analysis/LazyCallGraph.h Sun Jan  4 20:47:05 2015
@@ -541,7 +541,7 @@ public:
   ///
   /// This just builds the set of entry points to the call graph. The rest is
   /// built lazily as it is walked.
-  LazyCallGraph run(Module *M) { return LazyCallGraph(*M); }
+  LazyCallGraph run(Module &M) { return LazyCallGraph(M); }
 
 private:
   static char PassID;
@@ -556,7 +556,7 @@ class LazyCallGraphPrinterPass {
 public:
   explicit LazyCallGraphPrinterPass(raw_ostream &OS);
 
-  PreservedAnalyses run(Module *M, ModuleAnalysisManager *AM);
+  PreservedAnalyses run(Module &M, ModuleAnalysisManager *AM);
 
   static StringRef name() { return "LazyCallGraphPrinterPass"; }
 };

Modified: llvm/trunk/include/llvm/Bitcode/BitcodeWriterPass.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Bitcode/BitcodeWriterPass.h?rev=225145&r1=225144&r2=225145&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Bitcode/BitcodeWriterPass.h (original)
+++ llvm/trunk/include/llvm/Bitcode/BitcodeWriterPass.h Sun Jan  4 20:47:05 2015
@@ -41,7 +41,7 @@ public:
 
   /// \brief Run the bitcode writer pass, and output the module to the selected
   /// output stream.
-  PreservedAnalyses run(Module *M);
+  PreservedAnalyses run(Module &M);
 
   static StringRef name() { return "BitcodeWriterPass"; }
 };

Modified: llvm/trunk/include/llvm/IR/IRPrintingPasses.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/IRPrintingPasses.h?rev=225145&r1=225144&r2=225145&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/IRPrintingPasses.h (original)
+++ llvm/trunk/include/llvm/IR/IRPrintingPasses.h Sun Jan  4 20:47:05 2015
@@ -58,7 +58,7 @@ public:
   PrintModulePass();
   PrintModulePass(raw_ostream &OS, const std::string &Banner = "");
 
-  PreservedAnalyses run(Module *M);
+  PreservedAnalyses run(Module &M);
 
   static StringRef name() { return "PrintModulePass"; }
 };
@@ -75,7 +75,7 @@ public:
   PrintFunctionPass();
   PrintFunctionPass(raw_ostream &OS, const std::string &Banner = "");
 
-  PreservedAnalyses run(Function *F);
+  PreservedAnalyses run(Function &F);
 
   static StringRef name() { return "PrintFunctionPass"; }
 };

Modified: llvm/trunk/include/llvm/IR/PassManager.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/PassManager.h?rev=225145&r1=225144&r2=225145&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/PassManager.h (original)
+++ llvm/trunk/include/llvm/IR/PassManager.h Sun Jan  4 20:47:05 2015
@@ -186,7 +186,7 @@ public:
   ///
   /// This method should only be called for a single module as there is the
   /// expectation that the lifetime of a pass is bounded to that of a module.
-  PreservedAnalyses run(Module *M, ModuleAnalysisManager *AM = nullptr);
+  PreservedAnalyses run(Module &M, ModuleAnalysisManager *AM = nullptr);
 
   template <typename ModulePassT> void addPass(ModulePassT Pass) {
     Passes.emplace_back(new ModulePassModel<ModulePassT>(std::move(Pass)));
@@ -196,13 +196,13 @@ public:
 
 private:
   // Pull in the concept type and model template specialized for modules.
-  typedef detail::PassConcept<Module *, ModuleAnalysisManager>
+  typedef detail::PassConcept<Module &, ModuleAnalysisManager>
       ModulePassConcept;
   template <typename PassT>
   struct ModulePassModel
-      : detail::PassModel<Module *, ModuleAnalysisManager, PassT> {
+      : detail::PassModel<Module &, ModuleAnalysisManager, PassT> {
     ModulePassModel(PassT Pass)
-        : detail::PassModel<Module *, ModuleAnalysisManager, PassT>(
+        : detail::PassModel<Module &, ModuleAnalysisManager, PassT>(
               std::move(Pass)) {}
   };
 
@@ -255,19 +255,19 @@ public:
     Passes.emplace_back(new FunctionPassModel<FunctionPassT>(std::move(Pass)));
   }
 
-  PreservedAnalyses run(Function *F, FunctionAnalysisManager *AM = nullptr);
+  PreservedAnalyses run(Function &F, FunctionAnalysisManager *AM = nullptr);
 
   static StringRef name() { return "FunctionPassManager"; }
 
 private:
   // Pull in the concept type and model template specialized for functions.
-  typedef detail::PassConcept<Function *, FunctionAnalysisManager>
+  typedef detail::PassConcept<Function &, FunctionAnalysisManager>
       FunctionPassConcept;
   template <typename PassT>
   struct FunctionPassModel
-      : detail::PassModel<Function *, FunctionAnalysisManager, PassT> {
+      : detail::PassModel<Function &, FunctionAnalysisManager, PassT> {
     FunctionPassModel(PassT Pass)
-        : detail::PassModel<Function *, FunctionAnalysisManager, PassT>(
+        : detail::PassModel<Function &, FunctionAnalysisManager, PassT>(
               std::move(Pass)) {}
   };
 
@@ -369,7 +369,7 @@ public:
   /// \brief Invalidate a specific analysis pass for an IR module.
   ///
   /// Note that the analysis result can disregard invalidation.
-  template <typename PassT> void invalidate(Module *M) {
+  template <typename PassT> void invalidate(Module &M) {
     assert(AnalysisPasses.count(PassT::ID()) &&
            "This analysis pass was not registered prior to being invalidated");
     derived_this()->invalidateImpl(PassT::ID(), M);
@@ -413,9 +413,9 @@ private:
 /// \brief A module analysis pass manager with lazy running and caching of
 /// results.
 class ModuleAnalysisManager
-    : public detail::AnalysisManagerBase<ModuleAnalysisManager, Module *> {
-  friend class detail::AnalysisManagerBase<ModuleAnalysisManager, Module *>;
-  typedef detail::AnalysisManagerBase<ModuleAnalysisManager, Module *> BaseT;
+    : public detail::AnalysisManagerBase<ModuleAnalysisManager, Module &> {
+  friend class detail::AnalysisManagerBase<ModuleAnalysisManager, Module &>;
+  typedef detail::AnalysisManagerBase<ModuleAnalysisManager, Module &> BaseT;
   typedef BaseT::ResultConceptT ResultConceptT;
   typedef BaseT::PassConceptT PassConceptT;
 
@@ -438,21 +438,21 @@ private:
   operator=(const ModuleAnalysisManager &) LLVM_DELETED_FUNCTION;
 
   /// \brief Get a module pass result, running the pass if necessary.
-  ResultConceptT &getResultImpl(void *PassID, Module *M);
+  ResultConceptT &getResultImpl(void *PassID, Module &M);
 
   /// \brief Get a cached module pass result or return null.
-  ResultConceptT *getCachedResultImpl(void *PassID, Module *M) const;
+  ResultConceptT *getCachedResultImpl(void *PassID, Module &M) const;
 
   /// \brief Invalidate a module pass result.
-  void invalidateImpl(void *PassID, Module *M);
+  void invalidateImpl(void *PassID, Module &M);
 
   /// \brief Invalidate results across a module.
-  void invalidateImpl(Module *M, const PreservedAnalyses &PA);
+  void invalidateImpl(Module &M, const PreservedAnalyses &PA);
 
   /// \brief Map type from module analysis pass ID to pass result concept
   /// pointer.
   typedef DenseMap<void *,
-                   std::unique_ptr<detail::AnalysisResultConcept<Module *>>>
+                   std::unique_ptr<detail::AnalysisResultConcept<Module &>>>
       ModuleAnalysisResultMapT;
 
   /// \brief Cache of computed module analysis results for this module.
@@ -462,9 +462,9 @@ private:
 /// \brief A function analysis manager to coordinate and cache analyses run over
 /// a module.
 class FunctionAnalysisManager
-    : public detail::AnalysisManagerBase<FunctionAnalysisManager, Function *> {
-  friend class detail::AnalysisManagerBase<FunctionAnalysisManager, Function *>;
-  typedef detail::AnalysisManagerBase<FunctionAnalysisManager, Function *>
+    : public detail::AnalysisManagerBase<FunctionAnalysisManager, Function &> {
+  friend class detail::AnalysisManagerBase<FunctionAnalysisManager, Function &>;
+  typedef detail::AnalysisManagerBase<FunctionAnalysisManager, Function &>
       BaseT;
   typedef BaseT::ResultConceptT ResultConceptT;
   typedef BaseT::PassConceptT PassConceptT;
@@ -502,16 +502,16 @@ private:
   operator=(const FunctionAnalysisManager &) LLVM_DELETED_FUNCTION;
 
   /// \brief Get a function pass result, running the pass if necessary.
-  ResultConceptT &getResultImpl(void *PassID, Function *F);
+  ResultConceptT &getResultImpl(void *PassID, Function &F);
 
   /// \brief Get a cached function pass result or return null.
-  ResultConceptT *getCachedResultImpl(void *PassID, Function *F) const;
+  ResultConceptT *getCachedResultImpl(void *PassID, Function &F) const;
 
   /// \brief Invalidate a function pass result.
-  void invalidateImpl(void *PassID, Function *F);
+  void invalidateImpl(void *PassID, Function &F);
 
   /// \brief Invalidate the results for a function..
-  void invalidateImpl(Function *F, const PreservedAnalyses &PA);
+  void invalidateImpl(Function &F, const PreservedAnalyses &PA);
 
   /// \brief List of function analysis pass IDs and associated concept pointers.
   ///
@@ -519,7 +519,7 @@ private:
   /// erases. Provides both the pass ID and concept pointer such that it is
   /// half of a bijection and provides storage for the actual result concept.
   typedef std::list<std::pair<
-      void *, std::unique_ptr<detail::AnalysisResultConcept<Function *>>>>
+      void *, std::unique_ptr<detail::AnalysisResultConcept<Function &>>>>
       FunctionAnalysisResultListT;
 
   /// \brief Map type from function pointer to our custom list type.
@@ -581,7 +581,7 @@ public:
   /// In debug builds, it will also assert that the analysis manager is empty
   /// as no queries should arrive at the function analysis manager prior to
   /// this analysis being requested.
-  Result run(Module *M);
+  Result run(Module &M);
 
 private:
   static char PassID;
@@ -619,7 +619,7 @@ public:
   /// Regardless of whether this analysis is marked as preserved, all of the
   /// analyses in the \c FunctionAnalysisManager are potentially invalidated
   /// based on the set of preserved analyses.
-  bool invalidate(Module *M, const PreservedAnalyses &PA);
+  bool invalidate(Module &M, const PreservedAnalyses &PA);
 
 private:
   FunctionAnalysisManager *FAM;
@@ -655,7 +655,7 @@ public:
     const ModuleAnalysisManager &getManager() const { return *MAM; }
 
     /// \brief Handle invalidation by ignoring it, this pass is immutable.
-    bool invalidate(Function *) { return false; }
+    bool invalidate(Function &) { return false; }
 
   private:
     const ModuleAnalysisManager *MAM;
@@ -681,7 +681,7 @@ public:
   /// \brief Run the analysis pass and create our proxy result object.
   /// Nothing to see here, it just forwards the \c MAM reference into the
   /// result.
-  Result run(Function *) { return Result(*MAM); }
+  Result run(Function &) { return Result(*MAM); }
 
 private:
   static char PassID;
@@ -718,21 +718,21 @@ public:
   }
 
   /// \brief Runs the function pass across every function in the module.
-  PreservedAnalyses run(Module *M, ModuleAnalysisManager *AM) {
+  PreservedAnalyses run(Module &M, ModuleAnalysisManager *AM) {
     FunctionAnalysisManager *FAM = nullptr;
     if (AM)
       // Setup the function analysis manager from its proxy.
       FAM = &AM->getResult<FunctionAnalysisManagerModuleProxy>(M).getManager();
 
     PreservedAnalyses PA = PreservedAnalyses::all();
-    for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I) {
-      PreservedAnalyses PassPA = Pass.run(I, FAM);
+    for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) {
+      PreservedAnalyses PassPA = Pass.run(*I, FAM);
 
       // We know that the function pass couldn't have invalidated any other
       // function's analyses (that's the contract of a function pass), so
       // directly handle the function analysis manager's invalidation here.
       if (FAM)
-        FAM->invalidate(I, PassPA);
+        FAM->invalidate(*I, PassPA);
 
       // Then intersect the preserved set so that invalidation of module
       // analyses will eventually occur when the module pass completes.

Modified: llvm/trunk/include/llvm/IR/Verifier.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Verifier.h?rev=225145&r1=225144&r2=225145&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/Verifier.h (original)
+++ llvm/trunk/include/llvm/IR/Verifier.h Sun Jan  4 20:47:05 2015
@@ -77,8 +77,8 @@ class VerifierPass {
 public:
   explicit VerifierPass(bool FatalErrors = true) : FatalErrors(FatalErrors) {}
 
-  PreservedAnalyses run(Module *M);
-  PreservedAnalyses run(Function *F);
+  PreservedAnalyses run(Module &M);
+  PreservedAnalyses run(Function &F);
 
   static StringRef name() { return "VerifierPass"; }
 };

Modified: llvm/trunk/lib/Analysis/CGSCCPassManager.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/CGSCCPassManager.cpp?rev=225145&r1=225144&r2=225145&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/CGSCCPassManager.cpp (original)
+++ llvm/trunk/lib/Analysis/CGSCCPassManager.cpp Sun Jan  4 20:47:05 2015
@@ -17,7 +17,7 @@ static cl::opt<bool>
 DebugPM("debug-cgscc-pass-manager", cl::Hidden,
         cl::desc("Print CGSCC pass management debugging information"));
 
-PreservedAnalyses CGSCCPassManager::run(LazyCallGraph::SCC *C,
+PreservedAnalyses CGSCCPassManager::run(LazyCallGraph::SCC &C,
                                         CGSCCAnalysisManager *AM) {
   PreservedAnalyses PA = PreservedAnalyses::all();
 
@@ -53,16 +53,16 @@ void CGSCCAnalysisManager::clear() {
 }
 
 CGSCCAnalysisManager::ResultConceptT &
-CGSCCAnalysisManager::getResultImpl(void *PassID, LazyCallGraph::SCC *C) {
+CGSCCAnalysisManager::getResultImpl(void *PassID, LazyCallGraph::SCC &C) {
   CGSCCAnalysisResultMapT::iterator RI;
   bool Inserted;
   std::tie(RI, Inserted) = CGSCCAnalysisResults.insert(std::make_pair(
-      std::make_pair(PassID, C), CGSCCAnalysisResultListT::iterator()));
+      std::make_pair(PassID, &C), CGSCCAnalysisResultListT::iterator()));
 
   // If we don't have a cached result for this function, look up the pass and
   // run it to produce a result, which we then add to the cache.
   if (Inserted) {
-    CGSCCAnalysisResultListT &ResultList = CGSCCAnalysisResultLists[C];
+    CGSCCAnalysisResultListT &ResultList = CGSCCAnalysisResultLists[&C];
     ResultList.emplace_back(PassID, lookupPass(PassID).run(C, this));
     RI->second = std::prev(ResultList.end());
   }
@@ -72,27 +72,27 @@ CGSCCAnalysisManager::getResultImpl(void
 
 CGSCCAnalysisManager::ResultConceptT *
 CGSCCAnalysisManager::getCachedResultImpl(void *PassID,
-                                          LazyCallGraph::SCC *C) const {
+                                          LazyCallGraph::SCC &C) const {
   CGSCCAnalysisResultMapT::const_iterator RI =
-      CGSCCAnalysisResults.find(std::make_pair(PassID, C));
+      CGSCCAnalysisResults.find(std::make_pair(PassID, &C));
   return RI == CGSCCAnalysisResults.end() ? nullptr : &*RI->second->second;
 }
 
-void CGSCCAnalysisManager::invalidateImpl(void *PassID, LazyCallGraph::SCC *C) {
+void CGSCCAnalysisManager::invalidateImpl(void *PassID, LazyCallGraph::SCC &C) {
   CGSCCAnalysisResultMapT::iterator RI =
-      CGSCCAnalysisResults.find(std::make_pair(PassID, C));
+      CGSCCAnalysisResults.find(std::make_pair(PassID, &C));
   if (RI == CGSCCAnalysisResults.end())
     return;
 
-  CGSCCAnalysisResultLists[C].erase(RI->second);
+  CGSCCAnalysisResultLists[&C].erase(RI->second);
 }
 
-void CGSCCAnalysisManager::invalidateImpl(LazyCallGraph::SCC *C,
+void CGSCCAnalysisManager::invalidateImpl(LazyCallGraph::SCC &C,
                                           const PreservedAnalyses &PA) {
   // Clear all the invalidated results associated specifically with this
   // function.
   SmallVector<void *, 8> InvalidatedPassIDs;
-  CGSCCAnalysisResultListT &ResultsList = CGSCCAnalysisResultLists[C];
+  CGSCCAnalysisResultListT &ResultsList = CGSCCAnalysisResultLists[&C];
   for (CGSCCAnalysisResultListT::iterator I = ResultsList.begin(),
                                           E = ResultsList.end();
        I != E;)
@@ -104,14 +104,14 @@ void CGSCCAnalysisManager::invalidateImp
     }
   while (!InvalidatedPassIDs.empty())
     CGSCCAnalysisResults.erase(
-        std::make_pair(InvalidatedPassIDs.pop_back_val(), C));
-  CGSCCAnalysisResultLists.erase(C);
+        std::make_pair(InvalidatedPassIDs.pop_back_val(), &C));
+  CGSCCAnalysisResultLists.erase(&C);
 }
 
 char CGSCCAnalysisManagerModuleProxy::PassID;
 
 CGSCCAnalysisManagerModuleProxy::Result
-CGSCCAnalysisManagerModuleProxy::run(Module *M) {
+CGSCCAnalysisManagerModuleProxy::run(Module &M) {
   assert(CGAM->empty() && "CGSCC analyses ran prior to the module proxy!");
   return Result(*CGAM);
 }
@@ -123,7 +123,7 @@ CGSCCAnalysisManagerModuleProxy::Result:
 }
 
 bool CGSCCAnalysisManagerModuleProxy::Result::invalidate(
-    Module *M, const PreservedAnalyses &PA) {
+    Module &M, const PreservedAnalyses &PA) {
   // If this proxy isn't marked as preserved, then we can't even invalidate
   // individual CGSCC analyses, there may be an invalid set of SCC objects in
   // the cache making it impossible to incrementally preserve them.
@@ -140,7 +140,7 @@ char ModuleAnalysisManagerCGSCCProxy::Pa
 char FunctionAnalysisManagerCGSCCProxy::PassID;
 
 FunctionAnalysisManagerCGSCCProxy::Result
-FunctionAnalysisManagerCGSCCProxy::run(LazyCallGraph::SCC *C) {
+FunctionAnalysisManagerCGSCCProxy::run(LazyCallGraph::SCC &C) {
   assert(FAM->empty() && "Function analyses ran prior to the CGSCC proxy!");
   return Result(*FAM);
 }
@@ -152,7 +152,7 @@ FunctionAnalysisManagerCGSCCProxy::Resul
 }
 
 bool FunctionAnalysisManagerCGSCCProxy::Result::invalidate(
-    LazyCallGraph::SCC *C, const PreservedAnalyses &PA) {
+    LazyCallGraph::SCC &C, const PreservedAnalyses &PA) {
   // If this proxy isn't marked as preserved, then we can't even invalidate
   // individual function analyses, there may be an invalid set of Function
   // objects in the cache making it impossible to incrementally preserve them.

Modified: llvm/trunk/lib/Analysis/LazyCallGraph.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/LazyCallGraph.cpp?rev=225145&r1=225144&r2=225145&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/LazyCallGraph.cpp (original)
+++ llvm/trunk/lib/Analysis/LazyCallGraph.cpp Sun Jan  4 20:47:05 2015
@@ -708,11 +708,11 @@ static void printSCC(raw_ostream &OS, La
   OS << "\n";
 }
 
-PreservedAnalyses LazyCallGraphPrinterPass::run(Module *M,
+PreservedAnalyses LazyCallGraphPrinterPass::run(Module &M,
                                                 ModuleAnalysisManager *AM) {
   LazyCallGraph &G = AM->getResult<LazyCallGraphAnalysis>(M);
 
-  OS << "Printing the call graph for module: " << M->getModuleIdentifier()
+  OS << "Printing the call graph for module: " << M.getModuleIdentifier()
      << "\n\n";
 
   SmallPtrSet<LazyCallGraph::Node *, 16> Printed;
@@ -724,5 +724,4 @@ PreservedAnalyses LazyCallGraphPrinterPa
     printSCC(OS, SCC);
 
   return PreservedAnalyses::all();
-
 }

Modified: llvm/trunk/lib/Bitcode/Writer/BitcodeWriterPass.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/BitcodeWriterPass.cpp?rev=225145&r1=225144&r2=225145&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Writer/BitcodeWriterPass.cpp (original)
+++ llvm/trunk/lib/Bitcode/Writer/BitcodeWriterPass.cpp Sun Jan  4 20:47:05 2015
@@ -18,8 +18,8 @@
 #include "llvm/Pass.h"
 using namespace llvm;
 
-PreservedAnalyses BitcodeWriterPass::run(Module *M) {
-  WriteBitcodeToFile(M, OS);
+PreservedAnalyses BitcodeWriterPass::run(Module &M) {
+  WriteBitcodeToFile(&M, OS);
   return PreservedAnalyses::all();
 }
 

Modified: llvm/trunk/lib/IR/IRPrintingPasses.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/IRPrintingPasses.cpp?rev=225145&r1=225144&r2=225145&view=diff
==============================================================================
--- llvm/trunk/lib/IR/IRPrintingPasses.cpp (original)
+++ llvm/trunk/lib/IR/IRPrintingPasses.cpp Sun Jan  4 20:47:05 2015
@@ -24,8 +24,8 @@ PrintModulePass::PrintModulePass() : OS(
 PrintModulePass::PrintModulePass(raw_ostream &OS, const std::string &Banner)
     : OS(OS), Banner(Banner) {}
 
-PreservedAnalyses PrintModulePass::run(Module *M) {
-  OS << Banner << *M;
+PreservedAnalyses PrintModulePass::run(Module &M) {
+  OS << Banner << M;
   return PreservedAnalyses::all();
 }
 
@@ -33,8 +33,8 @@ PrintFunctionPass::PrintFunctionPass() :
 PrintFunctionPass::PrintFunctionPass(raw_ostream &OS, const std::string &Banner)
     : OS(OS), Banner(Banner) {}
 
-PreservedAnalyses PrintFunctionPass::run(Function *F) {
-  OS << Banner << static_cast<Value &>(*F);
+PreservedAnalyses PrintFunctionPass::run(Function &F) {
+  OS << Banner << static_cast<Value &>(F);
   return PreservedAnalyses::all();
 }
 
@@ -50,7 +50,7 @@ public:
       : ModulePass(ID), P(OS, Banner) {}
 
   bool runOnModule(Module &M) override {
-    P.run(&M);
+    P.run(M);
     return false;
   }
 
@@ -70,7 +70,7 @@ public:
 
   // This pass just prints a banner followed by the function as it's processed.
   bool runOnFunction(Function &F) override {
-    P.run(&F);
+    P.run(F);
     return false;
   }
 

Modified: llvm/trunk/lib/IR/PassManager.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/PassManager.cpp?rev=225145&r1=225144&r2=225145&view=diff
==============================================================================
--- llvm/trunk/lib/IR/PassManager.cpp (original)
+++ llvm/trunk/lib/IR/PassManager.cpp Sun Jan  4 20:47:05 2015
@@ -19,7 +19,7 @@ static cl::opt<bool>
     DebugPM("debug-pass-manager", cl::Hidden,
             cl::desc("Print pass management debugging information"));
 
-PreservedAnalyses ModulePassManager::run(Module *M, ModuleAnalysisManager *AM) {
+PreservedAnalyses ModulePassManager::run(Module &M, ModuleAnalysisManager *AM) {
   PreservedAnalyses PA = PreservedAnalyses::all();
 
   if (DebugPM)
@@ -34,7 +34,7 @@ PreservedAnalyses ModulePassManager::run
       AM->invalidate(M, PassPA);
     PA.intersect(std::move(PassPA));
 
-    M->getContext().yield();
+    M.getContext().yield();
   }
 
   if (DebugPM)
@@ -44,11 +44,11 @@ PreservedAnalyses ModulePassManager::run
 }
 
 ModuleAnalysisManager::ResultConceptT &
-ModuleAnalysisManager::getResultImpl(void *PassID, Module *M) {
+ModuleAnalysisManager::getResultImpl(void *PassID, Module &M) {
   ModuleAnalysisResultMapT::iterator RI;
   bool Inserted;
   std::tie(RI, Inserted) = ModuleAnalysisResults.insert(std::make_pair(
-      PassID, std::unique_ptr<detail::AnalysisResultConcept<Module *>>()));
+      PassID, std::unique_ptr<detail::AnalysisResultConcept<Module &>>()));
 
   // If we don't have a cached result for this module, look up the pass and run
   // it to produce a result, which we then add to the cache.
@@ -59,17 +59,17 @@ ModuleAnalysisManager::getResultImpl(voi
 }
 
 ModuleAnalysisManager::ResultConceptT *
-ModuleAnalysisManager::getCachedResultImpl(void *PassID, Module *M) const {
+ModuleAnalysisManager::getCachedResultImpl(void *PassID, Module &M) const {
   ModuleAnalysisResultMapT::const_iterator RI =
       ModuleAnalysisResults.find(PassID);
   return RI == ModuleAnalysisResults.end() ? nullptr : &*RI->second;
 }
 
-void ModuleAnalysisManager::invalidateImpl(void *PassID, Module *M) {
+void ModuleAnalysisManager::invalidateImpl(void *PassID, Module &M) {
   ModuleAnalysisResults.erase(PassID);
 }
 
-void ModuleAnalysisManager::invalidateImpl(Module *M,
+void ModuleAnalysisManager::invalidateImpl(Module &M,
                                            const PreservedAnalyses &PA) {
   // FIXME: This is a total hack based on the fact that erasure doesn't
   // invalidate iteration for DenseMap.
@@ -80,7 +80,7 @@ void ModuleAnalysisManager::invalidateIm
       ModuleAnalysisResults.erase(I);
 }
 
-PreservedAnalyses FunctionPassManager::run(Function *F,
+PreservedAnalyses FunctionPassManager::run(Function &F,
                                            FunctionAnalysisManager *AM) {
   PreservedAnalyses PA = PreservedAnalyses::all();
 
@@ -96,7 +96,7 @@ PreservedAnalyses FunctionPassManager::r
       AM->invalidate(F, PassPA);
     PA.intersect(std::move(PassPA));
 
-    F->getContext().yield();
+    F.getContext().yield();
   }
 
   if (DebugPM)
@@ -119,16 +119,16 @@ void FunctionAnalysisManager::clear() {
 }
 
 FunctionAnalysisManager::ResultConceptT &
-FunctionAnalysisManager::getResultImpl(void *PassID, Function *F) {
+FunctionAnalysisManager::getResultImpl(void *PassID, Function &F) {
   FunctionAnalysisResultMapT::iterator RI;
   bool Inserted;
   std::tie(RI, Inserted) = FunctionAnalysisResults.insert(std::make_pair(
-      std::make_pair(PassID, F), FunctionAnalysisResultListT::iterator()));
+      std::make_pair(PassID, &F), FunctionAnalysisResultListT::iterator()));
 
   // If we don't have a cached result for this function, look up the pass and
   // run it to produce a result, which we then add to the cache.
   if (Inserted) {
-    FunctionAnalysisResultListT &ResultList = FunctionAnalysisResultLists[F];
+    FunctionAnalysisResultListT &ResultList = FunctionAnalysisResultLists[&F];
     ResultList.emplace_back(PassID, lookupPass(PassID).run(F, this));
     RI->second = std::prev(ResultList.end());
   }
@@ -137,27 +137,27 @@ FunctionAnalysisManager::getResultImpl(v
 }
 
 FunctionAnalysisManager::ResultConceptT *
-FunctionAnalysisManager::getCachedResultImpl(void *PassID, Function *F) const {
+FunctionAnalysisManager::getCachedResultImpl(void *PassID, Function &F) const {
   FunctionAnalysisResultMapT::const_iterator RI =
-      FunctionAnalysisResults.find(std::make_pair(PassID, F));
+      FunctionAnalysisResults.find(std::make_pair(PassID, &F));
   return RI == FunctionAnalysisResults.end() ? nullptr : &*RI->second->second;
 }
 
-void FunctionAnalysisManager::invalidateImpl(void *PassID, Function *F) {
+void FunctionAnalysisManager::invalidateImpl(void *PassID, Function &F) {
   FunctionAnalysisResultMapT::iterator RI =
-      FunctionAnalysisResults.find(std::make_pair(PassID, F));
+      FunctionAnalysisResults.find(std::make_pair(PassID, &F));
   if (RI == FunctionAnalysisResults.end())
     return;
 
-  FunctionAnalysisResultLists[F].erase(RI->second);
+  FunctionAnalysisResultLists[&F].erase(RI->second);
 }
 
-void FunctionAnalysisManager::invalidateImpl(Function *F,
+void FunctionAnalysisManager::invalidateImpl(Function &F,
                                              const PreservedAnalyses &PA) {
   // Clear all the invalidated results associated specifically with this
   // function.
   SmallVector<void *, 8> InvalidatedPassIDs;
-  FunctionAnalysisResultListT &ResultsList = FunctionAnalysisResultLists[F];
+  FunctionAnalysisResultListT &ResultsList = FunctionAnalysisResultLists[&F];
   for (FunctionAnalysisResultListT::iterator I = ResultsList.begin(),
                                              E = ResultsList.end();
        I != E;)
@@ -169,15 +169,15 @@ void FunctionAnalysisManager::invalidate
     }
   while (!InvalidatedPassIDs.empty())
     FunctionAnalysisResults.erase(
-        std::make_pair(InvalidatedPassIDs.pop_back_val(), F));
+        std::make_pair(InvalidatedPassIDs.pop_back_val(), &F));
   if (ResultsList.empty())
-    FunctionAnalysisResultLists.erase(F);
+    FunctionAnalysisResultLists.erase(&F);
 }
 
 char FunctionAnalysisManagerModuleProxy::PassID;
 
 FunctionAnalysisManagerModuleProxy::Result
-FunctionAnalysisManagerModuleProxy::run(Module *M) {
+FunctionAnalysisManagerModuleProxy::run(Module &M) {
   assert(FAM->empty() && "Function analyses ran prior to the module proxy!");
   return Result(*FAM);
 }
@@ -189,7 +189,7 @@ FunctionAnalysisManagerModuleProxy::Resu
 }
 
 bool FunctionAnalysisManagerModuleProxy::Result::invalidate(
-    Module *M, const PreservedAnalyses &PA) {
+    Module &M, const PreservedAnalyses &PA) {
   // If this proxy isn't marked as preserved, then we can't even invalidate
   // individual function analyses, there may be an invalid set of Function
   // objects in the cache making it impossible to incrementally preserve them.

Modified: llvm/trunk/lib/IR/Verifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Verifier.cpp?rev=225145&r1=225144&r2=225145&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Verifier.cpp (original)
+++ llvm/trunk/lib/IR/Verifier.cpp Sun Jan  4 20:47:05 2015
@@ -2902,15 +2902,15 @@ ModulePass *llvm::createDebugInfoVerifie
   return new DebugInfoVerifierLegacyPass(FatalErrors);
 }
 
-PreservedAnalyses VerifierPass::run(Module *M) {
-  if (verifyModule(*M, &dbgs()) && FatalErrors)
+PreservedAnalyses VerifierPass::run(Module &M) {
+  if (verifyModule(M, &dbgs()) && FatalErrors)
     report_fatal_error("Broken module found, compilation aborted!");
 
   return PreservedAnalyses::all();
 }
 
-PreservedAnalyses VerifierPass::run(Function *F) {
-  if (verifyFunction(*F, &dbgs()) && FatalErrors)
+PreservedAnalyses VerifierPass::run(Function &F) {
+  if (verifyFunction(F, &dbgs()) && FatalErrors)
     report_fatal_error("Broken function found, compilation aborted!");
 
   return PreservedAnalyses::all();

Modified: llvm/trunk/tools/opt/NewPMDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/opt/NewPMDriver.cpp?rev=225145&r1=225144&r2=225145&view=diff
==============================================================================
--- llvm/trunk/tools/opt/NewPMDriver.cpp (original)
+++ llvm/trunk/tools/opt/NewPMDriver.cpp Sun Jan  4 20:47:05 2015
@@ -86,7 +86,7 @@ bool llvm::runPassPipeline(StringRef Arg
   cl::PrintOptionValues();
 
   // Now that we have all of the passes ready, run them.
-  MPM.run(&M, &MAM);
+  MPM.run(M, &MAM);
 
   // Declare success.
   if (OK != OK_NoOutput)

Modified: llvm/trunk/tools/opt/Passes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/opt/Passes.cpp?rev=225145&r1=225144&r2=225145&view=diff
==============================================================================
--- llvm/trunk/tools/opt/Passes.cpp (original)
+++ llvm/trunk/tools/opt/Passes.cpp Sun Jan  4 20:47:05 2015
@@ -28,13 +28,13 @@ namespace {
 
 /// \brief No-op module pass which does nothing.
 struct NoOpModulePass {
-  PreservedAnalyses run(Module *M) { return PreservedAnalyses::all(); }
+  PreservedAnalyses run(Module &M) { return PreservedAnalyses::all(); }
   static StringRef name() { return "NoOpModulePass"; }
 };
 
 /// \brief No-op CGSCC pass which does nothing.
 struct NoOpCGSCCPass {
-  PreservedAnalyses run(LazyCallGraph::SCC *C) {
+  PreservedAnalyses run(LazyCallGraph::SCC &C) {
     return PreservedAnalyses::all();
   }
   static StringRef name() { return "NoOpCGSCCPass"; }
@@ -42,7 +42,7 @@ struct NoOpCGSCCPass {
 
 /// \brief No-op function pass which does nothing.
 struct NoOpFunctionPass {
-  PreservedAnalyses run(Function *F) { return PreservedAnalyses::all(); }
+  PreservedAnalyses run(Function &F) { return PreservedAnalyses::all(); }
   static StringRef name() { return "NoOpFunctionPass"; }
 };
 

Modified: llvm/trunk/unittests/IR/PassManagerTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/IR/PassManagerTest.cpp?rev=225145&r1=225144&r2=225145&view=diff
==============================================================================
--- llvm/trunk/unittests/IR/PassManagerTest.cpp (original)
+++ llvm/trunk/unittests/IR/PassManagerTest.cpp Sun Jan  4 20:47:05 2015
@@ -32,10 +32,10 @@ public:
   TestFunctionAnalysis(int &Runs) : Runs(Runs) {}
 
   /// \brief Run the analysis pass over the function and return a result.
-  Result run(Function *F, FunctionAnalysisManager *AM) {
+  Result run(Function &F, FunctionAnalysisManager *AM) {
     ++Runs;
     int Count = 0;
-    for (Function::iterator BBI = F->begin(), BBE = F->end(); BBI != BBE; ++BBI)
+    for (Function::iterator BBI = F.begin(), BBE = F.end(); BBI != BBE; ++BBI)
       for (BasicBlock::iterator II = BBI->begin(), IE = BBI->end(); II != IE;
            ++II)
         ++Count;
@@ -62,10 +62,10 @@ public:
 
   TestModuleAnalysis(int &Runs) : Runs(Runs) {}
 
-  Result run(Module *M, ModuleAnalysisManager *AM) {
+  Result run(Module &M, ModuleAnalysisManager *AM) {
     ++Runs;
     int Count = 0;
-    for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I)
+    for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I)
       ++Count;
     return Result(Count);
   }
@@ -81,7 +81,7 @@ char TestModuleAnalysis::PassID;
 struct TestModulePass {
   TestModulePass(int &RunCount) : RunCount(RunCount) {}
 
-  PreservedAnalyses run(Module *M) {
+  PreservedAnalyses run(Module &M) {
     ++RunCount;
     return PreservedAnalyses::none();
   }
@@ -92,13 +92,13 @@ struct TestModulePass {
 };
 
 struct TestPreservingModulePass {
-  PreservedAnalyses run(Module *M) { return PreservedAnalyses::all(); }
+  PreservedAnalyses run(Module &M) { return PreservedAnalyses::all(); }
 
   static StringRef name() { return "TestPreservingModulePass"; }
 };
 
 struct TestMinPreservingModulePass {
-  PreservedAnalyses run(Module *M, ModuleAnalysisManager *AM) {
+  PreservedAnalyses run(Module &M, ModuleAnalysisManager *AM) {
     PreservedAnalyses PA;
 
     // Force running an analysis.
@@ -119,13 +119,13 @@ struct TestFunctionPass {
         AnalyzedFunctionCount(AnalyzedFunctionCount),
         OnlyUseCachedResults(OnlyUseCachedResults) {}
 
-  PreservedAnalyses run(Function *F, FunctionAnalysisManager *AM) {
+  PreservedAnalyses run(Function &F, FunctionAnalysisManager *AM) {
     ++RunCount;
 
     const ModuleAnalysisManager &MAM =
         AM->getResult<ModuleAnalysisManagerFunctionProxy>(F).getManager();
     if (TestModuleAnalysis::Result *TMA =
-            MAM.getCachedResult<TestModuleAnalysis>(F->getParent()))
+            MAM.getCachedResult<TestModuleAnalysis>(*F.getParent()))
       AnalyzedFunctionCount += TMA->FunctionCount;
 
     if (OnlyUseCachedResults) {
@@ -155,9 +155,9 @@ struct TestFunctionPass {
 struct TestInvalidationFunctionPass {
   TestInvalidationFunctionPass(StringRef FunctionName) : Name(FunctionName) {}
 
-  PreservedAnalyses run(Function *F) {
-    return F->getName() == Name ? PreservedAnalyses::none()
-                                : PreservedAnalyses::all();
+  PreservedAnalyses run(Function &F) {
+    return F.getName() == Name ? PreservedAnalyses::none()
+                               : PreservedAnalyses::all();
   }
 
   static StringRef name() { return "TestInvalidationFunctionPass"; }
@@ -165,10 +165,10 @@ struct TestInvalidationFunctionPass {
   StringRef Name;
 };
 
-Module *parseIR(const char *IR) {
+std::unique_ptr<Module> parseIR(const char *IR) {
   LLVMContext &C = getGlobalContext();
   SMDiagnostic Err;
-  return parseAssemblyString(IR, Err, C).release();
+  return parseAssemblyString(IR, Err, C);
 }
 
 class PassManagerTest : public ::testing::Test {
@@ -310,7 +310,7 @@ TEST_F(PassManagerTest, Basic) {
     MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
   }
 
-  MPM.run(M.get(), &MAM);
+  MPM.run(*M, &MAM);
 
   // Validate module pass counters.
   EXPECT_EQ(1, ModulePassRunCount);





More information about the llvm-commits mailing list