[llvm-commits] [llvm] r74640 - in /llvm/trunk: examples/BrainF/ examples/Fibonacci/ examples/HowToUseJIT/ examples/Kaleidoscope/ examples/ModuleMaker/ examples/ParallelJIT/ include/llvm-c/ include/llvm/ include/llvm/Assembly/ include/llvm/Bitcode/ include/llvm/Debugger/ lib/Archive/ lib/AsmParser/ lib/Bitcode/Reader/ lib/Debugger/ lib/Linker/ lib/VMCore/ tools/bugpoint/ tools/llc/ tools/lli/ tools/llvm-ar/ tools/llvm-as/ tools/llvm-db/ tools/llvm-dis/ tools/llvm-extract/ tools/llvm-ld/ tools/llvm-link/ tools/llvm-nm/ t...

Owen Anderson resistor at mac.com
Wed Jul 1 14:22:36 PDT 2009


Author: resistor
Date: Wed Jul  1 16:22:36 2009
New Revision: 74640

URL: http://llvm.org/viewvc/llvm-project?rev=74640&view=rev
Log:
Hold the LLVMContext by reference rather than by pointer.

Modified:
    llvm/trunk/examples/BrainF/BrainF.cpp
    llvm/trunk/examples/BrainF/BrainF.h
    llvm/trunk/examples/BrainF/BrainFDriver.cpp
    llvm/trunk/examples/Fibonacci/fibonacci.cpp
    llvm/trunk/examples/HowToUseJIT/HowToUseJIT.cpp
    llvm/trunk/examples/Kaleidoscope/toy.cpp
    llvm/trunk/examples/ModuleMaker/ModuleMaker.cpp
    llvm/trunk/examples/ParallelJIT/ParallelJIT.cpp
    llvm/trunk/include/llvm-c/lto.h
    llvm/trunk/include/llvm/Assembly/Parser.h
    llvm/trunk/include/llvm/Bitcode/Archive.h
    llvm/trunk/include/llvm/Bitcode/ReaderWriter.h
    llvm/trunk/include/llvm/Debugger/Debugger.h
    llvm/trunk/include/llvm/LLVMContext.h
    llvm/trunk/include/llvm/LinkAllVMCore.h
    llvm/trunk/include/llvm/Linker.h
    llvm/trunk/include/llvm/Module.h
    llvm/trunk/lib/Archive/Archive.cpp
    llvm/trunk/lib/Archive/ArchiveInternals.h
    llvm/trunk/lib/Archive/ArchiveReader.cpp
    llvm/trunk/lib/Archive/ArchiveWriter.cpp
    llvm/trunk/lib/AsmParser/Parser.cpp
    llvm/trunk/lib/Bitcode/Reader/BitReader.cpp
    llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
    llvm/trunk/lib/Bitcode/Reader/BitcodeReader.h
    llvm/trunk/lib/Debugger/Debugger.cpp
    llvm/trunk/lib/Linker/Linker.cpp
    llvm/trunk/lib/VMCore/Core.cpp
    llvm/trunk/lib/VMCore/LLVMContext.cpp
    llvm/trunk/lib/VMCore/Module.cpp
    llvm/trunk/tools/bugpoint/BugDriver.cpp
    llvm/trunk/tools/bugpoint/BugDriver.h
    llvm/trunk/tools/bugpoint/bugpoint.cpp
    llvm/trunk/tools/llc/llc.cpp
    llvm/trunk/tools/lli/lli.cpp
    llvm/trunk/tools/llvm-ar/llvm-ar.cpp
    llvm/trunk/tools/llvm-as/llvm-as.cpp
    llvm/trunk/tools/llvm-db/CLIDebugger.cpp
    llvm/trunk/tools/llvm-db/CLIDebugger.h
    llvm/trunk/tools/llvm-db/llvm-db.cpp
    llvm/trunk/tools/llvm-dis/llvm-dis.cpp
    llvm/trunk/tools/llvm-extract/llvm-extract.cpp
    llvm/trunk/tools/llvm-ld/llvm-ld.cpp
    llvm/trunk/tools/llvm-link/llvm-link.cpp
    llvm/trunk/tools/llvm-nm/llvm-nm.cpp
    llvm/trunk/tools/llvm-prof/llvm-prof.cpp
    llvm/trunk/tools/llvm-ranlib/llvm-ranlib.cpp
    llvm/trunk/tools/lto/LTOCodeGenerator.cpp
    llvm/trunk/tools/lto/LTOCodeGenerator.h
    llvm/trunk/tools/lto/LTOModule.cpp
    llvm/trunk/tools/lto/LTOModule.h
    llvm/trunk/tools/lto/lto.cpp
    llvm/trunk/tools/opt/opt.cpp
    llvm/trunk/unittests/ExecutionEngine/JIT/JITEventListenerTest.cpp
    llvm/trunk/unittests/VMCore/PassManagerTest.cpp

Modified: llvm/trunk/examples/BrainF/BrainF.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/BrainF/BrainF.cpp?rev=74640&r1=74639&r2=74640&view=diff

==============================================================================
--- llvm/trunk/examples/BrainF/BrainF.cpp (original)
+++ llvm/trunk/examples/BrainF/BrainF.cpp Wed Jul  1 16:22:36 2009
@@ -37,7 +37,7 @@
 const char *BrainF::testreg = "test";
 
 Module *BrainF::parse(std::istream *in1, int mem, CompileFlags cf,
-                      LLVMContext* Context) {
+                      const LLVMContext& Context) {
   in       = in1;
   memtotal = mem;
   comflag  = cf;
@@ -48,7 +48,7 @@
   return module;
 }
 
