diff options
62 files changed, 624 insertions, 720 deletions
diff --git a/docs/tutorial/LangImpl4.html b/docs/tutorial/LangImpl4.html index 728d518a47..49921534b2 100644 --- a/docs/tutorial/LangImpl4.html +++ b/docs/tutorial/LangImpl4.html @@ -171,10 +171,7 @@ add a set of optimizations to run. The code looks like this:</p> <div class="doc_code"> <pre> - ExistingModuleProvider *OurModuleProvider = - new ExistingModuleProvider(TheModule); - - FunctionPassManager OurFPM(OurModuleProvider); + FunctionPassManager OurFPM(TheModule); // Set up the optimizer pipeline. Start with registering info about how the // target lays out data structures. @@ -198,19 +195,13 @@ add a set of optimizations to run. The code looks like this:</p> </pre> </div> -<p>This code defines two objects, an <tt>ExistingModuleProvider</tt> and a -<tt>FunctionPassManager</tt>. The former is basically a wrapper around our -<tt>Module</tt> that the PassManager requires. It provides certain flexibility -that we're not going to take advantage of here, so I won't dive into any details -about it.</p> - -<p>The meat of the matter here, is the definition of "<tt>OurFPM</tt>". It -requires a pointer to the <tt>Module</tt> (through the <tt>ModuleProvider</tt>) -to construct itself. Once it is set up, we use a series of "add" calls to add -a bunch of LLVM passes. The first pass is basically boilerplate, it adds a pass -so that later optimizations know how the data structures in the program are -laid out. The "<tt>TheExecutionEngine</tt>" variable is related to the JIT, -which we will get to in the next section.</p> +<p>This code defines a <tt>FunctionPassManager</tt>, "<tt>OurFPM</tt>". It +requires a pointer to the <tt>Module</tt> to construct itself. Once it is set +up, we use a series of "add" calls to add a bunch of LLVM passes. The first +pass is basically boilerplate, it adds a pass so that later optimizations know +how the data structures in the program are laid out. The +"<tt>TheExecutionEngine</tt>" variable is related to the JIT, which we will get +to in the next section.</p> <p>In this case, we choose to add 4 optimization passes. The passes we chose here are a pretty standard set of "cleanup" optimizations that are useful for @@ -302,8 +293,8 @@ by adding a global variable and a call in <tt>main</tt>:</p> ... int main() { .. - <b>// Create the JIT. This takes ownership of the module and module provider. - TheExecutionEngine = EngineBuilder(OurModuleProvider).create();</b> + <b>// Create the JIT. This takes ownership of the module. + TheExecutionEngine = EngineBuilder(TheModule).create();</b> .. } </pre> @@ -515,7 +506,6 @@ at runtime.</p> #include "llvm/ExecutionEngine/JIT.h" #include "llvm/LLVMContext.h" #include "llvm/Module.h" -#include "llvm/ModuleProvider.h" #include "llvm/PassManager.h" #include "llvm/Analysis/Verifier.h" #include "llvm/Target/TargetData.h" @@ -1084,13 +1074,10 @@ int main() { // Make the module, which holds all the code. TheModule = new Module("my cool jit", Context); - ExistingModuleProvider *OurModuleProvider = - new ExistingModuleProvider(TheModule); - - // Create the JIT. This takes ownership of the module and module provider. - TheExecutionEngine = EngineBuilder(OurModuleProvider).create(); + // Create the JIT. This takes ownership of the module. + TheExecutionEngine = EngineBuilder(TheModule).create(); - FunctionPassManager OurFPM(OurModuleProvider); + FunctionPassManager OurFPM(TheModule); // Set up the optimizer pipeline. Start with registering info about how the // target lays out data structures. diff --git a/docs/tutorial/LangImpl5.html b/docs/tutorial/LangImpl5.html index f93b59be0d..bc31de8fa5 100644 --- a/docs/tutorial/LangImpl5.html +++ b/docs/tutorial/LangImpl5.html @@ -906,7 +906,6 @@ if/then/else and for expressions.. To build this example, use: #include "llvm/ExecutionEngine/JIT.h" #include "llvm/LLVMContext.h" #include "llvm/Module.h" -#include "llvm/ModuleProvider.h" #include "llvm/PassManager.h" #include "llvm/Analysis/Verifier.h" #include "llvm/Target/TargetData.h" @@ -1720,13 +1719,10 @@ int main() { // Make the module, which holds all the code. TheModule = new Module("my cool jit", Context); - ExistingModuleProvider *OurModuleProvider = - new ExistingModuleProvider(TheModule); + // Create the JIT. This takes ownership of the module. + TheExecutionEngine = EngineBuilder(TheModule).create(); - // Create the JIT. This takes ownership of the module and module provider. - TheExecutionEngine = EngineBuilder(OurModuleProvider).create(); - - FunctionPassManager OurFPM(OurModuleProvider); + FunctionPassManager OurFPM(TheModule); // Set up the optimizer pipeline. Start with registering info about how the // target lays out data structures. diff --git a/docs/tutorial/LangImpl6.html b/docs/tutorial/LangImpl6.html index f113e96651..59fac6e21a 100644 --- a/docs/tutorial/LangImpl6.html +++ b/docs/tutorial/LangImpl6.html @@ -825,7 +825,6 @@ if/then/else and for expressions.. To build this example, use: #include "llvm/ExecutionEngine/JIT.h" #include "llvm/LLVMContext.h" #include "llvm/Module.h" -#include "llvm/ModuleProvider.h" #include "llvm/PassManager.h" #include "llvm/Analysis/Verifier.h" #include "llvm/Target/TargetData.h" @@ -1757,13 +1756,10 @@ int main() { // Make the module, which holds all the code. TheModule = new Module("my cool jit", Context); - ExistingModuleProvider *OurModuleProvider = - new ExistingModuleProvider(TheModule); + // Create the JIT. This takes ownership of the module. + TheExecutionEngine = EngineBuilder(TheModule).create(); - // Create the JIT. This takes ownership of the module and module provider. - TheExecutionEngine = EngineBuilder(OurModuleProvider).create(); - - FunctionPassManager OurFPM(OurModuleProvider); + FunctionPassManager OurFPM(TheModule); // Set up the optimizer pipeline. Start with registering info about how the // target lays out data structures. diff --git a/docs/tutorial/LangImpl7.html b/docs/tutorial/LangImpl7.html index ec07fa88d4..f53382ec2b 100644 --- a/docs/tutorial/LangImpl7.html +++ b/docs/tutorial/LangImpl7.html @@ -1008,7 +1008,6 @@ variables and var/in support. To build this example, use: #include "llvm/ExecutionEngine/JIT.h" #include "llvm/LLVMContext.h" #include "llvm/Module.h" -#include "llvm/ModuleProvider.h" #include "llvm/PassManager.h" #include "llvm/Analysis/Verifier.h" #include "llvm/Target/TargetData.h" @@ -2105,13 +2104,10 @@ int main() { // Make the module, which holds all the code. TheModule = new Module("my cool jit", Context); - ExistingModuleProvider *OurModuleProvider = - new ExistingModuleProvider(TheModule); + // Create the JIT. This takes ownership of the module. + TheExecutionEngine = EngineBuilder(TheModule).create(); - // Create the JIT. This takes ownership of the module and module provider. - TheExecutionEngine = EngineBuilder(OurModuleProvider).create(); - - FunctionPassManager OurFPM(OurModuleProvider); + FunctionPassManager OurFPM(TheModule); // Set up the optimizer pipeline. Start with registering info about how the // target lays out data structures. diff --git a/examples/BrainF/BrainFDriver.cpp b/examples/BrainF/BrainFDriver.cpp index 6f4ba69927..c11a58067e 100644 --- a/examples/BrainF/BrainFDriver.cpp +++ b/examples/BrainF/BrainFDriver.cpp @@ -27,7 +27,6 @@ #include "BrainF.h" #include "llvm/Constants.h" -#include "llvm/ModuleProvider.h" #include "llvm/Analysis/Verifier.h" #include "llvm/Bitcode/ReaderWriter.h" #include "llvm/ExecutionEngine/GenericValue.h" diff --git a/examples/Fibonacci/fibonacci.cpp b/examples/Fibonacci/fibonacci.cpp index 077cdd0f5d..353e17380c 100644 --- a/examples/Fibonacci/fibonacci.cpp +++ b/examples/Fibonacci/fibonacci.cpp @@ -28,7 +28,6 @@ #include "llvm/DerivedTypes.h" #include "llvm/Constants.h" #include "llvm/Instructions.h" -#include "llvm/ModuleProvider.h" #include "llvm/Analysis/Verifier.h" #include "llvm/ExecutionEngine/JIT.h" #include "llvm/ExecutionEngine/Interpreter.h" diff --git a/examples/HowToUseJIT/HowToUseJIT.cpp b/examples/HowToUseJIT/HowToUseJIT.cpp index ec9c2e6854..426d2818cd 100644 --- a/examples/HowToUseJIT/HowToUseJIT.cpp +++ b/examples/HowToUseJIT/HowToUseJIT.cpp @@ -39,7 +39,6 @@ #include "llvm/Constants.h" #include "llvm/DerivedTypes.h" #include "llvm/Instructions.h" -#include "llvm/ModuleProvider.h" #include "llvm/ExecutionEngine/JIT.h" #include "llvm/ExecutionEngine/Interpreter.h" #include "llvm/ExecutionEngine/GenericValue.h" diff --git a/examples/Kaleidoscope/Chapter4/toy.cpp b/examples/Kaleidoscope/Chapter4/toy.cpp index d136635e81..cdc9d74dde 100644 --- a/examples/Kaleidoscope/Chapter4/toy.cpp +++ b/examples/Kaleidoscope/Chapter4/toy.cpp @@ -4,7 +4,6 @@ #include "llvm/ExecutionEngine/JIT.h" #include "llvm/LLVMContext.h" #include "llvm/Module.h" -#include "llvm/ModuleProvider.h" #include "llvm/PassManager.h" #include "llvm/Analysis/Verifier.h" #include "llvm/Target/TargetData.h" @@ -573,13 +572,10 @@ int main() { // Make the module, which holds all the code. TheModule = new Module("my cool jit", Context); - ExistingModuleProvider *OurModuleProvider = - new ExistingModuleProvider(TheModule); + // Create the JIT. This takes ownership of the module. + TheExecutionEngine = EngineBuilder(TheModule).create(); - // Create the JIT. This takes ownership of the module and module provider. - TheExecutionEngine = EngineBuilder(OurModuleProvider).create(); - - FunctionPassManager OurFPM(OurModuleProvider); + FunctionPassManager OurFPM(TheModule); // Set up the optimizer pipeline. Start with registering info about how the // target lays out data structures. diff --git a/examples/Kaleidoscope/Chapter5/toy.cpp b/examples/Kaleidoscope/Chapter5/toy.cpp index c2613e3602..24f551f3a6 100644 --- a/examples/Kaleidoscope/Chapter5/toy.cpp +++ b/examples/Kaleidoscope/Chapter5/toy.cpp @@ -4,7 +4,6 @@ #include "llvm/ExecutionEngine/JIT.h" #include "llvm/LLVMContext.h" #include "llvm/Module.h" -#include "llvm/ModuleProvider.h" #include "llvm/PassManager.h" #include "llvm/Analysis/Verifier.h" #include "llvm/Target/TargetData.h" @@ -818,13 +817,10 @@ int main() { // Make the module, which holds all the code. TheModule = new Module("my cool jit", Context); - ExistingModuleProvider *OurModuleProvider = - new ExistingModuleProvider(TheModule); + // Create the JIT. This takes ownership of the module. + TheExecutionEngine = EngineBuilder(TheModule).create(); - // Create the JIT. This takes ownership of the module and module provider. - TheExecutionEngine = EngineBuilder(OurModuleProvider).create(); - - FunctionPassManager OurFPM(OurModuleProvider); + FunctionPassManager OurFPM(TheModule); // Set up the optimizer pipeline. Start with registering info about how the // target lays out data structures. diff --git a/examples/Kaleidoscope/Chapter6/toy.cpp b/examples/Kaleidoscope/Chapter6/toy.cpp index 638a340d51..f4b5b8cd38 100644 --- a/examples/Kaleidoscope/Chapter6/toy.cpp +++ b/examples/Kaleidoscope/Chapter6/toy.cpp @@ -4,7 +4,6 @@ #include "llvm/ExecutionEngine/JIT.h" #include "llvm/LLVMContext.h" #include "llvm/Module.h" -#include "llvm/ModuleProvider.h" #include "llvm/PassManager.h" #include "llvm/Analysis/Verifier.h" #include "llvm/Target/TargetData.h" @@ -936,13 +935,10 @@ int main() { // Make the module, which holds all the code. TheModule = new Module("my cool jit", Context); - ExistingModuleProvider *OurModuleProvider = - new ExistingModuleProvider(TheModule); + // Create the JIT. This takes ownership of the module. + TheExecutionEngine = EngineBuilder(TheModule).create(); - // Create the JIT. This takes ownership of the module and module provider. - TheExecutionEngine = EngineBuilder(OurModuleProvider).create(); - - FunctionPassManager OurFPM(OurModuleProvider); + FunctionPassManager OurFPM(TheModule); // Set up the optimizer pipeline. Start with registering info about how the // target lays out data structures. diff --git a/examples/Kaleidoscope/Chapter7/toy.cpp b/examples/Kaleidoscope/Chapter7/toy.cpp index 8b0c321c06..951dfd8e63 100644 --- a/examples/Kaleidoscope/Chapter7/toy.cpp +++ b/examples/Kaleidoscope/Chapter7/toy.cpp @@ -4,7 +4,6 @@ #include "llvm/ExecutionEngine/JIT.h" #include "llvm/LLVMContext.h" #include "llvm/Module.h" -#include "llvm/ModuleProvider.h" #include "llvm/PassManager.h" #include "llvm/Analysis/Verifier.h" #include "llvm/Target/TargetData.h" @@ -1100,13 +1099,10 @@ int main() { // Make the module, which holds all the code. TheModule = new Module("my cool jit", Context); - ExistingModuleProvider *OurModuleProvider = - new ExistingModuleProvider(TheModule); + // Create the JIT. This takes ownership of the module. + TheExecutionEngine = EngineBuilder(TheModule).create(); - // Create the JIT. This takes ownership of the module and module provider. - TheExecutionEngine = EngineBuilder(OurModuleProvider).create(); - - FunctionPassManager OurFPM(OurModuleProvider); + FunctionPassManager OurFPM(TheModule); // Set up the optimizer pipeline. Start with registering info about how the // target lays out data structures. diff --git a/examples/ParallelJIT/ParallelJIT.cpp b/examples/ParallelJIT/ParallelJIT.cpp index be40a28215..9231abf6e3 100644 --- a/examples/ParallelJIT/ParallelJIT.cpp +++ b/examples/ParallelJIT/ParallelJIT.cpp @@ -23,7 +23,6 @@ #include "llvm/Constants.h" #include "llvm/DerivedTypes.h" #include "llvm/Instructions.h" -#include "llvm/ModuleProvider.h" #include "llvm/ExecutionEngine/JIT.h" #include "llvm/ExecutionEngine/Interpreter.h" #include "llvm/ExecutionEngine/GenericValue.h" diff --git a/include/llvm-c/Core.h b/include/llvm-c/Core.h index d57c250fcb..674dde509d 100644 --- a/include/llvm-c/Core.h +++ b/include/llvm-c/Core.h @@ -78,8 +78,9 @@ typedef struct LLVMOpaqueValue *LLVMValueRef; typedef struct LLVMOpaqueBasicBlock *LLVMBasicBlockRef; typedef struct LLVMOpaqueBuilder *LLVMBuilderRef; -/* Used to provide a module to JIT or interpreter. - * See the llvm::ModuleProvider class. +/* Interface used to provide a module to JIT or interpreter. This is now just a + * synonym for llvm::Module, but we have to keep using the different type to + * keep binary compatibility. */ typedef struct LLVMOpaqueModuleProvider *LLVMModuleProviderRef; @@ -210,8 +211,7 @@ typedef enum { LLVMDLLImportLinkage, /**< Function to be imported from DLL */ LLVMDLLExportLinkage, /**< Function to be accessible from DLL */ LLVMExternalWeakLinkage,/**< ExternalWeak linkage description */ - LLVMGhostLinkage, /**< Stand-in functions for streaming fns from - bitcode */ + LLVMGhostLinkage, /**< Obsolete */ LLVMCommonLinkage, /**< Tentative definitions */ LLVMLinkerPrivateLinkage /**< Like Private, but linker removes. */ } LLVMLinkage; @@ -914,17 +914,15 @@ LLVMValueRef LLVMBuildPtrDiff(LLVMBuilderRef, LLVMValueRef LHS, /*===-- Module providers --------------------------------------------------===*/ -/* Encapsulates the module M in a module provider, taking ownership of the - * module. - * See the constructor llvm::ExistingModuleProvider::ExistingModuleProvider. +/* Changes the type of M so it can be passed to FunctionPassManagers and the + * JIT. They take ModuleProviders for historical reasons. */ LLVMModuleProviderRef LLVMCreateModuleProviderForExistingModule(LLVMModuleRef M); -/* Destroys the module provider MP as well as the contained module. - * See the destructor llvm::ModuleProvider::~ModuleProvider. +/* Destroys the module M. */ -void LLVMDisposeModuleProvider(LLVMModuleProviderRef MP); +void LLVMDisposeModuleProvider(LLVMModuleProviderRef M); /*===-- Memory buffers ----------------------------------------------------===*/ @@ -981,7 +979,6 @@ void LLVMDisposePassManager(LLVMPassManagerRef PM); } namespace llvm { - class ModuleProvider; class MemoryBuffer; class PassManagerBase; @@ -1018,11 +1015,16 @@ namespace llvm { DEFINE_SIMPLE_CONVERSION_FUNCTIONS(BasicBlock, LLVMBasicBlockRef ) DEFINE_SIMPLE_CONVERSION_FUNCTIONS(IRBuilder<>, LLVMBuilderRef ) DEFINE_SIMPLE_CONVERSION_FUNCTIONS(PATypeHolder, LLVMTypeHandleRef ) - DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ModuleProvider, LLVMModuleProviderRef) DEFINE_SIMPLE_CONVERSION_FUNCTIONS(MemoryBuffer, LLVMMemoryBufferRef ) DEFINE_SIMPLE_CONVERSION_FUNCTIONS(LLVMContext, LLVMContextRef ) DEFINE_SIMPLE_CONVERSION_FUNCTIONS(Use, LLVMUseIteratorRef ) DEFINE_STDCXX_CONVERSION_FUNCTIONS(PassManagerBase, LLVMPassManagerRef ) + /* LLVMModuleProviderRef exists for historical reasons, but now just holds a + * Module. + */ + inline Module *unwrap(LLVMModuleProviderRef MP) { + return reinterpret_cast<Module*>(MP); + } #undef DEFINE_STDCXX_CONVERSION_FUNCTIONS #undef DEFINE_ISA_CONVERSION_FUNCTIONS diff --git a/include/llvm/Bitcode/Archive.h b/include/llvm/Bitcode/Archive.h index e19e4c09ce..67f2a4a999 100644 --- a/include/llvm/Bitcode/Archive.h +++ b/include/llvm/Bitcode/Archive.h @@ -27,7 +27,6 @@ namespace llvm { class MemoryBuffer; // Forward declare classes -class ModuleProvider; // From VMCore class Module; // From VMCore class Archive; // Declared below class ArchiveMemberHeader; // Internal implementation class @@ -374,14 +373,14 @@ class Archive { /// returns the associated module that defines that symbol. This method can /// be called as many times as necessary. This is handy for linking the /// archive into another module based on unresolved symbols. Note that the - /// ModuleProvider returned by this accessor should not be deleted by the - /// caller. It is managed internally by the Archive class. It is possible - /// that multiple calls to this accessor will return the same ModuleProvider - /// instance because the associated module defines multiple symbols. - /// @returns The ModuleProvider* found or null if the archive does not - /// contain a module that defines the \p symbol. + /// Module returned by this accessor should not be deleted by the caller. It + /// is managed internally by the Archive class. It is possible that multiple + /// calls to this accessor will return the same Module instance because the + /// associated module defines multiple symbols. + /// @returns The Module* found or null if the archive does not contain a + /// module that defines the \p symbol. /// @brief Look up a module by symbol name. - ModuleProvider* findModuleDefiningSymbol( + Module* findModuleDefiningSymbol( const std::string& symbol, ///< Symbol to be sought std::string* ErrMessage ///< Error message storage, if non-zero ); @@ -397,7 +396,7 @@ class Archive { /// @brief Look up multiple symbols in the archive. bool findModulesDefiningSymbols( std::set<std::string>& symbols, ///< Symbols to be sought - std::set<ModuleProvider*>& modules, ///< The modules matching \p symbols + std::set<Module*>& modules, ///< The modules matching \p symbols std::string* ErrMessage ///< Error msg storage, if non-zero ); @@ -513,9 +512,9 @@ class Archive { /// This type is used to keep track of bitcode modules loaded from the /// symbol table. It maps the file offset to a pair that consists of the - /// associated ArchiveMember and the ModuleProvider. + /// associated ArchiveMember and the Module. /// @brief Module mapping type - typedef std::map<unsigned,std::pair<ModuleProvider*,ArchiveMember*> > + typedef std::map<unsigned,std::pair<Module*,ArchiveMember*> > ModuleMap; diff --git a/include/llvm/Bitcode/ReaderWriter.h b/include/llvm/Bitcode/ReaderWriter.h index 7b74bdf76b..45eb801a8c 100644 --- a/include/llvm/Bitcode/ReaderWriter.h +++ b/include/llvm/Bitcode/ReaderWriter.h @@ -18,21 +18,20 @@ namespace llvm { class Module; - class ModuleProvider; class MemoryBuffer; class ModulePass; class BitstreamWriter; class LLVMContext; class raw_ostream; - /// getBitcodeModuleProvider - Read the header of the specified bitcode buffer + /// getLazyBitcodeModule - Read the header of the specified bitcode buffer /// and prepare for lazy deserialization of function bodies. If successful, /// this takes ownership of 'buffer' and returns a non-null pointer. On /// error, this returns |