diff options
author | Owen Anderson <resistor@mac.com> | 2009-07-01 16:58:40 +0000 |
---|---|---|
committer | Owen Anderson <resistor@mac.com> | 2009-07-01 16:58:40 +0000 |
commit | 8b477ed579794ba6d76915d56b3f448a7dd20120 (patch) | |
tree | 70d3be97f6ecf1ab7962e6cfafd113f2f7ce2579 /tools/llvm-link/llvm-link.cpp | |
parent | 4fb75e542539153acaf31d9221845a7d0feccbf6 (diff) | |
download | external_llvm-8b477ed579794ba6d76915d56b3f448a7dd20120.zip external_llvm-8b477ed579794ba6d76915d56b3f448a7dd20120.tar.gz external_llvm-8b477ed579794ba6d76915d56b3f448a7dd20120.tar.bz2 |
Add a pointer to the owning LLVMContext to Module. This requires threading LLVMContext through a lot
of the bitcode reader and ASM parser APIs, as well as supporting it in all of the tools.
Patches for Clang and LLVM-GCC to follow.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74614 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-link/llvm-link.cpp')
-rw-r--r-- | tools/llvm-link/llvm-link.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/tools/llvm-link/llvm-link.cpp b/tools/llvm-link/llvm-link.cpp index 15850f4..ae5fa40 100644 --- a/tools/llvm-link/llvm-link.cpp +++ b/tools/llvm-link/llvm-link.cpp @@ -13,6 +13,7 @@ //===----------------------------------------------------------------------===// #include "llvm/Linker.h" +#include "llvm/LLVMContext.h" #include "llvm/Module.h" #include "llvm/Analysis/Verifier.h" #include "llvm/Bitcode/ReaderWriter.h" @@ -47,7 +48,8 @@ DumpAsm("d", cl::desc("Print assembly as linked"), cl::Hidden); // LoadFile - Read the specified bitcode file in and return it. This routine // searches the link path for the specified file to try to find it... // -static inline std::auto_ptr<Module> LoadFile(const std::string &FN) { +static inline std::auto_ptr<Module> LoadFile(const std::string &FN, + LLVMContext* Context) { sys::Path Filename; if (!Filename.set(FN)) { cerr << "Invalid file name: '" << FN << "'\n"; @@ -62,7 +64,7 @@ static inline std::auto_ptr<Module> LoadFile(const std::string &FN) { const std::string &FNStr = Filename.toString(); if (MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(FNStr, &ErrorMessage)) { - Result = ParseBitcodeFile(Buffer, &ErrorMessage); + Result = ParseBitcodeFile(Buffer, Context, &ErrorMessage); delete Buffer; } if (Result) return std::auto_ptr<Module>(Result); // Load successful! @@ -84,13 +86,14 @@ int main(int argc, char **argv) { sys::PrintStackTraceOnErrorSignal(); PrettyStackTraceProgram X(argc, argv); + LLVMContext Context; llvm_shutdown_obj Y; // Call llvm_shutdown() on exit. cl::ParseCommandLineOptions(argc, argv, "llvm linker\n"); unsigned BaseArg = 0; std::string ErrorMessage; - std::auto_ptr<Module> Composite(LoadFile(InputFilenames[BaseArg])); + std::auto_ptr<Module> Composite(LoadFile(InputFilenames[BaseArg], &Context)); if (Composite.get() == 0) { cerr << argv[0] << ": error loading file '" << InputFilenames[BaseArg] << "'\n"; @@ -98,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])); + std::auto_ptr<Module> M(LoadFile(InputFilenames[i], &Context)); if (M.get() == 0) { cerr << argv[0] << ": error loading file '" <<InputFilenames[i]<< "'\n"; return 1; |