aboutsummaryrefslogtreecommitdiff
path: root/tools/lto
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2009-07-01 21:22:36 +0000
committerOwen Anderson <resistor@mac.com>2009-07-01 21:22:36 +0000
commit31895e73591d3c9ceae731a1274c8f56194b9616 (patch)
tree9e5f714db4af7dddfab061cb0016489f6d114c56 /tools/lto
parentfcd65ae28fe797c174be350a07955713fd42d110 (diff)
Hold the LLVMContext by reference rather than by pointer.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74640 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/lto')
-rw-r--r--tools/lto/LTOCodeGenerator.cpp4
-rw-r--r--tools/lto/LTOCodeGenerator.h4
-rw-r--r--tools/lto/LTOModule.cpp10
-rw-r--r--tools/lto/LTOModule.h6
-rw-r--r--tools/lto/lto.cpp10
5 files changed, 18 insertions, 16 deletions
diff --git a/tools/lto/LTOCodeGenerator.cpp b/tools/lto/LTOCodeGenerator.cpp
index 8ae196fe94..faac33b8ca 100644
--- a/tools/lto/LTOCodeGenerator.cpp
+++ b/tools/lto/LTOCodeGenerator.cpp
@@ -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),
diff --git a/tools/lto/LTOCodeGenerator.h b/tools/lto/LTOCodeGenerator.h
index d412626fbf..4603c35870 100644
--- a/tools/lto/LTOCodeGenerator.h
+++ b/tools/lto/LTOCodeGenerator.h
@@ -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;
diff --git a/tools/lto/LTOModule.cpp b/tools/lto/LTOModule.cpp
index 64e7950901..3da095d6c3 100644
--- a/tools/lto/LTOModule.cpp
+++ b/tools/lto/LTOModule.cpp
@@ -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
diff --git a/tools/lto/LTOModule.h b/tools/lto/LTOModule.h
index bfdf6e7fd0..d7b992f71d 100644
--- a/tools/lto/LTOModule.h
+++ b/tools/lto/LTOModule.h
@@ -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);
diff --git a/tools/lto/lto.cpp b/tools/lto/lto.cpp
index c25f87c340..02034bbf84 100644
--- a/tools/lto/lto.cpp
+++ b/tools/lto/lto.cpp
@@ -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