Hold the LLVMContext by reference rather than by pointer.
authorOwen Anderson <resistor@mac.com>
Wed, 1 Jul 2009 21:22:36 +0000 (21:22 +0000)
committerOwen Anderson <resistor@mac.com>
Wed, 1 Jul 2009 21:22:36 +0000 (21:22 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74640 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 0caff13e81ec25e077db10cb7605ea94e2184eb6..fa6d6675e77d4626853db877f0bb8c87d98aaf58 100644 (file)
@@ -37,7 +37,7 @@ const char *BrainF::label   = "brainf";
 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 @@ Module *BrainF::parse(std::istream *in1, int mem, CompileFlags cf,
   return module;
 }
 
-void BrainF::header(LLVMContext* C) {
+void BrainF::header(const LLVMContext& C) {
   module = new Module("BrainF", C);
 
   //Function prototypes
index d0fb1b1de0ef38f1e339bcdc4fc9db9feb5f9835..d21d3bb8913923f763cb4ef897b5b8dbe513ee1f 100644 (file)
@@ -39,7 +39,8 @@ class BrainF {
     /// 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 @@ class BrainF {
     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 "[]".
index 0868d735066364c665b6eb9d0eec21eda6478b62..4eaa4940e70abf91aaab211b59a6541261fc0c09 100644 (file)
@@ -126,7 +126,7 @@ int main(int argc, char **argv) {
 
   //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);
 
index 58c0dcdaf5cae229f23c0901456fe5a27827751a..c3431fc3527e0340c283c2da807779f9f3b2472d 100644 (file)
@@ -94,7 +94,7 @@ int main(int argc, char **argv) {
   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);
index f11c3e256e6f23ee8faf05db3271e9ddfc9c0168..6734547916245d23ec4e1786d54610b1ee5c93d5 100644 (file)
@@ -55,7 +55,7 @@ int main() {
   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".
index 9ca6035156cda8b63142feb9d719fdd3a083d2fc..612cfa547ca1415d4d3f503c9e1ff0af8a494a8c 100644 (file)
@@ -1099,7 +1099,7 @@ int main() {
   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);
index 322835e04f20a7a0ec24b9cd2614231d5a7c6dcf..59a86d031d2f3823a73d439e68d0cc79923abdc4 100644 (file)
@@ -27,7 +27,7 @@ int main() {
 
   // 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);
index 858cd52de6aea6ea915c298d7fa214b02b1a3695..eadd0f58e5d50d6f3029f846077cf7e658ab25eb 100644 (file)
@@ -236,7 +236,7 @@ int main() {
   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 );
index 5d92fc5af013594f2d51dcb648eac4bd583ae462..d9a2e5ce68625e8898841174bf293945f9fbff19 100644 (file)
@@ -58,6 +58,7 @@ typedef struct LTOModule*         lto_module_t;
 /** 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 @@ lto_get_version(void);
 extern const char*
 lto_get_error_message(void);
 
-
 /**
  * Checks if a file is a loadable object file.
  */
index 2a5bac7a704cca322b7c180e8bbe4291d4af9e06..616750ae3ef3e8bb966a75c4a43a516bc2dc6bf6 100644 (file)
@@ -32,7 +32,7 @@ class LLVMContext;
 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 @@ Module *ParseAssemblyString(
   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
 );
 
 //===------------------------------------------------------------------------===
index c188df882419e4ecad84dfc44630f98d0db1560e..85b918ed32e40875b9b314732c5b54cfb8dd9444 100644 (file)
@@ -280,7 +280,7 @@ class Archive {
     /// @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 @@ class Archive {
     /// @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 @@ class Archive {
     /// @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 @@ class Archive {
   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 @@ class Archive {
     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
   /// @{
index a7811876ff687679c1a317756202c5da742a1b65..3cde47bf77e8822018249b51e103a19ece3e67dc 100644 (file)
@@ -32,13 +32,13 @@ namespace llvm {
   /// 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
index ed04ed533adba87517976869bfb0944276c6fcd2..d003539e7e2e1ba48c3c849677735c5cfb23df40 100644 (file)
@@ -96,7 +96,7 @@ namespace llvm {
     /// 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
index 1d95502bcd6a5a3de85219e04fad91c8471a0604..f0c2200c7a3ddcc8141546d70032fe24eb1b4048 100644 (file)
@@ -198,7 +198,7 @@ public:
 };
 
 /// FOR BACKWARDS COMPATIBILITY - Returns a global context.
-LLVMContext* getGlobalContext();
+extern const LLVMContext& getGlobalContext();
 
 }
 
index 3c4b9c447b9d23f578c95a627be1d731f21e82b8..e5a51971f164bf808d8f1e55c6d1f8a259d16e6c 100644 (file)
@@ -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 @@ namespace {
       // 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,"");
index 8389dc770efcbab2cb97a09857dc0a6b94159726..2ab0ed4705915731c098c20be9f66d17ff74b88c 100644 (file)
@@ -67,7 +67,7 @@ class Linker {
     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 @@ class Linker {
   /// @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.
index 8370ffb872cdb6ff05ee064b37e1a13a47e96009..8efa8e0e0eb1fa39bd3b592d65d34871f59f4d02 100644 (file)
@@ -110,7 +110,7 @@ public:
 /// @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 @@ private:
 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 @@ public:
 
   /// 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.
index e6903b607fb858bc34b5a813db117c81581566b3..1a8b25ace254d40451b549aef70f4d199651a232 100644 (file)
@@ -138,7 +138,7 @@ bool ArchiveMember::replaceWith(const sys::Path& newFile, std::string* ErrMsg) {
 // 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 @@ static void getSymbols(Module*M, std::vector<std::string>& symbols) {
 
 // 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 @@ bool llvm::GetBitcodeSymbols(const sys::Path& fName,
 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
index cdd8e35ca0dc05b6efb16c6eacde940273713bb8..15f01b3690e9f430ffda3a086dde7c481587ffd2 100644 (file)
@@ -73,13 +73,13 @@ namespace llvm {
   
   // 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);
 }
index 4e3e28166ca549fa10c0545803af11979b4b1fa1..2393554ede8f1ef33441e18152935d30ff1c8f2e 100644 (file)
@@ -327,7 +327,7 @@ Archive::loadArchive(std::string* error) {
 
 // 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 @@ Archive::loadSymbolTable(std::string* ErrorMsg) {
 }
 
 // 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))
index 641e3324d63dd25525089e08de8e404d6a6ba9b7..e84035404bf3564efecc4e4350002d8719b92b5c 100644 (file)
@@ -64,7 +64,7 @@ static inline unsigned numVbrBytes(unsigned num) {
 }
 
 // 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;
 }
index 7759c70d73da9ab0c6cf265539cc267a77914bcf..daf23fe748b73115970d2228678b212538844483 100644 (file)
@@ -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::ParseAssemblyFile(const std::string &Filename, ParseError &Err,
 }
 
 Module *llvm::ParseAssemblyString(const char *AsmString, Module *M,
-                                  ParseError &Err, LLVMContext* Context) {
+                                  ParseError &Err, const LLVMContext& Context) {
   Err.setFilename("<string>");
 
   OwningPtr<MemoryBuffer>
index 2baf71bb541bab488872f8ab736ec92d3ef3b266..273975a59be621f8a331ddbf0f257cf1163c0fa1 100644 (file)
@@ -22,7 +22,7 @@ int LLVMParseBitcode(LLVMMemoryBufferRef MemBuf, LLVMContextRef ContextRef,
                      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 @@ int LLVMGetBitcodeModuleProvider(LLVMMemoryBufferRef MemBuf,
                                  char **OutMessage) {
   std::string Message;
   
-  *OutMP = wrap(getBitcodeModuleProvider(unwrap(MemBuf), unwrap(ContextRef), 
+  *OutMP = wrap(getBitcodeModuleProvider(unwrap(MemBuf), *unwrap(ContextRef), 
                                          &Message));
   if (!*OutMP) {
     if (OutMessage)
index 7cf03242990195b188daff8be41c1ba12e551fbc..ce33de04f7ebfc026b18cbd665c973a73453797f 100644 (file)
@@ -2090,7 +2090,7 @@ Module *BitcodeReader::releaseModule(std::string *ErrInfo) {
 /// 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 @@ ModuleProvider *llvm::getBitcodeModuleProvider(MemoryBuffer *Buffer,
 
 /// 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, 
index 498a34ae01bf19c92a1ebda920ede321e0998894..dd12375cc432c578ffcd7588ef08673ff9a8060f 100644 (file)
@@ -86,7 +86,7 @@ public:
 };
 
 class BitcodeReader : public ModuleProvider {
-  LLVMContext* Context;
+  const LLVMContext& Context;
   MemoryBuffer *Buffer;
   BitstreamReader StreamFile;
   BitstreamCursor Stream;
@@ -125,7 +125,7 @@ class BitcodeReader : public ModuleProvider {
   /// 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;
   }
index dbfbbed1dc5491ad3d623eec830b33044ccdb52d..61d8358d08d57a8d6a312fa35c2e25db2c69d040 100644 (file)
@@ -46,7 +46,8 @@ std::string Debugger::getProgramPath() const {
 }
 
 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 @@ getMaterializedModuleProvider(const std::string &Filename, LLVMContext* C) {
 /// 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.
index d0d69d072c1700bf5a4d81580593297342d9a3ee..42d4e724db49da5c05ae556b04dafb30b2944c0b 100644 (file)
@@ -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(),
index 1c0a8f7af2593da522c70ac816f8643136ce0bf7..9f92e6f29496cac2b9531541c557eef18b05fcc9 100644 (file)
@@ -53,7 +53,7 @@ void LLVMContextDispose(LLVMContextRef C) {
 /*===-- 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) {
index 09c7fcc8cf1fe7d68c961becae698a8ed06604c7..d29b758ea74c4b766a6e465686856cc06252e82a 100644 (file)
@@ -22,8 +22,8 @@ using namespace llvm;
 
 static ManagedStatic<LLVMContext> GlobalContext;
 
-LLVMContext* getGlobalContext() {
-  return &*GlobalContext;
+const LLVMContext& llvm::getGlobalContext() {
+  return *GlobalContext;
 }
 
 LLVMContext::LLVMContext() : pImpl(new LLVMContextImpl()) { }
index 96a25a5d0d25349b43db5965fd0af720a6690dc7..5ccd7ccfa35bdc92bbbe7cdc25d3b49983660d12 100644 (file)
@@ -55,7 +55,7 @@ template class SymbolTableListTraits<GlobalAlias, Module>;
 // 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();
index 340522a4437b034aaf444462fcdd8515c35d9c3b..93b09fb381c5fdd2b9ecf9b231bbbbde23661f1f 100644 (file)
@@ -64,7 +64,8 @@ std::string llvm::getPassesString(const std::vector<const PassInfo*> &Passes) {
 }
 
 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 @@ BugDriver::BugDriver(const char *toolname, bool as_child, bool find_bugs,
 /// 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())
index 4c81cc2a2b6db2b95f37f54a322d650aca3fc382..34267d55a628133006f52df69a214f553785e631 100644 (file)
@@ -43,7 +43,7 @@ extern bool DisableSimplifyCFG;
 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 @@ class BugDriver {
 
 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 @@ private:
 /// 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
index 57007e035c47d481616cc44dd75065a976ebcbc7..3365b227b1f7ce0f77709f48aabbba431329f857 100644 (file)
@@ -76,7 +76,7 @@ int main(int argc, char **argv) {
   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());
 
index d0d88c505f74bf7896eed753c969b94fe8e3b73f..ae03c1e0c031c3e4a291f3100cc5e7dbf667e38f 100644 (file)
@@ -227,7 +227,7 @@ int main(int argc, char **argv) {
   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";
index 10b86382a455a2803be7e7e9bbf6f0e5ce96caa0..e7c449efaa8256b5cd4e35f399eab98d67b2c768 100644 (file)
@@ -107,7 +107,7 @@ int main(int argc, char **argv, char * const *envp) {
   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;
   }
   
index 960f8e371b8bab0d3a8007b697043a59713157ef..fe58db1222bb984353fdb6ef68711845e8dea283 100644 (file)
@@ -719,11 +719,11 @@ int main(int argc, char **argv) {
       // 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";
index 06798cbd28a33e23614d734eca84eff733b7fad2..53731b6c11e5d77617f5fc37456519398d43c8d8 100644 (file)
@@ -65,7 +65,7 @@ int main(int argc, char **argv) {
   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;
index c7aedd1006e00f4b1bb286a0819505fcb4de19ba..3caa2e6bd53e58770e288c0d132fcb8f061770eb 100644 (file)
@@ -22,7 +22,7 @@ using namespace llvm;
 /// 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
index b1a31a4d91dcc900c6bd204ddae8451cafa42383..a5c73bd86a0a0c618995eb86d5f558fbecacc4d6 100644 (file)
@@ -29,7 +29,7 @@ namespace llvm {
   /// 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 @@ namespace llvm {
     const SourceLanguage *CurrentLanguage;
 
   public:
-    CLIDebugger(LLVMContext* ctxt);
+    CLIDebugger(const LLVMContext& ctxt);
 
     /// getDebugger - Return the current LLVM debugger implementation being
     /// used.
index 62ee325bfd4a932a86c6628b203cbd1e7946e34b..78dbf71df5115e0ba4cf7fa1b0b049a603e5896d 100644 (file)
@@ -70,7 +70,7 @@ int main(int argc, char **argv, char * const *envp) {
       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();
index 3460f7e0fb7d3a010151e45212edd9999ed8ce36..901c8e9d3a93872d42b5a6cb33fc98ce2f8f725c 100644 (file)
@@ -63,7 +63,7 @@ int main(int argc, char **argv) {
    
     if (MemoryBuffer *Buffer
            = MemoryBuffer::getFileOrSTDIN(InputFilename, &ErrorMessage)) {
-      M.reset(ParseBitcodeFile(Buffer, &Context, &ErrorMessage));
+      M.reset(ParseBitcodeFile(Buffer, Context, &ErrorMessage));
       delete Buffer;
     }
 
index a9772116c9f4c092caed1fa40a77fc83575f1d6d..af0cf0705bf9c8c582eecfabc8dd0c40313a24fd 100644 (file)
@@ -73,7 +73,7 @@ int main(int argc, char **argv) {
     cerr << argv[0] << ": Error reading file '" + InputFilename + "'\n";
     return 1;
   } else {
-    M.reset(ParseBitcodeFile(Buffer, &Context));
+    M.reset(ParseBitcodeFile(Buffer, Context));
   }
   delete Buffer;
   
index 435de0f4a36585181357dc7ba08d040cb6cad0a3..2b9d2550dc2af2b2db30b514decc06176a812bba 100644 (file)
@@ -517,7 +517,7 @@ int main(int argc, char **argv, char **envp) {
     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;
index ae5fa40ecba8491639cc96ca00cb8d4cfb666e0a..818df14fd994da1c5304c1de60df7dbd64992ba7 100644 (file)
@@ -49,7 +49,7 @@ DumpAsm("d", cl::desc("Print assembly as linked"), cl::Hidden);
 // 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 @@ int main(int argc, char **argv) {
   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 @@ int main(int argc, char **argv) {
   }
 
   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;
index 3f19940660e93b0828f4760880ad6a1df8623654..4e011807a6d4dd760ac159e556c4f532bfd724ee 100644 (file)
@@ -142,7 +142,7 @@ static void DumpSymbolNamesFromFile(std::string &Filename) {
                    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 @@ static void DumpSymbolNamesFromFile(std::string &Filename) {
     
   } 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";
index 104d879447e106d663395571b364c44e302b8d64..cab87e7305827b883c3759b68257a6f0d6eb63d9 100644 (file)
@@ -127,7 +127,7 @@ int main(int argc, char **argv) {
     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) {
index 7b1b413ecca852c91eed76a5cda54fe7555ca2e2..d9bcc48eb13ed1bcce7db5d3a76868610c3a8d65 100644 (file)
@@ -75,7 +75,7 @@ int main(int argc, char **argv) {
 
     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;
index 8ae196fe94270d0f1f2fea69978356c37fe4fe25..faac33b8caed382136eecb021de75fbabb702a63 100644 (file)
@@ -69,8 +69,8 @@ const char* LTOCodeGenerator::getVersionString()
 }
 
 
-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),
index d412626fbf4a0f48a0fd3dbefc123b10609288d1..4603c35870da896342081158c46f43aa10db55ab 100644 (file)
@@ -31,7 +31,7 @@ class LTOCodeGenerator {
 public:
     static const char*        getVersionString();
     
-                            LTOCodeGenerator();
+                            LTOCodeGenerator(const llvm::LLVMContext& Context);
                             ~LTOCodeGenerator();
                             
     bool                addModule(class LTOModule*, std::string& errMsg);
@@ -54,7 +54,7 @@ private:
     
     typedef llvm::StringMap<uint8_t> StringSet;
 
-    llvm::LLVMContext*          _context;
+    const llvm::LLVMContext&          _context;
     llvm::Linker                _linker;
     llvm::TargetMachine*        _target;
     bool                        _emitDwarfDebugInfo;
index 64e79509017d96ec0d08caca7c455c8d776f3626..3da095d6c36cfb152a7a4a4a2e8341de9d31e719 100644 (file)
@@ -69,7 +69,7 @@ bool LTOModule::isBitcodeFileForTarget(const char* path,
 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(Module* m, TargetMachine* t)
 {
 }
 
-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 @@ MemoryBuffer* LTOModule::makeBuffer(const void* mem, size_t length)
 
 
 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 @@ std::string getFeatureString(const char *TargetTriple) {
   return Features.getString();
 }
 
-LTOModule* LTOModule::makeLTOModule(MemoryBuffer* buffer, LLVMContext* Context,
+LTOModule* LTOModule::makeLTOModule(MemoryBuffer* buffer,
+                                    const LLVMContext& Context,
                                     std::string& errMsg)
 {
     // parse bitcode buffer
index bfdf6e7fd093489e296848130b05966f4bed74c2..d7b992f71d43b6a192b03c7d2f4f6f7a9747f5f2 100644 (file)
@@ -52,10 +52,10 @@ public:
                                                     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 @@ private:
                                                     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);
 
index c25f87c34045f6e2eafe9756cbf40f37a010a740..02034bbf84660abfd4f8d883c901411bc772b729 100644 (file)
@@ -88,7 +88,7 @@ bool lto_module_is_object_file_in_memory_for_target(const void* mem,
 //
 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(const char* path, LLVMContextRef Ctxt)
 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 @@ lto_symbol_attributes lto_module_get_symbol_attribute(lto_module_t mod,
 // 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 @@ extern void
 lto_codegen_debug_options(lto_code_gen_t cg, const char * opt)
 {
   cg->setCodeGenDebugOptions(opt);
-}
+}
\ No newline at end of file
index b46960638d832f430c6a2d72deb66d228cb31971..689161940240b39376e7f5070a1da8895b55fea3 100644 (file)
@@ -327,7 +327,7 @@ int main(int argc, char **argv) {
     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;
     }
     
index 1bcf0ab1227fe9bb97c367b80d22df782728332e..1007ae1cc586c04fe17d76e968ab4667123e5246 100644 (file)
@@ -65,7 +65,7 @@ struct RecordingJITEventListener : public JITEventListener {
 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))) {
   }
 
index fb26d52e553670de8f83b1dfbae3a5bf1828690b..8122e2cad9b2558d3efaa14203817f98e2abdc91 100644 (file)
@@ -272,7 +272,7 @@ namespace llvm {
     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 @@ namespace llvm {
     }
 
     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 @@ namespace llvm {
 
     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");