-void BrainF::header(LLVMContext* C) {
+void BrainF::header(const LLVMContext& C) {
   module = new Module("BrainF", C);
 
   //Function prototypes

Modified: llvm/trunk/examples/BrainF/BrainF.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/BrainF/BrainF.h?rev=74640&r1=74639&r2=74640&view=diff

==============================================================================
--- llvm/trunk/examples/BrainF/BrainF.h (original)
+++ llvm/trunk/examples/BrainF/BrainF.h Wed Jul  1 16:22:36 2009
@@ -39,7 +39,8 @@
     /// containing the resulting code.
     /// On error, it calls abort.
     /// The caller must delete the returned module.
-    Module *parse(std::istream *in1, int mem, CompileFlags cf, LLVMContext* C);
+    Module *parse(std::istream *in1, int mem, CompileFlags cf,
+                  const LLVMContext& C);
 
   protected:
     /// The different symbols in the BrainF language
@@ -65,7 +66,7 @@
     static const char *testreg;
 
     /// Put the brainf function preamble and other fixed pieces of code
-    void header(LLVMContext* C);
+    void header(const LLVMContext& C);
 
     /// The main loop for parsing.  It calls itself recursively
     /// to handle the depth of nesting of "[]".

Modified: llvm/trunk/examples/BrainF/BrainFDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/BrainF/BrainFDriver.cpp?rev=74640&r1=74639&r2=74640&view=diff

==============================================================================
--- llvm/trunk/examples/BrainF/BrainFDriver.cpp (original)
+++ llvm/trunk/examples/BrainF/BrainFDriver.cpp Wed Jul  1 16:22:36 2009
@@ -126,7 +126,7 @@
 
   //Read the BrainF program
   BrainF bf;
-  Module *mod = bf.parse(in, 65536, cf, &Context); //64 KiB
+  Module *mod = bf.parse(in, 65536, cf, Context); //64 KiB
   if (in != &std::cin) {delete in;}
   addMainFunction(mod);
 

Modified: llvm/trunk/examples/Fibonacci/fibonacci.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/Fibonacci/fibonacci.cpp?rev=74640&r1=74639&r2=74640&view=diff

==============================================================================
--- llvm/trunk/examples/Fibonacci/fibonacci.cpp (original)
+++ llvm/trunk/examples/Fibonacci/fibonacci.cpp Wed Jul  1 16:22:36 2009
@@ -94,7 +94,7 @@
   LLVMContext Context;
   
   // Create some module to put our function into it.
-  Module *M = new Module("test", &Context);
+  Module *M = new Module("test", Context);
 
   // We are about to create the "fib" function:
   Function *FibF = CreateFibFunction(M);

Modified: llvm/trunk/examples/HowToUseJIT/HowToUseJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/HowToUseJIT/HowToUseJIT.cpp?rev=74640&r1=74639&r2=74640&view=diff

==============================================================================
--- llvm/trunk/examples/HowToUseJIT/HowToUseJIT.cpp (original)
+++ llvm/trunk/examples/HowToUseJIT/HowToUseJIT.cpp Wed Jul  1 16:22:36 2009
@@ -55,7 +55,7 @@
   LLVMContext Context;
   
   // Create some module to put our function into it.
-  Module *M = new Module("test", &Context);
+  Module *M = new Module("test", Context);
 
   // Create the add1 function entry and insert this entry into module M.  The
   // function will have a return type of "int" and take an argument of "int".

Modified: llvm/trunk/examples/Kaleidoscope/toy.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/Kaleidoscope/toy.cpp?rev=74640&r1=74639&r2=74640&view=diff

==============================================================================
--- llvm/trunk/examples/Kaleidoscope/toy.cpp (original)
+++ llvm/trunk/examples/Kaleidoscope/toy.cpp Wed Jul  1 16:22:36 2009
@@ -1099,7 +1099,7 @@
   getNextToken();
 
   // Make the module, which holds all the code.
-  TheModule = new Module("my cool jit", &Context);
+  TheModule = new Module("my cool jit", Context);
   
   // Create the JIT.
   TheExecutionEngine = ExecutionEngine::create(TheModule);

Modified: llvm/trunk/examples/ModuleMaker/ModuleMaker.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/ModuleMaker/ModuleMaker.cpp?rev=74640&r1=74639&r2=74640&view=diff

==============================================================================
--- llvm/trunk/examples/ModuleMaker/ModuleMaker.cpp (original)
+++ llvm/trunk/examples/ModuleMaker/ModuleMaker.cpp Wed Jul  1 16:22:36 2009
@@ -27,7 +27,7 @@
 
   // Create the "module" or "program" or "translation unit" to hold the
   // function
-  Module *M = new Module("test", &Context);
+  Module *M = new Module("test", Context);
 
   // Create the main function: first create the type 'int ()'
   FunctionType *FT = FunctionType::get(Type::Int32Ty, /*not vararg*/false);

Modified: llvm/trunk/examples/ParallelJIT/ParallelJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/ParallelJIT/ParallelJIT.cpp?rev=74640&r1=74639&r2=74640&view=diff

==============================================================================
--- llvm/trunk/examples/ParallelJIT/ParallelJIT.cpp (original)
+++ llvm/trunk/examples/ParallelJIT/ParallelJIT.cpp Wed Jul  1 16:22:36 2009
@@ -236,7 +236,7 @@
   LLVMContext Context;
 
   // Create some module to put our function into it.
-  Module *M = new Module("test", &Context);
+  Module *M = new Module("test", Context);
 
   Function* add1F = createAdd1( M );
   Function* fibF = CreateFibFunction( M );

Modified: llvm/trunk/include/llvm-c/lto.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/lto.h?rev=74640&r1=74639&r2=74640&view=diff

==============================================================================
--- llvm/trunk/include/llvm-c/lto.h (original)
+++ llvm/trunk/include/llvm-c/lto.h Wed Jul  1 16:22:36 2009
@@ -58,6 +58,7 @@
 /** opaque reference to a code generator */
 typedef struct LTOCodeGenerator*  lto_code_gen_t;
 
+typedef struct LTOContext*        lto_context_t;
 
 #ifdef __cplusplus
 extern "C" {
@@ -76,7 +77,6 @@
 extern const char*
 lto_get_error_message(void);
 
-
 /**
  * Checks if a file is a loadable object file.
  */

Modified: llvm/trunk/include/llvm/Assembly/Parser.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Assembly/Parser.h?rev=74640&r1=74639&r2=74640&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Assembly/Parser.h (original)
+++ llvm/trunk/include/llvm/Assembly/Parser.h Wed Jul  1 16:22:36 2009
@@ -32,7 +32,7 @@
 Module *ParseAssemblyFile(
   const std::string &Filename, ///< The name of the file to parse
   ParseError &Error,           ///< If not null, an object to return errors in.
-  LLVMContext* Context         ///< Context in which to allocate globals info.
+  const LLVMContext& Context         ///< Context in which to allocate globals info.
 );
 
 /// The function is a secondary interface to the LLVM Assembly Parser. It parses
@@ -45,7 +45,7 @@
   const char *AsmString, ///< The string containing assembly
   Module *M,             ///< A module to add the assembly too.
   ParseError &Error,     ///< If not null, an object to return errors in.
-  LLVMContext* Context
+  const LLVMContext& Context
 );
 
 //===------------------------------------------------------------------------===

Modified: llvm/trunk/include/llvm/Bitcode/Archive.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Bitcode/Archive.h?rev=74640&r1=74639&r2=74640&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Bitcode/Archive.h (original)
+++ llvm/trunk/include/llvm/Bitcode/Archive.h Wed Jul  1 16:22:36 2009
@@ -280,7 +280,7 @@
     /// @brief Create an empty Archive.
     static Archive* CreateEmpty(
       const sys::Path& Filename,///< Name of the archive to (eventually) create.
-      LLVMContext* C            ///< Context to use for global information
+      const LLVMContext& C            ///< Context to use for global information
     );
 
     /// Open an existing archive and load its contents in preparation for
@@ -291,7 +291,7 @@
     /// @brief Open and load an archive file
     static Archive* OpenAndLoad(
       const sys::Path& filePath,  ///< The file path to open and load
-      LLVMContext* C,             ///< The context to use for global information
+      const LLVMContext& C,       ///< The context to use for global information
       std::string* ErrorMessage   ///< An optional error string
     );
 
@@ -313,7 +313,7 @@
     /// @brief Open an existing archive and load its symbols.
     static Archive* OpenAndLoadSymbols(
       const sys::Path& Filename,   ///< Name of the archive file to open
-      LLVMContext* C,              ///< The context to use for global info
+      const LLVMContext& C,              ///< The context to use for global info
       std::string* ErrorMessage=0  ///< An optional error string
     );
 
@@ -453,7 +453,7 @@
   protected:
     /// @brief Construct an Archive for \p filename and optionally  map it
     /// into memory.
-    explicit Archive(const sys::Path& filename, LLVMContext* C);
+    explicit Archive(const sys::Path& filename, const LLVMContext& C);
 
     /// @param data The symbol table data to be parsed
     /// @param len  The length of the symbol table data
@@ -534,7 +534,7 @@
     unsigned firstFileOffset; ///< Offset to first normal file.
     ModuleMap modules;        ///< The modules loaded via symbol lookup.
     ArchiveMember* foreignST; ///< This holds the foreign symbol table.
-    LLVMContext* Context;     ///< This holds global data.
+    const LLVMContext& Context;     ///< This holds global data.
   /// @}
   /// @name Hidden
   /// @{

Modified: llvm/trunk/include/llvm/Bitcode/ReaderWriter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Bitcode/ReaderWriter.h?rev=74640&r1=74639&r2=74640&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Bitcode/ReaderWriter.h (original)
+++ llvm/trunk/include/llvm/Bitcode/ReaderWriter.h Wed Jul  1 16:22:36 2009
@@ -32,13 +32,13 @@
   /// error, this returns null, *does not* take ownership of Buffer, and fills
   /// in *ErrMsg with an error description if ErrMsg is non-null.
   ModuleProvider *getBitcodeModuleProvider(MemoryBuffer *Buffer,
-                                           LLVMContext* Context,
+                                           const LLVMContext& Context,
                                            std::string *ErrMsg = 0);
 
   /// ParseBitcodeFile - Read the specified bitcode file, returning the module.
   /// If an error occurs, this returns null and fills in *ErrMsg if it is
   /// non-null.  This method *never* takes ownership of Buffer.
-  Module *ParseBitcodeFile(MemoryBuffer *Buffer, LLVMContext* Context,
+  Module *ParseBitcodeFile(MemoryBuffer *Buffer, const LLVMContext& Context,
                            std::string *ErrMsg = 0);
 
   /// WriteBitcodeToFile - Write the specified module to the specified output

Modified: llvm/trunk/include/llvm/Debugger/Debugger.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Debugger/Debugger.h?rev=74640&r1=74639&r2=74640&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Debugger/Debugger.h (original)
+++ llvm/trunk/include/llvm/Debugger/Debugger.h Wed Jul  1 16:22:36 2009
@@ -96,7 +96,7 @@
     /// the PATH for the specified program, loading it when found.  If the
     /// specified program cannot be found, an exception is thrown to indicate
     /// the error.
-    void loadProgram(const std::string &Path, LLVMContext* Context);
+    void loadProgram(const std::string &Path, const LLVMContext& Context);
 
     /// unloadProgram - If a program is running, kill it, then unload all traces
     /// of the current program.  If no program is loaded, this method silently

Modified: llvm/trunk/include/llvm/LLVMContext.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/LLVMContext.h?rev=74640&r1=74639&r2=74640&view=diff

==============================================================================
--- llvm/trunk/include/llvm/LLVMContext.h (original)
+++ llvm/trunk/include/llvm/LLVMContext.h Wed Jul  1 16:22:36 2009
@@ -198,7 +198,7 @@
 };
 
 /// FOR BACKWARDS COMPATIBILITY - Returns a global context.
-LLVMContext* getGlobalContext();
+extern const LLVMContext& getGlobalContext();
 
 }
 

Modified: llvm/trunk/include/llvm/LinkAllVMCore.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/LinkAllVMCore.h?rev=74640&r1=74639&r2=74640&view=diff

==============================================================================
--- llvm/trunk/include/llvm/LinkAllVMCore.h (original)
+++ llvm/trunk/include/llvm/LinkAllVMCore.h Wed Jul  1 16:22:36 2009
@@ -16,6 +16,7 @@
 #ifndef LLVM_LINKALLVMCORE_H
 #define LLVM_LINKALLVMCORE_H
 
+#include "llvm/LLVMContext.h"
 #include "llvm/Module.h"
 #include "llvm/Instructions.h"
 #include "llvm/IntrinsicInst.h"
@@ -44,7 +45,7 @@
       // to know that getenv() never returns -1, this will do the job.
       if (std::getenv("bar") != (char*) -1)
         return;
-      llvm::Module* M = new llvm::Module("", 0);
+      llvm::Module* M = new llvm::Module("", llvm::getGlobalContext());
       (void)new llvm::UnreachableInst();
       (void)    llvm::createVerifierPass(); 
       (void) new llvm::Mangler(*M,"");

Modified: llvm/trunk/include/llvm/Linker.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Linker.h?rev=74640&r1=74639&r2=74640&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Linker.h (original)
+++ llvm/trunk/include/llvm/Linker.h Wed Jul  1 16:22:36 2009
@@ -67,7 +67,7 @@
     Linker(
         const std::string& progname, ///< name of tool running linker
         const std::string& modulename, ///< name of linker's end-result module
-        LLVMContext* C, ///< Context for global info
+        const LLVMContext& C, ///< Context for global info
         unsigned Flags = 0  ///< ControlFlags (one or more |'d together)
     );
 
@@ -285,7 +285,7 @@
   /// @name Data
   /// @{
   private:
-    LLVMContext* Context; ///< The context for global information
+    const LLVMContext& Context; ///< The context for global information
     Module* Composite; ///< The composite module linked together
     std::vector<sys::Path> LibPaths; ///< The library search paths
     unsigned Flags;    ///< Flags to control optional behavior.

Modified: llvm/trunk/include/llvm/Module.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Module.h?rev=74640&r1=74639&r2=74640&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Module.h (original)
+++ llvm/trunk/include/llvm/Module.h Wed Jul  1 16:22:36 2009
@@ -110,7 +110,7 @@
 /// @name Member Variables
 /// @{
 private:
-  LLVMContext* Context;          ///< The LLVMContext from which types and
+  const LLVMContext& Context;    ///< The LLVMContext from which types and
                                  ///< constants are allocated.
   GlobalListType GlobalList;     ///< The Global Variables in the module
   FunctionListType FunctionList; ///< The Functions in the module
@@ -131,7 +131,7 @@
 public:
   /// The Module constructor. Note that there is no default constructor. You
   /// must provide a name for the module upon construction.
-  explicit Module(const std::string &ModuleID, LLVMContext* C);
+  explicit Module(const std::string &ModuleID, const LLVMContext& C);
   /// The module destructor. This will dropAllReferences.
   ~Module();
 
@@ -162,7 +162,7 @@
 
   /// Get the global data context.
   /// @returns LLVMContext - a container for LLVM's global information
-  LLVMContext* getContext() const { return Context; }
+  const LLVMContext& getContext() const { return Context; }
 
   /// Get any module-scope inline assembly blocks.
   /// @returns a string containing the module-scope inline assembly blocks.

Modified: llvm/trunk/lib/Archive/Archive.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Archive/Archive.cpp?rev=74640&r1=74639&r2=74640&view=diff

==============================================================================
--- llvm/trunk/lib/Archive/Archive.cpp (original)
+++ llvm/trunk/lib/Archive/Archive.cpp Wed Jul  1 16:22:36 2009
@@ -138,7 +138,7 @@
 // Archive constructor - this is the only constructor that gets used for the
 // Archive class. Everything else (default,copy) is deprecated. This just
 // initializes and maps the file into memory, if requested.
-Archive::Archive(const sys::Path& filename, LLVMContext* C)
+Archive::Archive(const sys::Path& filename, const LLVMContext& C)
   : archPath(filename), members(), mapfile(0), base(0), symTab(), strtab(),
     symTabSize(0), firstFileOffset(0), modules(), foreignST(0), Context(C) {
 }
@@ -208,7 +208,7 @@
 
 // Get just the externally visible defined symbols from the bitcode
 bool llvm::GetBitcodeSymbols(const sys::Path& fName,
-                             LLVMContext* Context,
+                             const LLVMContext& Context,
                              std::vector<std::string>& symbols,
                              std::string* ErrMsg) {
   std::auto_ptr<MemoryBuffer> Buffer(
@@ -240,7 +240,7 @@
 ModuleProvider*
 llvm::GetBitcodeSymbols(const unsigned char *BufPtr, unsigned Length,
                         const std::string& ModuleID,
-                        LLVMContext* Context,
+                        const LLVMContext& Context,
                         std::vector<std::string>& symbols,
                         std::string* ErrMsg) {
   // Get the module provider

Modified: llvm/trunk/lib/Archive/ArchiveInternals.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Archive/ArchiveInternals.h?rev=74640&r1=74639&r2=74640&view=diff

==============================================================================
--- llvm/trunk/lib/Archive/ArchiveInternals.h (original)
+++ llvm/trunk/lib/Archive/ArchiveInternals.h Wed Jul  1 16:22:36 2009
@@ -73,13 +73,13 @@
   
   // Get just the externally visible defined symbols from the bitcode
   bool GetBitcodeSymbols(const sys::Path& fName,
-                          LLVMContext* Context,
+                          const LLVMContext& Context,
                           std::vector<std::string>& symbols,
                           std::string* ErrMsg);
   
   ModuleProvider* GetBitcodeSymbols(const unsigned char*Buffer,unsigned Length,
                                     const std::string& ModuleID,
-                                    LLVMContext* Context,
+                                    const LLVMContext& Context,
                                     std::vector<std::string>& symbols,
                                     std::string* ErrMsg);
 }

Modified: llvm/trunk/lib/Archive/ArchiveReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Archive/ArchiveReader.cpp?rev=74640&r1=74639&r2=74640&view=diff

==============================================================================
--- llvm/trunk/lib/Archive/ArchiveReader.cpp (original)
+++ llvm/trunk/lib/Archive/ArchiveReader.cpp Wed Jul  1 16:22:36 2009
@@ -327,7 +327,7 @@
 
 // Open and completely load the archive file.
 Archive*
-Archive::OpenAndLoad(const sys::Path& file, LLVMContext* C, 
+Archive::OpenAndLoad(const sys::Path& file, const LLVMContext& C, 
                      std::string* ErrorMessage) {
   std::auto_ptr<Archive> result ( new Archive(file, C));
   if (result->mapToMemory(ErrorMessage))
@@ -441,7 +441,8 @@
 }
 
 // Open the archive and load just the symbol tables
-Archive* Archive::OpenAndLoadSymbols(const sys::Path& file, LLVMContext* C,
+Archive* Archive::OpenAndLoadSymbols(const sys::Path& file,
+                                     const LLVMContext& C,
                                      std::string* ErrorMessage) {
   std::auto_ptr<Archive> result ( new Archive(file, C) );
   if (result->mapToMemory(ErrorMessage))

Modified: llvm/trunk/lib/Archive/ArchiveWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Archive/ArchiveWriter.cpp?rev=74640&r1=74639&r2=74640&view=diff

==============================================================================
--- llvm/trunk/lib/Archive/ArchiveWriter.cpp (original)
+++ llvm/trunk/lib/Archive/ArchiveWriter.cpp Wed Jul  1 16:22:36 2009
@@ -64,7 +64,7 @@
 }
 
 // Create an empty archive.
-Archive* Archive::CreateEmpty(const sys::Path& FilePath, LLVMContext* C) {
+Archive* Archive::CreateEmpty(const sys::Path& FilePath, const LLVMContext& C) {
   Archive* result = new Archive(FilePath, C);
   return result;
 }

Modified: llvm/trunk/lib/AsmParser/Parser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/Parser.cpp?rev=74640&r1=74639&r2=74640&view=diff

==============================================================================
--- llvm/trunk/lib/AsmParser/Parser.cpp (original)
+++ llvm/trunk/lib/AsmParser/Parser.cpp Wed Jul  1 16:22:36 2009
@@ -21,7 +21,7 @@
 using namespace llvm;
 
 Module *llvm::ParseAssemblyFile(const std::string &Filename, ParseError &Err,
-                                LLVMContext* Context) {
+                                const LLVMContext& Context) {
   Err.setFilename(Filename);
 
   std::string ErrorStr;
@@ -39,7 +39,7 @@
 }
 
 Module *llvm::ParseAssemblyString(const char *AsmString, Module *M,
-                                  ParseError &Err, LLVMContext* Context) {
+                                  ParseError &Err, const LLVMContext& Context) {
   Err.setFilename("<string>");
 
   OwningPtr<MemoryBuffer>

Modified: llvm/trunk/lib/Bitcode/Reader/BitReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitReader.cpp?rev=74640&r1=74639&r2=74640&view=diff

==============================================================================
--- llvm/trunk/lib/Bitcode/Reader/BitReader.cpp (original)
+++ llvm/trunk/lib/Bitcode/Reader/BitReader.cpp Wed Jul  1 16:22:36 2009
@@ -22,7 +22,7 @@
                      LLVMModuleRef *OutModule, char **OutMessage) {
   std::string Message;
   
-  *OutModule = wrap(ParseBitcodeFile(unwrap(MemBuf), unwrap(ContextRef),  
+  *OutModule = wrap(ParseBitcodeFile(unwrap(MemBuf), *unwrap(ContextRef),  
                                      &Message));
   if (!*OutModule) {
     if (OutMessage)
@@ -42,7 +42,7 @@
                                  char **OutMessage) {
   std::string Message;
   
-  *OutMP = wrap(getBitcodeModuleProvider(unwrap(MemBuf), unwrap(ContextRef), 
+  *OutMP = wrap(getBitcodeModuleProvider(unwrap(MemBuf), *unwrap(ContextRef), 
                                          &Message));
   if (!*OutMP) {
     if (OutMessage)

Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=74640&r1=74639&r2=74640&view=diff

==============================================================================
--- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original)
+++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Wed Jul  1 16:22:36 2009
@@ -2090,7 +2090,7 @@
 /// getBitcodeModuleProvider - lazy function-at-a-time loading from a file.
 ///
 ModuleProvider *llvm::getBitcodeModuleProvider(MemoryBuffer *Buffer,
-                                               LLVMContext* Context,
+                                               const LLVMContext& Context,
                                                std::string *ErrMsg) {
   BitcodeReader *R = new BitcodeReader(Buffer, Context);
   if (R->ParseBitcode()) {
@@ -2107,7 +2107,7 @@
 
 /// ParseBitcodeFile - Read the specified bitcode file, returning the module.
 /// If an error occurs, return null and fill in *ErrMsg if non-null.
-Module *llvm::ParseBitcodeFile(MemoryBuffer *Buffer, LLVMContext* Context, 
+Module *llvm::ParseBitcodeFile(MemoryBuffer *Buffer, const LLVMContext& Context, 
                                std::string *ErrMsg){
   BitcodeReader *R;
   R = static_cast<BitcodeReader*>(getBitcodeModuleProvider(Buffer, Context, 

Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.h?rev=74640&r1=74639&r2=74640&view=diff

==============================================================================
--- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.h (original)
+++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.h Wed Jul  1 16:22:36 2009
@@ -86,7 +86,7 @@
 };
 
 class BitcodeReader : public ModuleProvider {
-  LLVMContext* Context;
+  const LLVMContext& Context;
   MemoryBuffer *Buffer;
   BitstreamReader StreamFile;
   BitstreamCursor Stream;
@@ -125,7 +125,7 @@
   /// stream) and what linkage the original function had.
   DenseMap<Function*, std::pair<uint64_t, unsigned> > DeferredFunctionInfo;
 public:
-  explicit BitcodeReader(MemoryBuffer *buffer, LLVMContext* C)
+  explicit BitcodeReader(MemoryBuffer *buffer, const LLVMContext& C)
       : Context(C), Buffer(buffer), ErrorString(0) {
     HasReversedFunctionsWithBodies = false;
   }

Modified: llvm/trunk/lib/Debugger/Debugger.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Debugger/Debugger.cpp?rev=74640&r1=74639&r2=74640&view=diff

==============================================================================
--- llvm/trunk/lib/Debugger/Debugger.cpp (original)
+++ llvm/trunk/lib/Debugger/Debugger.cpp Wed Jul  1 16:22:36 2009
@@ -46,7 +46,8 @@
 }
 
 static Module *
-getMaterializedModuleProvider(const std::string &Filename, LLVMContext* C) {
+getMaterializedModuleProvider(const std::string &Filename,
+                              const LLVMContext& C) {
   std::auto_ptr<MemoryBuffer> Buffer;
   Buffer.reset(MemoryBuffer::getFileOrSTDIN(Filename.c_str()));
   if (Buffer.get())
@@ -58,7 +59,7 @@
 /// the PATH for the specified program, loading it when found.  If the
 /// specified program cannot be found, an exception is thrown to indicate the
 /// error.
-void Debugger::loadProgram(const std::string &Filename, LLVMContext* C) {
+void Debugger::loadProgram(const std::string &Filename, const LLVMContext& C) {
   if ((Program = getMaterializedModuleProvider(Filename, C)) ||
       (Program = getMaterializedModuleProvider(Filename+".bc", C)))
     return;   // Successfully loaded the program.

Modified: llvm/trunk/lib/Linker/Linker.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Linker/Linker.cpp?rev=74640&r1=74639&r2=74640&view=diff

==============================================================================
--- llvm/trunk/lib/Linker/Linker.cpp (original)
+++ llvm/trunk/lib/Linker/Linker.cpp Wed Jul  1 16:22:36 2009
@@ -20,7 +20,7 @@
 using namespace llvm;
 
 Linker::Linker(const std::string& progname, const std::string& modname,
-               LLVMContext* C, unsigned flags): 
+               const LLVMContext& C, unsigned flags): 
   Context(C),
   Composite(new Module(modname, C)),
   LibPaths(),

Modified: llvm/trunk/lib/VMCore/Core.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Core.cpp?rev=74640&r1=74639&r2=74640&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/Core.cpp (original)
+++ llvm/trunk/lib/VMCore/Core.cpp Wed Jul  1 16:22:36 2009
@@ -53,7 +53,7 @@
 /*===-- Operations on modules ---------------------------------------------===*/
 
 LLVMModuleRef LLVMModuleCreateWithName(const char *ModuleID, LLVMContextRef C) {
-  return wrap(new Module(ModuleID, unwrap(C)));
+  return wrap(new Module(ModuleID, *unwrap(C)));
 }
 
 void LLVMDisposeModule(LLVMModuleRef M) {

Modified: llvm/trunk/lib/VMCore/LLVMContext.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/LLVMContext.cpp?rev=74640&r1=74639&r2=74640&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/LLVMContext.cpp (original)
+++ llvm/trunk/lib/VMCore/LLVMContext.cpp Wed Jul  1 16:22:36 2009
@@ -22,8 +22,8 @@
 
 static ManagedStatic<LLVMContext> GlobalContext;
 
-LLVMContext* getGlobalContext() {
-  return &*GlobalContext;
+const LLVMContext& llvm::getGlobalContext() {
+  return *GlobalContext;
 }
 
 LLVMContext::LLVMContext() : pImpl(new LLVMContextImpl()) { }

Modified: llvm/trunk/lib/VMCore/Module.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Module.cpp?rev=74640&r1=74639&r2=74640&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/Module.cpp (original)
+++ llvm/trunk/lib/VMCore/Module.cpp Wed Jul  1 16:22:36 2009
@@ -55,7 +55,7 @@
 // Primitive Module methods.
 //
 
-Module::Module(const std::string &MID, LLVMContext* C)
+Module::Module(const std::string &MID, const LLVMContext& C)
   : Context(C), ModuleID(MID), DataLayout("")  {
   ValSymTab = new ValueSymbolTable();
   TypeSymTab = new TypeSymbolTable();

Modified: llvm/trunk/tools/bugpoint/BugDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/bugpoint/BugDriver.cpp?rev=74640&r1=74639&r2=74640&view=diff

==============================================================================
--- llvm/trunk/tools/bugpoint/BugDriver.cpp (original)
+++ llvm/trunk/tools/bugpoint/BugDriver.cpp Wed Jul  1 16:22:36 2009
@@ -64,7 +64,8 @@
 }
 
 BugDriver::BugDriver(const char *toolname, bool as_child, bool find_bugs,
-                     unsigned timeout, unsigned memlimit, LLVMContext* ctxt)
+                     unsigned timeout, unsigned memlimit,
+                     const LLVMContext& ctxt)
   : Context(ctxt), ToolName(toolname), ReferenceOutputFile(OutputFile),
     Program(0), Interpreter(0), SafeInterpreter(0), gcc(0),
     run_as_child(as_child), run_find_bugs(find_bugs), Timeout(timeout), 
@@ -74,7 +75,8 @@
 /// ParseInputFile - Given a bitcode or assembly input filename, parse and
 /// return it, or return null if not possible.
 ///
-Module *llvm::ParseInputFile(const std::string &Filename, LLVMContext* Ctxt) {
+Module *llvm::ParseInputFile(const std::string &Filename,
+                             const LLVMContext& Ctxt) {
   std::auto_ptr<MemoryBuffer> Buffer(MemoryBuffer::getFileOrSTDIN(Filename));
   Module *Result = 0;
   if (Buffer.get())

Modified: llvm/trunk/tools/bugpoint/BugDriver.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/bugpoint/BugDriver.h?rev=74640&r1=74639&r2=74640&view=diff

==============================================================================
--- llvm/trunk/tools/bugpoint/BugDriver.h (original)
+++ llvm/trunk/tools/bugpoint/BugDriver.h Wed Jul  1 16:22:36 2009
@@ -43,7 +43,7 @@
 extern bool BugpointIsInterrupted;
 
 class BugDriver {
-  LLVMContext* Context;
+  const LLVMContext& Context;
   const std::string ToolName;  // Name of bugpoint
   std::string ReferenceOutputFile; // Name of `good' output file
   Module *Program;             // The raw program, linked together
@@ -62,11 +62,11 @@
 
 public:
   BugDriver(const char *toolname, bool as_child, bool find_bugs,
-            unsigned timeout, unsigned memlimit, LLVMContext* ctxt);
+            unsigned timeout, unsigned memlimit, const LLVMContext& ctxt);
 
   const std::string &getToolName() const { return ToolName; }
 
-  LLVMContext* getContext() { return Context; }
+  const LLVMContext& getContext() { return Context; }
 
   // Set up methods... these methods are used to copy information about the
   // command line arguments into instance variables of BugDriver.
@@ -294,7 +294,8 @@
 /// ParseInputFile - Given a bitcode or assembly input filename, parse and
 /// return it, or return null if not possible.
 ///
-Module *ParseInputFile(const std::string &InputFilename, LLVMContext* ctxt);
+Module *ParseInputFile(const std::string &InputFilename,
+                       const LLVMContext& ctxt);
 
 
 /// getPassesString - Turn a list of passes into a string which indicates the

Modified: llvm/trunk/tools/bugpoint/bugpoint.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/bugpoint/bugpoint.cpp?rev=74640&r1=74639&r2=74640&view=diff

==============================================================================
--- llvm/trunk/tools/bugpoint/bugpoint.cpp (original)
+++ llvm/trunk/tools/bugpoint/bugpoint.cpp Wed Jul  1 16:22:36 2009
@@ -76,7 +76,7 @@
   sys::SetInterruptFunction(BugpointInterruptFunction);
 
   LLVMContext Context;
-  BugDriver D(argv[0], AsChild, FindBugs, TimeoutValue, MemoryLimit, &Context);
+  BugDriver D(argv[0], AsChild, FindBugs, TimeoutValue, MemoryLimit, Context);
   if (D.addSources(InputFilenames)) return 1;
   D.addPasses(PassList.begin(), PassList.end());
 

Modified: llvm/trunk/tools/llc/llc.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llc/llc.cpp?rev=74640&r1=74639&r2=74640&view=diff

==============================================================================
--- llvm/trunk/tools/llc/llc.cpp (original)
+++ llvm/trunk/tools/llc/llc.cpp Wed Jul  1 16:22:36 2009
@@ -227,7 +227,7 @@
   std::auto_ptr<MemoryBuffer> Buffer(
                    MemoryBuffer::getFileOrSTDIN(InputFilename, &ErrorMessage));
   if (Buffer.get())
-    M.reset(ParseBitcodeFile(Buffer.get(), &Context, &ErrorMessage));
+    M.reset(ParseBitcodeFile(Buffer.get(), Context, &ErrorMessage));
   if (M.get() == 0) {
     std::cerr << argv[0] << ": bitcode didn't read correctly.\n";
     std::cerr << "Reason: " << ErrorMessage << "\n";

Modified: llvm/trunk/tools/lli/lli.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lli/lli.cpp?rev=74640&r1=74639&r2=74640&view=diff

==============================================================================
--- llvm/trunk/tools/lli/lli.cpp (original)
+++ llvm/trunk/tools/lli/lli.cpp Wed Jul  1 16:22:36 2009
@@ -107,7 +107,7 @@
   std::string ErrorMsg;
   ModuleProvider *MP = NULL;
   if (MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(InputFile,&ErrorMsg)){
-    MP = getBitcodeModuleProvider(Buffer, &Context, &ErrorMsg);
+    MP = getBitcodeModuleProvider(Buffer, Context, &ErrorMsg);
     if (!MP) delete Buffer;
   }
   

Modified: llvm/trunk/tools/llvm-ar/llvm-ar.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-ar/llvm-ar.cpp?rev=74640&r1=74639&r2=74640&view=diff

==============================================================================
--- llvm/trunk/tools/llvm-ar/llvm-ar.cpp (original)
+++ llvm/trunk/tools/llvm-ar/llvm-ar.cpp Wed Jul  1 16:22:36 2009
@@ -719,11 +719,11 @@
       // Produce a warning if we should and we're creating the archive
       if (!Create)
         std::cerr << argv[0] << ": creating " << ArchivePath.toString() << "\n";
-      TheArchive = Archive::CreateEmpty(ArchivePath, &Context);
+      TheArchive = Archive::CreateEmpty(ArchivePath, Context);
       TheArchive->writeToDisk();
     } else {
       std::string Error;
-      TheArchive = Archive::OpenAndLoad(ArchivePath, &Context, &Error);
+      TheArchive = Archive::OpenAndLoad(ArchivePath, Context, &Error);
       if (TheArchive == 0) {
         std::cerr << argv[0] << ": error loading '" << ArchivePath << "': "
                   << Error << "!\n";

Modified: llvm/trunk/tools/llvm-as/llvm-as.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-as/llvm-as.cpp?rev=74640&r1=74639&r2=74640&view=diff

==============================================================================
--- llvm/trunk/tools/llvm-as/llvm-as.cpp (original)
+++ llvm/trunk/tools/llvm-as/llvm-as.cpp Wed Jul  1 16:22:36 2009
@@ -65,7 +65,7 @@
   try {
     // Parse the file now...
     ParseError Err;
-    std::auto_ptr<Module> M(ParseAssemblyFile(InputFilename, Err, &Context));
+    std::auto_ptr<Module> M(ParseAssemblyFile(InputFilename, Err, Context));
     if (M.get() == 0) {
       Err.PrintError(argv[0], errs());
       return 1;

Modified: llvm/trunk/tools/llvm-db/CLIDebugger.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-db/CLIDebugger.cpp?rev=74640&r1=74639&r2=74640&view=diff

==============================================================================
--- llvm/trunk/tools/llvm-db/CLIDebugger.cpp (original)
+++ llvm/trunk/tools/llvm-db/CLIDebugger.cpp Wed Jul  1 16:22:36 2009
@@ -22,7 +22,7 @@
 /// CLIDebugger constructor - This initializes the debugger to its default
 /// state, and initializes the command table.
 ///
-CLIDebugger::CLIDebugger(LLVMContext* ctxt)
+CLIDebugger::CLIDebugger(const LLVMContext& ctxt)
   : Context(ctxt), TheProgramInfo(0), TheRuntimeInfo(0),
     Prompt("(llvm-db) "), ListSize(10) {
   // Initialize instance variables

Modified: llvm/trunk/tools/llvm-db/CLIDebugger.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-db/CLIDebugger.h?rev=74640&r1=74639&r2=74640&view=diff

==============================================================================
--- llvm/trunk/tools/llvm-db/CLIDebugger.h (original)
+++ llvm/trunk/tools/llvm-db/CLIDebugger.h Wed Jul  1 16:22:36 2009
@@ -29,7 +29,7 @@
   /// CLIDebugger - This class implements the command line interface for the
   /// LLVM debugger.
   class CLIDebugger {
-    LLVMContext* Context;
+    const LLVMContext& Context;
     
     /// Dbg - The low-level LLVM debugger object that we use to do our dirty
     /// work.
@@ -82,7 +82,7 @@
     const SourceLanguage *CurrentLanguage;
 
   public:
-    CLIDebugger(LLVMContext* ctxt);
+    CLIDebugger(const LLVMContext& ctxt);
 
     /// getDebugger - Return the current LLVM debugger implementation being
     /// used.

Modified: llvm/trunk/tools/llvm-db/llvm-db.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-db/llvm-db.cpp?rev=74640&r1=74639&r2=74640&view=diff

==============================================================================
--- llvm/trunk/tools/llvm-db/llvm-db.cpp (original)
+++ llvm/trunk/tools/llvm-db/llvm-db.cpp Wed Jul  1 16:22:36 2009
@@ -70,7 +70,7 @@
       InputArgs.push_back(InputFile);
 
     // Create the CLI debugger...
-    CLIDebugger D(&Context);
+    CLIDebugger D(Context);
 
     // Initialize the debugger with the command line options we read...
     Debugger &Dbg = D.getDebugger();

Modified: llvm/trunk/tools/llvm-dis/llvm-dis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-dis/llvm-dis.cpp?rev=74640&r1=74639&r2=74640&view=diff

==============================================================================
--- llvm/trunk/tools/llvm-dis/llvm-dis.cpp (original)
+++ llvm/trunk/tools/llvm-dis/llvm-dis.cpp Wed Jul  1 16:22:36 2009
@@ -63,7 +63,7 @@
    
     if (MemoryBuffer *Buffer
            = MemoryBuffer::getFileOrSTDIN(InputFilename, &ErrorMessage)) {
-      M.reset(ParseBitcodeFile(Buffer, &Context, &ErrorMessage));
+      M.reset(ParseBitcodeFile(Buffer, Context, &ErrorMessage));
       delete Buffer;
     }
 

Modified: llvm/trunk/tools/llvm-extract/llvm-extract.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-extract/llvm-extract.cpp?rev=74640&r1=74639&r2=74640&view=diff

==============================================================================
--- llvm/trunk/tools/llvm-extract/llvm-extract.cpp (original)
+++ llvm/trunk/tools/llvm-extract/llvm-extract.cpp Wed Jul  1 16:22:36 2009
@@ -73,7 +73,7 @@
     cerr << argv[0] << ": Error reading file '" + InputFilename + "'\n";
     return 1;
   } else {
-    M.reset(ParseBitcodeFile(Buffer, &Context));
+    M.reset(ParseBitcodeFile(Buffer, Context));
   }
   delete Buffer;
   

Modified: llvm/trunk/tools/llvm-ld/llvm-ld.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-ld/llvm-ld.cpp?rev=74640&r1=74639&r2=74640&view=diff

==============================================================================
--- llvm/trunk/tools/llvm-ld/llvm-ld.cpp (original)
+++ llvm/trunk/tools/llvm-ld/llvm-ld.cpp Wed Jul  1 16:22:36 2009
@@ -517,7 +517,7 @@
     cl::ParseCommandLineOptions(argc, argv, "llvm linker\n");
 
     // Construct a Linker (now that Verbose is set)
-    Linker TheLinker(progname, OutputFilename, &Context, Verbose);
+    Linker TheLinker(progname, OutputFilename, Context, Verbose);
 
     // Keep track of the native link items (versus the bitcode items)
     Linker::ItemList NativeLinkItems;

Modified: llvm/trunk/tools/llvm-link/llvm-link.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-link/llvm-link.cpp?rev=74640&r1=74639&r2=74640&view=diff

==============================================================================
--- llvm/trunk/tools/llvm-link/llvm-link.cpp (original)
+++ llvm/trunk/tools/llvm-link/llvm-link.cpp Wed Jul  1 16:22:36 2009
@@ -49,7 +49,7 @@
 // searches the link path for the specified file to try to find it...
 //
 static inline std::auto_ptr<Module> LoadFile(const std::string &FN, 
-                                             LLVMContext* Context) {
+                                             const LLVMContext& Context) {
   sys::Path Filename;
   if (!Filename.set(FN)) {
     cerr << "Invalid file name: '" << FN << "'\n";
@@ -93,7 +93,7 @@
   unsigned BaseArg = 0;
   std::string ErrorMessage;
 
-  std::auto_ptr<Module> Composite(LoadFile(InputFilenames[BaseArg], &Context));
+  std::auto_ptr<Module> Composite(LoadFile(InputFilenames[BaseArg], Context));
   if (Composite.get() == 0) {
     cerr << argv[0] << ": error loading file '"
          << InputFilenames[BaseArg] << "'\n";
@@ -101,7 +101,7 @@
   }
 
   for (unsigned i = BaseArg+1; i < InputFilenames.size(); ++i) {
-    std::auto_ptr<Module> M(LoadFile(InputFilenames[i], &Context));
+    std::auto_ptr<Module> M(LoadFile(InputFilenames[i], Context));
     if (M.get() == 0) {
       cerr << argv[0] << ": error loading file '" <<InputFilenames[i]<< "'\n";
       return 1;

Modified: llvm/trunk/tools/llvm-nm/llvm-nm.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-nm/llvm-nm.cpp?rev=74640&r1=74639&r2=74640&view=diff

==============================================================================
--- llvm/trunk/tools/llvm-nm/llvm-nm.cpp (original)
+++ llvm/trunk/tools/llvm-nm/llvm-nm.cpp Wed Jul  1 16:22:36 2009
@@ -142,7 +142,7 @@
                    MemoryBuffer::getFileOrSTDIN(Filename, &ErrorMessage));
     Module *Result = 0;
     if (Buffer.get())
-      Result = ParseBitcodeFile(Buffer.get(), &Context, &ErrorMessage);
+      Result = ParseBitcodeFile(Buffer.get(), Context, &ErrorMessage);
     
     if (Result)
       DumpSymbolNamesFromModule(Result);
@@ -153,7 +153,7 @@
     
   } else if (aPath.isArchive()) {
     std::string ErrMsg;
-    Archive* archive = Archive::OpenAndLoad(sys::Path(Filename), &Context,
+    Archive* archive = Archive::OpenAndLoad(sys::Path(Filename), Context,
                                             &ErrorMessage);
     if (!archive)
       std::cerr << ToolName << ": " << Filename << ": " << ErrorMessage << "\n";

Modified: llvm/trunk/tools/llvm-prof/llvm-prof.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-prof/llvm-prof.cpp?rev=74640&r1=74639&r2=74640&view=diff

==============================================================================
--- llvm/trunk/tools/llvm-prof/llvm-prof.cpp (original)
+++ llvm/trunk/tools/llvm-prof/llvm-prof.cpp Wed Jul  1 16:22:36 2009
@@ -127,7 +127,7 @@
     Module *M = 0;
     if (MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(BitcodeFile,
                                                             &ErrorMessage)) {
-      M = ParseBitcodeFile(Buffer, &Context, &ErrorMessage);
+      M = ParseBitcodeFile(Buffer, Context, &ErrorMessage);
       delete Buffer;
     }
     if (M == 0) {

Modified: llvm/trunk/tools/llvm-ranlib/llvm-ranlib.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-ranlib/llvm-ranlib.cpp?rev=74640&r1=74639&r2=74640&view=diff

==============================================================================
--- llvm/trunk/tools/llvm-ranlib/llvm-ranlib.cpp (original)
+++ llvm/trunk/tools/llvm-ranlib/llvm-ranlib.cpp Wed Jul  1 16:22:36 2009
@@ -75,7 +75,7 @@
 
     std::string err_msg;
     std::auto_ptr<Archive>
-      AutoArchive(Archive::OpenAndLoad(ArchivePath, &Context, &err_msg));
+      AutoArchive(Archive::OpenAndLoad(ArchivePath, Context, &err_msg));
     Archive* TheArchive = AutoArchive.get();
     if (!TheArchive)
       throw err_msg;

Modified: llvm/trunk/tools/lto/LTOCodeGenerator.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOCodeGenerator.cpp?rev=74640&r1=74639&r2=74640&view=diff

==============================================================================
--- llvm/trunk/tools/lto/LTOCodeGenerator.cpp (original)
+++ llvm/trunk/tools/lto/LTOCodeGenerator.cpp Wed Jul  1 16:22:36 2009
@@ -69,8 +69,8 @@
 }
 
 
-LTOCodeGenerator::LTOCodeGenerator() 
-    : _context(new LLVMContext()),
+LTOCodeGenerator::LTOCodeGenerator(const LLVMContext& Context) 
+    : _context(Context),
       _linker("LinkTimeOptimizer", "ld-temp.o", _context), _target(NULL),
       _emitDwarfDebugInfo(false), _scopeRestrictionsDone(false),
       _codeModel(LTO_CODEGEN_PIC_MODEL_DYNAMIC),

Modified: llvm/trunk/tools/lto/LTOCodeGenerator.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOCodeGenerator.h?rev=74640&r1=74639&r2=74640&view=diff

==============================================================================
--- llvm/trunk/tools/lto/LTOCodeGenerator.h (original)
+++ llvm/trunk/tools/lto/LTOCodeGenerator.h Wed Jul  1 16:22:36 2009
@@ -31,7 +31,7 @@
 public:
     static const char*        getVersionString();
     
-                            LTOCodeGenerator();
+                            LTOCodeGenerator(const llvm::LLVMContext& Context);
                             ~LTOCodeGenerator();
                             
     bool                addModule(class LTOModule*, std::string& errMsg);
@@ -54,7 +54,7 @@
     
     typedef llvm::StringMap<uint8_t> StringSet;
 
-    llvm::LLVMContext*          _context;
+    const llvm::LLVMContext&          _context;
     llvm::Linker                _linker;
     llvm::TargetMachine*        _target;
     bool                        _emitDwarfDebugInfo;

Modified: llvm/trunk/tools/lto/LTOModule.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOModule.cpp?rev=74640&r1=74639&r2=74640&view=diff

==============================================================================
--- llvm/trunk/tools/lto/LTOModule.cpp (original)
+++ llvm/trunk/tools/lto/LTOModule.cpp Wed Jul  1 16:22:36 2009
@@ -69,7 +69,7 @@
 bool LTOModule::isTargetMatch(MemoryBuffer* buffer, const char* triplePrefix)
 {
     OwningPtr<ModuleProvider> mp(getBitcodeModuleProvider(buffer,
-                                                          new LLVMContext()));
+                                                          *new LLVMContext()));
     // on success, mp owns buffer and both are deleted at end of this method
     if ( !mp ) {
         delete buffer;
@@ -86,7 +86,8 @@
 {
 }
 
-LTOModule* LTOModule::makeLTOModule(const char* path, LLVMContext* Context,
+LTOModule* LTOModule::makeLTOModule(const char* path,
+                                    const LLVMContext& Context,
                                     std::string& errMsg)
 {
     OwningPtr<MemoryBuffer> buffer(MemoryBuffer::getFile(path, &errMsg));
@@ -112,7 +113,7 @@
 
 
 LTOModule* LTOModule::makeLTOModule(const void* mem, size_t length, 
-                                    LLVMContext* Context,
+                                    const LLVMContext& Context,
                                     std::string& errMsg)
 {
     OwningPtr<MemoryBuffer> buffer(makeBuffer(mem, length));
@@ -140,7 +141,8 @@
   return Features.getString();
 }
 
-LTOModule* LTOModule::makeLTOModule(MemoryBuffer* buffer, LLVMContext* Context,
+LTOModule* LTOModule::makeLTOModule(MemoryBuffer* buffer,
+                                    const LLVMContext& Context,
                                     std::string& errMsg)
 {
     // parse bitcode buffer

Modified: llvm/trunk/tools/lto/LTOModule.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOModule.h?rev=74640&r1=74639&r2=74640&view=diff

==============================================================================
--- llvm/trunk/tools/lto/LTOModule.h (original)
+++ llvm/trunk/tools/lto/LTOModule.h Wed Jul  1 16:22:36 2009
@@ -52,10 +52,10 @@
                                                     const char* triplePrefix);
 
     static LTOModule*        makeLTOModule(const char* path,
-                                          llvm::LLVMContext* Context,
+                                          const llvm::LLVMContext& Context,
                                           std::string& errMsg);
     static LTOModule*        makeLTOModule(const void* mem, size_t length,
-                                           llvm::LLVMContext* Context,
+                                           const llvm::LLVMContext& Context,
                                            std::string& errMsg);
 
     const char*              getTargetTriple();
@@ -91,7 +91,7 @@
                                                     const char* triplePrefix);
 
     static LTOModule*       makeLTOModule(llvm::MemoryBuffer* buffer,
-                                          llvm::LLVMContext* Context,
+                                          const llvm::LLVMContext& Context,
                                                         std::string& errMsg);
     static llvm::MemoryBuffer* makeBuffer(const void* mem, size_t length);
 

Modified: llvm/trunk/tools/lto/lto.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/lto.cpp?rev=74640&r1=74639&r2=74640&view=diff

==============================================================================
--- llvm/trunk/tools/lto/lto.cpp (original)
+++ llvm/trunk/tools/lto/lto.cpp Wed Jul  1 16:22:36 2009
@@ -88,7 +88,7 @@
 //
 lto_module_t lto_module_create(const char* path, LLVMContextRef Ctxt)
 {
-     return LTOModule::makeLTOModule(path, llvm::unwrap(Ctxt), 
+     return LTOModule::makeLTOModule(path, *llvm::unwrap(Ctxt), 
                                      sLastErrorString);
 }
 
@@ -100,7 +100,7 @@
 lto_module_t lto_module_create_from_memory(const void* mem, size_t length,
                                            LLVMContextRef Ctxt)
 {
-     return LTOModule::makeLTOModule(mem, length, llvm::unwrap(Ctxt),
+     return LTOModule::makeLTOModule(mem, length, *llvm::unwrap(Ctxt),
                                      sLastErrorString);
 }
 
@@ -158,9 +158,9 @@
 // instantiates a code generator
 // returns NULL if there is an error
 //
-lto_code_gen_t lto_codegen_create()
+lto_code_gen_t lto_codegen_create(LLVMContextRef ContextRef)
 {
-     return new LTOCodeGenerator();
+     return new LTOCodeGenerator(*llvm::unwrap(ContextRef));
 }
 
 
@@ -265,4 +265,4 @@
 lto_codegen_debug_options(lto_code_gen_t cg, const char * opt)
 {
   cg->setCodeGenDebugOptions(opt);
-}
+}
\ No newline at end of file

Modified: llvm/trunk/tools/opt/opt.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/opt/opt.cpp?rev=74640&r1=74639&r2=74640&view=diff

==============================================================================
--- llvm/trunk/tools/opt/opt.cpp (original)
+++ llvm/trunk/tools/opt/opt.cpp Wed Jul  1 16:22:36 2009
@@ -327,7 +327,7 @@
     std::auto_ptr<Module> M;
     if (MemoryBuffer *Buffer
           = MemoryBuffer::getFileOrSTDIN(InputFilename, &ErrorMessage)) {
-      M.reset(ParseBitcodeFile(Buffer, &Context, &ErrorMessage));
+      M.reset(ParseBitcodeFile(Buffer, Context, &ErrorMessage));
       delete Buffer;
     }
     

Modified: llvm/trunk/unittests/ExecutionEngine/JIT/JITEventListenerTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ExecutionEngine/JIT/JITEventListenerTest.cpp?rev=74640&r1=74639&r2=74640&view=diff

==============================================================================
--- llvm/trunk/unittests/ExecutionEngine/JIT/JITEventListenerTest.cpp (original)
+++ llvm/trunk/unittests/ExecutionEngine/JIT/JITEventListenerTest.cpp Wed Jul  1 16:22:36 2009
@@ -65,7 +65,7 @@
 class JITEventListenerTest : public testing::Test {
  protected:
   JITEventListenerTest()
-      : M(new Module("module", new LLVMContext())),
+      : M(new Module("module", *new LLVMContext())),
         EE(ExecutionEngine::createJIT(new ExistingModuleProvider(M))) {
   }
 

Modified: llvm/trunk/unittests/VMCore/PassManagerTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/VMCore/PassManagerTest.cpp?rev=74640&r1=74639&r2=74640&view=diff

==============================================================================
--- llvm/trunk/unittests/VMCore/PassManagerTest.cpp (original)
+++ llvm/trunk/unittests/VMCore/PassManagerTest.cpp Wed Jul  1 16:22:36 2009
@@ -272,7 +272,7 @@
     char OnTheFlyTest::ID=0;
 
     TEST(PassManager, RunOnce) {
-      Module M("test-once", new LLVMContext());
+      Module M("test-once", *new LLVMContext());
       struct ModuleNDNM *mNDNM = new ModuleNDNM();
       struct ModuleDNM *mDNM = new ModuleDNM();
       struct ModuleNDM *mNDM = new ModuleNDM();
@@ -296,7 +296,7 @@
     }
 
     TEST(PassManager, ReRun) {
-      Module M("test-rerun", new LLVMContext());
+      Module M("test-rerun", *new LLVMContext());
       struct ModuleNDNM *mNDNM = new ModuleNDNM();
       struct ModuleDNM *mDNM = new ModuleDNM();
       struct ModuleNDM *mNDM = new ModuleNDM();
@@ -387,7 +387,7 @@
 
     Module* makeLLVMModule() {
       // Module Construction
-      Module* mod = new Module("test-mem", new LLVMContext());
+      Module* mod = new Module("test-mem", *new LLVMContext());
       mod->setDataLayout("e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-"
                          "i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-"
                          "a0:0:64-s0:64:64-f80:128:128");





More information about the llvm-commits mailing list