mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-21 16:31:16 +00:00
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
This commit is contained in:
parent
fcd65ae28f
commit
31895e7359
@ -37,7 +37,7 @@ const char *BrainF::label = "brainf";
|
|||||||
const char *BrainF::testreg = "test";
|
const char *BrainF::testreg = "test";
|
||||||
|
|
||||||
Module *BrainF::parse(std::istream *in1, int mem, CompileFlags cf,
|
Module *BrainF::parse(std::istream *in1, int mem, CompileFlags cf,
|
||||||
LLVMContext* Context) {
|
const LLVMContext& Context) {
|
||||||
in = in1;
|
in = in1;
|
||||||
memtotal = mem;
|
memtotal = mem;
|
||||||
comflag = cf;
|
comflag = cf;
|
||||||
@ -48,7 +48,7 @@ Module *BrainF::parse(std::istream *in1, int mem, CompileFlags cf,
|
|||||||
return module;
|
return module;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrainF::header(LLVMContext* C) {
|
void BrainF::header(const LLVMContext& C) {
|
||||||
module = new Module("BrainF", C);
|
module = new Module("BrainF", C);
|
||||||
|
|
||||||
//Function prototypes
|
//Function prototypes
|
||||||
|
@ -39,7 +39,8 @@ class BrainF {
|
|||||||
/// containing the resulting code.
|
/// containing the resulting code.
|
||||||
/// On error, it calls abort.
|
/// On error, it calls abort.
|
||||||
/// The caller must delete the returned module.
|
/// 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:
|
protected:
|
||||||
/// The different symbols in the BrainF language
|
/// The different symbols in the BrainF language
|
||||||
@ -65,7 +66,7 @@ class BrainF {
|
|||||||
static const char *testreg;
|
static const char *testreg;
|
||||||
|
|
||||||
/// Put the brainf function preamble and other fixed pieces of code
|
/// 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
|
/// The main loop for parsing. It calls itself recursively
|
||||||
/// to handle the depth of nesting of "[]".
|
/// to handle the depth of nesting of "[]".
|
||||||
|
@ -126,7 +126,7 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
//Read the BrainF program
|
//Read the BrainF program
|
||||||
BrainF bf;
|
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;}
|
if (in != &std::cin) {delete in;}
|
||||||
addMainFunction(mod);
|
addMainFunction(mod);
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ int main(int argc, char **argv) {
|
|||||||
LLVMContext Context;
|
LLVMContext Context;
|
||||||
|
|
||||||
// Create some module to put our function into it.
|
// 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:
|
// We are about to create the "fib" function:
|
||||||
Function *FibF = CreateFibFunction(M);
|
Function *FibF = CreateFibFunction(M);
|
||||||
|
@ -55,7 +55,7 @@ int main() {
|
|||||||
LLVMContext Context;
|
LLVMContext Context;
|
||||||
|
|
||||||
// Create some module to put our function into it.
|
// 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
|
// 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".
|
// function will have a return type of "int" and take an argument of "int".
|
||||||
|
@ -1099,7 +1099,7 @@ int main() {
|
|||||||
getNextToken();
|
getNextToken();
|
||||||
|
|
||||||
// Make the module, which holds all the code.
|
// 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.
|
// Create the JIT.
|
||||||
TheExecutionEngine = ExecutionEngine::create(TheModule);
|
TheExecutionEngine = ExecutionEngine::create(TheModule);
|
||||||
|
@ -27,7 +27,7 @@ int main() {
|
|||||||
|
|
||||||
// Create the "module" or "program" or "translation unit" to hold the
|
// Create the "module" or "program" or "translation unit" to hold the
|
||||||
// function
|
// function
|
||||||
Module *M = new Module("test", &Context);
|
Module *M = new Module("test", Context);
|
||||||
|
|
||||||
// Create the main function: first create the type 'int ()'
|
// Create the main function: first create the type 'int ()'
|
||||||
FunctionType *FT = FunctionType::get(Type::Int32Ty, /*not vararg*/false);
|
FunctionType *FT = FunctionType::get(Type::Int32Ty, /*not vararg*/false);
|
||||||
|
@ -236,7 +236,7 @@ int main() {
|
|||||||
LLVMContext Context;
|
LLVMContext Context;
|
||||||
|
|
||||||
// Create some module to put our function into it.
|
// 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* add1F = createAdd1( M );
|
||||||
Function* fibF = CreateFibFunction( M );
|
Function* fibF = CreateFibFunction( M );
|
||||||
|
@ -58,6 +58,7 @@ typedef struct LTOModule* lto_module_t;
|
|||||||
/** opaque reference to a code generator */
|
/** opaque reference to a code generator */
|
||||||
typedef struct LTOCodeGenerator* lto_code_gen_t;
|
typedef struct LTOCodeGenerator* lto_code_gen_t;
|
||||||
|
|
||||||
|
typedef struct LTOContext* lto_context_t;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@ -76,7 +77,6 @@ lto_get_version(void);
|
|||||||
extern const char*
|
extern const char*
|
||||||
lto_get_error_message(void);
|
lto_get_error_message(void);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if a file is a loadable object file.
|
* Checks if a file is a loadable object file.
|
||||||
*/
|
*/
|
||||||
|
@ -32,7 +32,7 @@ class LLVMContext;
|
|||||||
Module *ParseAssemblyFile(
|
Module *ParseAssemblyFile(
|
||||||
const std::string &Filename, ///< The name of the file to parse
|
const std::string &Filename, ///< The name of the file to parse
|
||||||
ParseError &Error, ///< If not null, an object to return errors in.
|
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
|
/// 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
|
const char *AsmString, ///< The string containing assembly
|
||||||
Module *M, ///< A module to add the assembly too.
|
Module *M, ///< A module to add the assembly too.
|
||||||
ParseError &Error, ///< If not null, an object to return errors in.
|
ParseError &Error, ///< If not null, an object to return errors in.
|
||||||
LLVMContext* Context
|
const LLVMContext& Context
|
||||||
);
|
);
|
||||||
|
|
||||||
//===------------------------------------------------------------------------===
|
//===------------------------------------------------------------------------===
|
||||||
|
@ -280,7 +280,7 @@ class Archive {
|
|||||||
/// @brief Create an empty Archive.
|
/// @brief Create an empty Archive.
|
||||||
static Archive* CreateEmpty(
|
static Archive* CreateEmpty(
|
||||||
const sys::Path& Filename,///< Name of the archive to (eventually) create.
|
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
|
/// Open an existing archive and load its contents in preparation for
|
||||||
@ -291,7 +291,7 @@ class Archive {
|
|||||||
/// @brief Open and load an archive file
|
/// @brief Open and load an archive file
|
||||||
static Archive* OpenAndLoad(
|
static Archive* OpenAndLoad(
|
||||||
const sys::Path& filePath, ///< The file path to open and load
|
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
|
std::string* ErrorMessage ///< An optional error string
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -313,7 +313,7 @@ class Archive {
|
|||||||
/// @brief Open an existing archive and load its symbols.
|
/// @brief Open an existing archive and load its symbols.
|
||||||
static Archive* OpenAndLoadSymbols(
|
static Archive* OpenAndLoadSymbols(
|
||||||
const sys::Path& Filename, ///< Name of the archive file to open
|
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
|
std::string* ErrorMessage=0 ///< An optional error string
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -453,7 +453,7 @@ class Archive {
|
|||||||
protected:
|
protected:
|
||||||
/// @brief Construct an Archive for \p filename and optionally map it
|
/// @brief Construct an Archive for \p filename and optionally map it
|
||||||
/// into memory.
|
/// 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 data The symbol table data to be parsed
|
||||||
/// @param len The length of the symbol table data
|
/// @param len The length of the symbol table data
|
||||||
@ -534,7 +534,7 @@ class Archive {
|
|||||||
unsigned firstFileOffset; ///< Offset to first normal file.
|
unsigned firstFileOffset; ///< Offset to first normal file.
|
||||||
ModuleMap modules; ///< The modules loaded via symbol lookup.
|
ModuleMap modules; ///< The modules loaded via symbol lookup.
|
||||||
ArchiveMember* foreignST; ///< This holds the foreign symbol table.
|
ArchiveMember* foreignST; ///< This holds the foreign symbol table.
|
||||||
LLVMContext* Context; ///< This holds global data.
|
const LLVMContext& Context; ///< This holds global data.
|
||||||
/// @}
|
/// @}
|
||||||
/// @name Hidden
|
/// @name Hidden
|
||||||
/// @{
|
/// @{
|
||||||
|
@ -32,13 +32,13 @@ namespace llvm {
|
|||||||
/// error, this returns null, *does not* take ownership of Buffer, and fills
|
/// error, this returns null, *does not* take ownership of Buffer, and fills
|
||||||
/// in *ErrMsg with an error description if ErrMsg is non-null.
|
/// in *ErrMsg with an error description if ErrMsg is non-null.
|
||||||
ModuleProvider *getBitcodeModuleProvider(MemoryBuffer *Buffer,
|
ModuleProvider *getBitcodeModuleProvider(MemoryBuffer *Buffer,
|
||||||
LLVMContext* Context,
|
const LLVMContext& Context,
|
||||||
std::string *ErrMsg = 0);
|
std::string *ErrMsg = 0);
|
||||||
|
|
||||||
/// ParseBitcodeFile - Read the specified bitcode file, returning the module.
|
/// ParseBitcodeFile - Read the specified bitcode file, returning the module.
|
||||||
/// If an error occurs, this returns null and fills in *ErrMsg if it is
|
/// If an error occurs, this returns null and fills in *ErrMsg if it is
|
||||||
/// non-null. This method *never* takes ownership of Buffer.
|
/// 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);
|
std::string *ErrMsg = 0);
|
||||||
|
|
||||||
/// WriteBitcodeToFile - Write the specified module to the specified output
|
/// WriteBitcodeToFile - Write the specified module to the specified output
|
||||||
|
@ -96,7 +96,7 @@ namespace llvm {
|
|||||||
/// the PATH for the specified program, loading it when found. If the
|
/// the PATH for the specified program, loading it when found. If the
|
||||||
/// specified program cannot be found, an exception is thrown to indicate
|
/// specified program cannot be found, an exception is thrown to indicate
|
||||||
/// the error.
|
/// 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
|
/// unloadProgram - If a program is running, kill it, then unload all traces
|
||||||
/// of the current program. If no program is loaded, this method silently
|
/// of the current program. If no program is loaded, this method silently
|
||||||
|
@ -198,7 +198,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
/// FOR BACKWARDS COMPATIBILITY - Returns a global context.
|
/// FOR BACKWARDS COMPATIBILITY - Returns a global context.
|
||||||
LLVMContext* getGlobalContext();
|
extern const LLVMContext& getGlobalContext();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#ifndef LLVM_LINKALLVMCORE_H
|
#ifndef LLVM_LINKALLVMCORE_H
|
||||||
#define LLVM_LINKALLVMCORE_H
|
#define LLVM_LINKALLVMCORE_H
|
||||||
|
|
||||||
|
#include "llvm/LLVMContext.h"
|
||||||
#include "llvm/Module.h"
|
#include "llvm/Module.h"
|
||||||
#include "llvm/Instructions.h"
|
#include "llvm/Instructions.h"
|
||||||
#include "llvm/IntrinsicInst.h"
|
#include "llvm/IntrinsicInst.h"
|
||||||
@ -44,7 +45,7 @@ namespace {
|
|||||||
// to know that getenv() never returns -1, this will do the job.
|
// to know that getenv() never returns -1, this will do the job.
|
||||||
if (std::getenv("bar") != (char*) -1)
|
if (std::getenv("bar") != (char*) -1)
|
||||||
return;
|
return;
|
||||||
llvm::Module* M = new llvm::Module("", 0);
|
llvm::Module* M = new llvm::Module("", llvm::getGlobalContext());
|
||||||
(void)new llvm::UnreachableInst();
|
(void)new llvm::UnreachableInst();
|
||||||
(void) llvm::createVerifierPass();
|
(void) llvm::createVerifierPass();
|
||||||
(void) new llvm::Mangler(*M,"");
|
(void) new llvm::Mangler(*M,"");
|
||||||
|
@ -67,7 +67,7 @@ class Linker {
|
|||||||
Linker(
|
Linker(
|
||||||
const std::string& progname, ///< name of tool running linker
|
const std::string& progname, ///< name of tool running linker
|
||||||
const std::string& modulename, ///< name of linker's end-result module
|
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)
|
unsigned Flags = 0 ///< ControlFlags (one or more |'d together)
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -285,7 +285,7 @@ class Linker {
|
|||||||
/// @name Data
|
/// @name Data
|
||||||
/// @{
|
/// @{
|
||||||
private:
|
private:
|
||||||
LLVMContext* Context; ///< The context for global information
|
const LLVMContext& Context; ///< The context for global information
|
||||||
Module* Composite; ///< The composite module linked together
|
Module* Composite; ///< The composite module linked together
|
||||||
std::vector<sys::Path> LibPaths; ///< The library search paths
|
std::vector<sys::Path> LibPaths; ///< The library search paths
|
||||||
unsigned Flags; ///< Flags to control optional behavior.
|
unsigned Flags; ///< Flags to control optional behavior.
|
||||||
|
@ -110,7 +110,7 @@ public:
|
|||||||
/// @name Member Variables
|
/// @name Member Variables
|
||||||
/// @{
|
/// @{
|
||||||
private:
|
private:
|
||||||
LLVMContext* Context; ///< The LLVMContext from which types and
|
const LLVMContext& Context; ///< The LLVMContext from which types and
|
||||||
///< constants are allocated.
|
///< constants are allocated.
|
||||||
GlobalListType GlobalList; ///< The Global Variables in the module
|
GlobalListType GlobalList; ///< The Global Variables in the module
|
||||||
FunctionListType FunctionList; ///< The Functions in the module
|
FunctionListType FunctionList; ///< The Functions in the module
|
||||||
@ -131,7 +131,7 @@ private:
|
|||||||
public:
|
public:
|
||||||
/// The Module constructor. Note that there is no default constructor. You
|
/// The Module constructor. Note that there is no default constructor. You
|
||||||
/// must provide a name for the module upon construction.
|
/// 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.
|
/// The module destructor. This will dropAllReferences.
|
||||||
~Module();
|
~Module();
|
||||||
|
|
||||||
@ -162,7 +162,7 @@ public:
|
|||||||
|
|
||||||
/// Get the global data context.
|
/// Get the global data context.
|
||||||
/// @returns LLVMContext - a container for LLVM's global information
|
/// @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.
|
/// Get any module-scope inline assembly blocks.
|
||||||
/// @returns a string containing the module-scope inline assembly blocks.
|
/// @returns a string containing the module-scope inline assembly blocks.
|
||||||
|
@ -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 constructor - this is the only constructor that gets used for the
|
||||||
// Archive class. Everything else (default,copy) is deprecated. This just
|
// Archive class. Everything else (default,copy) is deprecated. This just
|
||||||
// initializes and maps the file into memory, if requested.
|
// 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(),
|
: archPath(filename), members(), mapfile(0), base(0), symTab(), strtab(),
|
||||||
symTabSize(0), firstFileOffset(0), modules(), foreignST(0), Context(C) {
|
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
|
// Get just the externally visible defined symbols from the bitcode
|
||||||
bool llvm::GetBitcodeSymbols(const sys::Path& fName,
|
bool llvm::GetBitcodeSymbols(const sys::Path& fName,
|
||||||
LLVMContext* Context,
|
const LLVMContext& Context,
|
||||||
std::vector<std::string>& symbols,
|
std::vector<std::string>& symbols,
|
||||||
std::string* ErrMsg) {
|
std::string* ErrMsg) {
|
||||||
std::auto_ptr<MemoryBuffer> Buffer(
|
std::auto_ptr<MemoryBuffer> Buffer(
|
||||||
@ -240,7 +240,7 @@ bool llvm::GetBitcodeSymbols(const sys::Path& fName,
|
|||||||
ModuleProvider*
|
ModuleProvider*
|
||||||
llvm::GetBitcodeSymbols(const unsigned char *BufPtr, unsigned Length,
|
llvm::GetBitcodeSymbols(const unsigned char *BufPtr, unsigned Length,
|
||||||
const std::string& ModuleID,
|
const std::string& ModuleID,
|
||||||
LLVMContext* Context,
|
const LLVMContext& Context,
|
||||||
std::vector<std::string>& symbols,
|
std::vector<std::string>& symbols,
|
||||||
std::string* ErrMsg) {
|
std::string* ErrMsg) {
|
||||||
// Get the module provider
|
// Get the module provider
|
||||||
|
@ -73,13 +73,13 @@ namespace llvm {
|
|||||||
|
|
||||||
// Get just the externally visible defined symbols from the bitcode
|
// Get just the externally visible defined symbols from the bitcode
|
||||||
bool GetBitcodeSymbols(const sys::Path& fName,
|
bool GetBitcodeSymbols(const sys::Path& fName,
|
||||||
LLVMContext* Context,
|
const LLVMContext& Context,
|
||||||
std::vector<std::string>& symbols,
|
std::vector<std::string>& symbols,
|
||||||
std::string* ErrMsg);
|
std::string* ErrMsg);
|
||||||
|
|
||||||
ModuleProvider* GetBitcodeSymbols(const unsigned char*Buffer,unsigned Length,
|
ModuleProvider* GetBitcodeSymbols(const unsigned char*Buffer,unsigned Length,
|
||||||
const std::string& ModuleID,
|
const std::string& ModuleID,
|
||||||
LLVMContext* Context,
|
const LLVMContext& Context,
|
||||||
std::vector<std::string>& symbols,
|
std::vector<std::string>& symbols,
|
||||||
std::string* ErrMsg);
|
std::string* ErrMsg);
|
||||||
}
|
}
|
||||||
|
@ -327,7 +327,7 @@ Archive::loadArchive(std::string* error) {
|
|||||||
|
|
||||||
// Open and completely load the archive file.
|
// Open and completely load the archive file.
|
||||||
Archive*
|
Archive*
|
||||||
Archive::OpenAndLoad(const sys::Path& file, LLVMContext* C,
|
Archive::OpenAndLoad(const sys::Path& file, const LLVMContext& C,
|
||||||
std::string* ErrorMessage) {
|
std::string* ErrorMessage) {
|
||||||
std::auto_ptr<Archive> result ( new Archive(file, C));
|
std::auto_ptr<Archive> result ( new Archive(file, C));
|
||||||
if (result->mapToMemory(ErrorMessage))
|
if (result->mapToMemory(ErrorMessage))
|
||||||
@ -441,7 +441,8 @@ Archive::loadSymbolTable(std::string* ErrorMsg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Open the archive and load just the symbol tables
|
// 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::string* ErrorMessage) {
|
||||||
std::auto_ptr<Archive> result ( new Archive(file, C) );
|
std::auto_ptr<Archive> result ( new Archive(file, C) );
|
||||||
if (result->mapToMemory(ErrorMessage))
|
if (result->mapToMemory(ErrorMessage))
|
||||||
|
@ -64,7 +64,7 @@ static inline unsigned numVbrBytes(unsigned num) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create an empty archive.
|
// 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);
|
Archive* result = new Archive(FilePath, C);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
Module *llvm::ParseAssemblyFile(const std::string &Filename, ParseError &Err,
|
Module *llvm::ParseAssemblyFile(const std::string &Filename, ParseError &Err,
|
||||||
LLVMContext* Context) {
|
const LLVMContext& Context) {
|
||||||
Err.setFilename(Filename);
|
Err.setFilename(Filename);
|
||||||
|
|
||||||
std::string ErrorStr;
|
std::string ErrorStr;
|
||||||
@ -39,7 +39,7 @@ Module *llvm::ParseAssemblyFile(const std::string &Filename, ParseError &Err,
|
|||||||
}
|
}
|
||||||
|
|
||||||
Module *llvm::ParseAssemblyString(const char *AsmString, Module *M,
|
Module *llvm::ParseAssemblyString(const char *AsmString, Module *M,
|
||||||
ParseError &Err, LLVMContext* Context) {
|
ParseError &Err, const LLVMContext& Context) {
|
||||||
Err.setFilename("<string>");
|
Err.setFilename("<string>");
|
||||||
|
|
||||||
OwningPtr<MemoryBuffer>
|
OwningPtr<MemoryBuffer>
|
||||||
|
@ -22,7 +22,7 @@ int LLVMParseBitcode(LLVMMemoryBufferRef MemBuf, LLVMContextRef ContextRef,
|
|||||||
LLVMModuleRef *OutModule, char **OutMessage) {
|
LLVMModuleRef *OutModule, char **OutMessage) {
|
||||||
std::string Message;
|
std::string Message;
|
||||||
|
|
||||||
*OutModule = wrap(ParseBitcodeFile(unwrap(MemBuf), unwrap(ContextRef),
|
*OutModule = wrap(ParseBitcodeFile(unwrap(MemBuf), *unwrap(ContextRef),
|
||||||
&Message));
|
&Message));
|
||||||
if (!*OutModule) {
|
if (!*OutModule) {
|
||||||
if (OutMessage)
|
if (OutMessage)
|
||||||
@ -42,7 +42,7 @@ int LLVMGetBitcodeModuleProvider(LLVMMemoryBufferRef MemBuf,
|
|||||||
char **OutMessage) {
|
char **OutMessage) {
|
||||||
std::string Message;
|
std::string Message;
|
||||||
|
|
||||||
*OutMP = wrap(getBitcodeModuleProvider(unwrap(MemBuf), unwrap(ContextRef),
|
*OutMP = wrap(getBitcodeModuleProvider(unwrap(MemBuf), *unwrap(ContextRef),
|
||||||
&Message));
|
&Message));
|
||||||
if (!*OutMP) {
|
if (!*OutMP) {
|
||||||
if (OutMessage)
|
if (OutMessage)
|
||||||
|
@ -2090,7 +2090,7 @@ Module *BitcodeReader::releaseModule(std::string *ErrInfo) {
|
|||||||
/// getBitcodeModuleProvider - lazy function-at-a-time loading from a file.
|
/// getBitcodeModuleProvider - lazy function-at-a-time loading from a file.
|
||||||
///
|
///
|
||||||
ModuleProvider *llvm::getBitcodeModuleProvider(MemoryBuffer *Buffer,
|
ModuleProvider *llvm::getBitcodeModuleProvider(MemoryBuffer *Buffer,
|
||||||
LLVMContext* Context,
|
const LLVMContext& Context,
|
||||||
std::string *ErrMsg) {
|
std::string *ErrMsg) {
|
||||||
BitcodeReader *R = new BitcodeReader(Buffer, Context);
|
BitcodeReader *R = new BitcodeReader(Buffer, Context);
|
||||||
if (R->ParseBitcode()) {
|
if (R->ParseBitcode()) {
|
||||||
@ -2107,7 +2107,7 @@ ModuleProvider *llvm::getBitcodeModuleProvider(MemoryBuffer *Buffer,
|
|||||||
|
|
||||||
/// ParseBitcodeFile - Read the specified bitcode file, returning the module.
|
/// ParseBitcodeFile - Read the specified bitcode file, returning the module.
|
||||||
/// If an error occurs, return null and fill in *ErrMsg if non-null.
|
/// 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){
|
std::string *ErrMsg){
|
||||||
BitcodeReader *R;
|
BitcodeReader *R;
|
||||||
R = static_cast<BitcodeReader*>(getBitcodeModuleProvider(Buffer, Context,
|
R = static_cast<BitcodeReader*>(getBitcodeModuleProvider(Buffer, Context,
|
||||||
|
@ -86,7 +86,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
class BitcodeReader : public ModuleProvider {
|
class BitcodeReader : public ModuleProvider {
|
||||||
LLVMContext* Context;
|
const LLVMContext& Context;
|
||||||
MemoryBuffer *Buffer;
|
MemoryBuffer *Buffer;
|
||||||
BitstreamReader StreamFile;
|
BitstreamReader StreamFile;
|
||||||
BitstreamCursor Stream;
|
BitstreamCursor Stream;
|
||||||
@ -125,7 +125,7 @@ class BitcodeReader : public ModuleProvider {
|
|||||||
/// stream) and what linkage the original function had.
|
/// stream) and what linkage the original function had.
|
||||||
DenseMap<Function*, std::pair<uint64_t, unsigned> > DeferredFunctionInfo;
|
DenseMap<Function*, std::pair<uint64_t, unsigned> > DeferredFunctionInfo;
|
||||||
public:
|
public:
|
||||||
explicit BitcodeReader(MemoryBuffer *buffer, LLVMContext* C)
|
explicit BitcodeReader(MemoryBuffer *buffer, const LLVMContext& C)
|
||||||
: Context(C), Buffer(buffer), ErrorString(0) {
|
: Context(C), Buffer(buffer), ErrorString(0) {
|
||||||
HasReversedFunctionsWithBodies = false;
|
HasReversedFunctionsWithBodies = false;
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,8 @@ std::string Debugger::getProgramPath() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Module *
|
static Module *
|
||||||
getMaterializedModuleProvider(const std::string &Filename, LLVMContext* C) {
|
getMaterializedModuleProvider(const std::string &Filename,
|
||||||
|
const LLVMContext& C) {
|
||||||
std::auto_ptr<MemoryBuffer> Buffer;
|
std::auto_ptr<MemoryBuffer> Buffer;
|
||||||
Buffer.reset(MemoryBuffer::getFileOrSTDIN(Filename.c_str()));
|
Buffer.reset(MemoryBuffer::getFileOrSTDIN(Filename.c_str()));
|
||||||
if (Buffer.get())
|
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
|
/// the PATH for the specified program, loading it when found. If the
|
||||||
/// specified program cannot be found, an exception is thrown to indicate the
|
/// specified program cannot be found, an exception is thrown to indicate the
|
||||||
/// error.
|
/// 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)) ||
|
if ((Program = getMaterializedModuleProvider(Filename, C)) ||
|
||||||
(Program = getMaterializedModuleProvider(Filename+".bc", C)))
|
(Program = getMaterializedModuleProvider(Filename+".bc", C)))
|
||||||
return; // Successfully loaded the program.
|
return; // Successfully loaded the program.
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
Linker::Linker(const std::string& progname, const std::string& modname,
|
Linker::Linker(const std::string& progname, const std::string& modname,
|
||||||
LLVMContext* C, unsigned flags):
|
const LLVMContext& C, unsigned flags):
|
||||||
Context(C),
|
Context(C),
|
||||||
Composite(new Module(modname, C)),
|
Composite(new Module(modname, C)),
|
||||||
LibPaths(),
|
LibPaths(),
|
||||||
|
@ -53,7 +53,7 @@ void LLVMContextDispose(LLVMContextRef C) {
|
|||||||
/*===-- Operations on modules ---------------------------------------------===*/
|
/*===-- Operations on modules ---------------------------------------------===*/
|
||||||
|
|
||||||
LLVMModuleRef LLVMModuleCreateWithName(const char *ModuleID, LLVMContextRef C) {
|
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) {
|
void LLVMDisposeModule(LLVMModuleRef M) {
|
||||||
|
@ -22,8 +22,8 @@ using namespace llvm;
|
|||||||
|
|
||||||
static ManagedStatic<LLVMContext> GlobalContext;
|
static ManagedStatic<LLVMContext> GlobalContext;
|
||||||
|
|
||||||
LLVMContext* getGlobalContext() {
|
const LLVMContext& llvm::getGlobalContext() {
|
||||||
return &*GlobalContext;
|
return *GlobalContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
LLVMContext::LLVMContext() : pImpl(new LLVMContextImpl()) { }
|
LLVMContext::LLVMContext() : pImpl(new LLVMContextImpl()) { }
|
||||||
|
@ -55,7 +55,7 @@ template class SymbolTableListTraits<GlobalAlias, Module>;
|
|||||||
// Primitive Module methods.
|
// 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("") {
|
: Context(C), ModuleID(MID), DataLayout("") {
|
||||||
ValSymTab = new ValueSymbolTable();
|
ValSymTab = new ValueSymbolTable();
|
||||||
TypeSymTab = new TypeSymbolTable();
|
TypeSymTab = new TypeSymbolTable();
|
||||||
|
@ -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,
|
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),
|
: Context(ctxt), ToolName(toolname), ReferenceOutputFile(OutputFile),
|
||||||
Program(0), Interpreter(0), SafeInterpreter(0), gcc(0),
|
Program(0), Interpreter(0), SafeInterpreter(0), gcc(0),
|
||||||
run_as_child(as_child), run_find_bugs(find_bugs), Timeout(timeout),
|
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
|
/// ParseInputFile - Given a bitcode or assembly input filename, parse and
|
||||||
/// return it, or return null if not possible.
|
/// 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));
|
std::auto_ptr<MemoryBuffer> Buffer(MemoryBuffer::getFileOrSTDIN(Filename));
|
||||||
Module *Result = 0;
|
Module *Result = 0;
|
||||||
if (Buffer.get())
|
if (Buffer.get())
|
||||||
|
@ -43,7 +43,7 @@ extern bool DisableSimplifyCFG;
|
|||||||
extern bool BugpointIsInterrupted;
|
extern bool BugpointIsInterrupted;
|
||||||
|
|
||||||
class BugDriver {
|
class BugDriver {
|
||||||
LLVMContext* Context;
|
const LLVMContext& Context;
|
||||||
const std::string ToolName; // Name of bugpoint
|
const std::string ToolName; // Name of bugpoint
|
||||||
std::string ReferenceOutputFile; // Name of `good' output file
|
std::string ReferenceOutputFile; // Name of `good' output file
|
||||||
Module *Program; // The raw program, linked together
|
Module *Program; // The raw program, linked together
|
||||||
@ -62,11 +62,11 @@ class BugDriver {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
BugDriver(const char *toolname, bool as_child, bool find_bugs,
|
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; }
|
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
|
// Set up methods... these methods are used to copy information about the
|
||||||
// command line arguments into instance variables of BugDriver.
|
// command line arguments into instance variables of BugDriver.
|
||||||
@ -294,7 +294,8 @@ private:
|
|||||||
/// ParseInputFile - Given a bitcode or assembly input filename, parse and
|
/// ParseInputFile - Given a bitcode or assembly input filename, parse and
|
||||||
/// return it, or return null if not possible.
|
/// 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
|
/// getPassesString - Turn a list of passes into a string which indicates the
|
||||||
|
@ -76,7 +76,7 @@ int main(int argc, char **argv) {
|
|||||||
sys::SetInterruptFunction(BugpointInterruptFunction);
|
sys::SetInterruptFunction(BugpointInterruptFunction);
|
||||||
|
|
||||||
LLVMContext Context;
|
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;
|
if (D.addSources(InputFilenames)) return 1;
|
||||||
D.addPasses(PassList.begin(), PassList.end());
|
D.addPasses(PassList.begin(), PassList.end());
|
||||||
|
|
||||||
|
@ -227,7 +227,7 @@ int main(int argc, char **argv) {
|
|||||||
std::auto_ptr<MemoryBuffer> Buffer(
|
std::auto_ptr<MemoryBuffer> Buffer(
|
||||||
MemoryBuffer::getFileOrSTDIN(InputFilename, &ErrorMessage));
|
MemoryBuffer::getFileOrSTDIN(InputFilename, &ErrorMessage));
|
||||||
if (Buffer.get())
|
if (Buffer.get())
|
||||||
M.reset(ParseBitcodeFile(Buffer.get(), &Context, &ErrorMessage));
|
M.reset(ParseBitcodeFile(Buffer.get(), Context, &ErrorMessage));
|
||||||
if (M.get() == 0) {
|
if (M.get() == 0) {
|
||||||
std::cerr << argv[0] << ": bitcode didn't read correctly.\n";
|
std::cerr << argv[0] << ": bitcode didn't read correctly.\n";
|
||||||
std::cerr << "Reason: " << ErrorMessage << "\n";
|
std::cerr << "Reason: " << ErrorMessage << "\n";
|
||||||
|
@ -107,7 +107,7 @@ int main(int argc, char **argv, char * const *envp) {
|
|||||||
std::string ErrorMsg;
|
std::string ErrorMsg;
|
||||||
ModuleProvider *MP = NULL;
|
ModuleProvider *MP = NULL;
|
||||||
if (MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(InputFile,&ErrorMsg)){
|
if (MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(InputFile,&ErrorMsg)){
|
||||||
MP = getBitcodeModuleProvider(Buffer, &Context, &ErrorMsg);
|
MP = getBitcodeModuleProvider(Buffer, Context, &ErrorMsg);
|
||||||
if (!MP) delete Buffer;
|
if (!MP) delete Buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -719,11 +719,11 @@ int main(int argc, char **argv) {
|
|||||||
// Produce a warning if we should and we're creating the archive
|
// Produce a warning if we should and we're creating the archive
|
||||||
if (!Create)
|
if (!Create)
|
||||||
std::cerr << argv[0] << ": creating " << ArchivePath.toString() << "\n";
|
std::cerr << argv[0] << ": creating " << ArchivePath.toString() << "\n";
|
||||||
TheArchive = Archive::CreateEmpty(ArchivePath, &Context);
|
TheArchive = Archive::CreateEmpty(ArchivePath, Context);
|
||||||
TheArchive->writeToDisk();
|
TheArchive->writeToDisk();
|
||||||
} else {
|
} else {
|
||||||
std::string Error;
|
std::string Error;
|
||||||
TheArchive = Archive::OpenAndLoad(ArchivePath, &Context, &Error);
|
TheArchive = Archive::OpenAndLoad(ArchivePath, Context, &Error);
|
||||||
if (TheArchive == 0) {
|
if (TheArchive == 0) {
|
||||||
std::cerr << argv[0] << ": error loading '" << ArchivePath << "': "
|
std::cerr << argv[0] << ": error loading '" << ArchivePath << "': "
|
||||||
<< Error << "!\n";
|
<< Error << "!\n";
|
||||||
|
@ -65,7 +65,7 @@ int main(int argc, char **argv) {
|
|||||||
try {
|
try {
|
||||||
// Parse the file now...
|
// Parse the file now...
|
||||||
ParseError Err;
|
ParseError Err;
|
||||||
std::auto_ptr<Module> M(ParseAssemblyFile(InputFilename, Err, &Context));
|
std::auto_ptr<Module> M(ParseAssemblyFile(InputFilename, Err, Context));
|
||||||
if (M.get() == 0) {
|
if (M.get() == 0) {
|
||||||
Err.PrintError(argv[0], errs());
|
Err.PrintError(argv[0], errs());
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -22,7 +22,7 @@ using namespace llvm;
|
|||||||
/// CLIDebugger constructor - This initializes the debugger to its default
|
/// CLIDebugger constructor - This initializes the debugger to its default
|
||||||
/// state, and initializes the command table.
|
/// state, and initializes the command table.
|
||||||
///
|
///
|
||||||
CLIDebugger::CLIDebugger(LLVMContext* ctxt)
|
CLIDebugger::CLIDebugger(const LLVMContext& ctxt)
|
||||||
: Context(ctxt), TheProgramInfo(0), TheRuntimeInfo(0),
|
: Context(ctxt), TheProgramInfo(0), TheRuntimeInfo(0),
|
||||||
Prompt("(llvm-db) "), ListSize(10) {
|
Prompt("(llvm-db) "), ListSize(10) {
|
||||||
// Initialize instance variables
|
// Initialize instance variables
|
||||||
|
@ -29,7 +29,7 @@ namespace llvm {
|
|||||||
/// CLIDebugger - This class implements the command line interface for the
|
/// CLIDebugger - This class implements the command line interface for the
|
||||||
/// LLVM debugger.
|
/// LLVM debugger.
|
||||||
class CLIDebugger {
|
class CLIDebugger {
|
||||||
LLVMContext* Context;
|
const LLVMContext& Context;
|
||||||
|
|
||||||
/// Dbg - The low-level LLVM debugger object that we use to do our dirty
|
/// Dbg - The low-level LLVM debugger object that we use to do our dirty
|
||||||
/// work.
|
/// work.
|
||||||
@ -82,7 +82,7 @@ namespace llvm {
|
|||||||
const SourceLanguage *CurrentLanguage;
|
const SourceLanguage *CurrentLanguage;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CLIDebugger(LLVMContext* ctxt);
|
CLIDebugger(const LLVMContext& ctxt);
|
||||||
|
|
||||||
/// getDebugger - Return the current LLVM debugger implementation being
|
/// getDebugger - Return the current LLVM debugger implementation being
|
||||||
/// used.
|
/// used.
|
||||||
|
@ -70,7 +70,7 @@ int main(int argc, char **argv, char * const *envp) {
|
|||||||
InputArgs.push_back(InputFile);
|
InputArgs.push_back(InputFile);
|
||||||
|
|
||||||
// Create the CLI debugger...
|
// Create the CLI debugger...
|
||||||
CLIDebugger D(&Context);
|
CLIDebugger D(Context);
|
||||||
|
|
||||||
// Initialize the debugger with the command line options we read...
|
// Initialize the debugger with the command line options we read...
|
||||||
Debugger &Dbg = D.getDebugger();
|
Debugger &Dbg = D.getDebugger();
|
||||||
|
@ -63,7 +63,7 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
if (MemoryBuffer *Buffer
|
if (MemoryBuffer *Buffer
|
||||||
= MemoryBuffer::getFileOrSTDIN(InputFilename, &ErrorMessage)) {
|
= MemoryBuffer::getFileOrSTDIN(InputFilename, &ErrorMessage)) {
|
||||||
M.reset(ParseBitcodeFile(Buffer, &Context, &ErrorMessage));
|
M.reset(ParseBitcodeFile(Buffer, Context, &ErrorMessage));
|
||||||
delete Buffer;
|
delete Buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ int main(int argc, char **argv) {
|
|||||||
cerr << argv[0] << ": Error reading file '" + InputFilename + "'\n";
|
cerr << argv[0] << ": Error reading file '" + InputFilename + "'\n";
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
M.reset(ParseBitcodeFile(Buffer, &Context));
|
M.reset(ParseBitcodeFile(Buffer, Context));
|
||||||
}
|
}
|
||||||
delete Buffer;
|
delete Buffer;
|
||||||
|
|
||||||
|
@ -517,7 +517,7 @@ int main(int argc, char **argv, char **envp) {
|
|||||||
cl::ParseCommandLineOptions(argc, argv, "llvm linker\n");
|
cl::ParseCommandLineOptions(argc, argv, "llvm linker\n");
|
||||||
|
|
||||||
// Construct a Linker (now that Verbose is set)
|
// 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)
|
// Keep track of the native link items (versus the bitcode items)
|
||||||
Linker::ItemList NativeLinkItems;
|
Linker::ItemList NativeLinkItems;
|
||||||
|
@ -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...
|
// 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) {
|
const LLVMContext& Context) {
|
||||||
sys::Path Filename;
|
sys::Path Filename;
|
||||||
if (!Filename.set(FN)) {
|
if (!Filename.set(FN)) {
|
||||||
cerr << "Invalid file name: '" << FN << "'\n";
|
cerr << "Invalid file name: '" << FN << "'\n";
|
||||||
@ -93,7 +93,7 @@ int main(int argc, char **argv) {
|
|||||||
unsigned BaseArg = 0;
|
unsigned BaseArg = 0;
|
||||||
std::string ErrorMessage;
|
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) {
|
if (Composite.get() == 0) {
|
||||||
cerr << argv[0] << ": error loading file '"
|
cerr << argv[0] << ": error loading file '"
|
||||||
<< InputFilenames[BaseArg] << "'\n";
|
<< InputFilenames[BaseArg] << "'\n";
|
||||||
@ -101,7 +101,7 @@ int main(int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (unsigned i = BaseArg+1; i < InputFilenames.size(); ++i) {
|
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) {
|
if (M.get() == 0) {
|
||||||
cerr << argv[0] << ": error loading file '" <<InputFilenames[i]<< "'\n";
|
cerr << argv[0] << ": error loading file '" <<InputFilenames[i]<< "'\n";
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -142,7 +142,7 @@ static void DumpSymbolNamesFromFile(std::string &Filename) {
|
|||||||
MemoryBuffer::getFileOrSTDIN(Filename, &ErrorMessage));
|
MemoryBuffer::getFileOrSTDIN(Filename, &ErrorMessage));
|
||||||
Module *Result = 0;
|
Module *Result = 0;
|
||||||
if (Buffer.get())
|
if (Buffer.get())
|
||||||
Result = ParseBitcodeFile(Buffer.get(), &Context, &ErrorMessage);
|
Result = ParseBitcodeFile(Buffer.get(), Context, &ErrorMessage);
|
||||||
|
|
||||||
if (Result)
|
if (Result)
|
||||||
DumpSymbolNamesFromModule(Result);
|
DumpSymbolNamesFromModule(Result);
|
||||||
@ -153,7 +153,7 @@ static void DumpSymbolNamesFromFile(std::string &Filename) {
|
|||||||
|
|
||||||
} else if (aPath.isArchive()) {
|
} else if (aPath.isArchive()) {
|
||||||
std::string ErrMsg;
|
std::string ErrMsg;
|
||||||
Archive* archive = Archive::OpenAndLoad(sys::Path(Filename), &Context,
|
Archive* archive = Archive::OpenAndLoad(sys::Path(Filename), Context,
|
||||||
&ErrorMessage);
|
&ErrorMessage);
|
||||||
if (!archive)
|
if (!archive)
|
||||||
std::cerr << ToolName << ": " << Filename << ": " << ErrorMessage << "\n";
|
std::cerr << ToolName << ": " << Filename << ": " << ErrorMessage << "\n";
|
||||||
|
@ -127,7 +127,7 @@ int main(int argc, char **argv) {
|
|||||||
Module *M = 0;
|
Module *M = 0;
|
||||||
if (MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(BitcodeFile,
|
if (MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(BitcodeFile,
|
||||||
&ErrorMessage)) {
|
&ErrorMessage)) {
|
||||||
M = ParseBitcodeFile(Buffer, &Context, &ErrorMessage);
|
M = ParseBitcodeFile(Buffer, Context, &ErrorMessage);
|
||||||
delete Buffer;
|
delete Buffer;
|
||||||
}
|
}
|
||||||
if (M == 0) {
|
if (M == 0) {
|
||||||
|
@ -75,7 +75,7 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
std::string err_msg;
|
std::string err_msg;
|
||||||
std::auto_ptr<Archive>
|
std::auto_ptr<Archive>
|
||||||
AutoArchive(Archive::OpenAndLoad(ArchivePath, &Context, &err_msg));
|
AutoArchive(Archive::OpenAndLoad(ArchivePath, Context, &err_msg));
|
||||||
Archive* TheArchive = AutoArchive.get();
|
Archive* TheArchive = AutoArchive.get();
|
||||||
if (!TheArchive)
|
if (!TheArchive)
|
||||||
throw err_msg;
|
throw err_msg;
|
||||||
|
@ -69,8 +69,8 @@ const char* LTOCodeGenerator::getVersionString()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LTOCodeGenerator::LTOCodeGenerator()
|
LTOCodeGenerator::LTOCodeGenerator(const LLVMContext& Context)
|
||||||
: _context(new LLVMContext()),
|
: _context(Context),
|
||||||
_linker("LinkTimeOptimizer", "ld-temp.o", _context), _target(NULL),
|
_linker("LinkTimeOptimizer", "ld-temp.o", _context), _target(NULL),
|
||||||
_emitDwarfDebugInfo(false), _scopeRestrictionsDone(false),
|
_emitDwarfDebugInfo(false), _scopeRestrictionsDone(false),
|
||||||
_codeModel(LTO_CODEGEN_PIC_MODEL_DYNAMIC),
|
_codeModel(LTO_CODEGEN_PIC_MODEL_DYNAMIC),
|
||||||
|
@ -31,7 +31,7 @@ class LTOCodeGenerator {
|
|||||||
public:
|
public:
|
||||||
static const char* getVersionString();
|
static const char* getVersionString();
|
||||||
|
|
||||||
LTOCodeGenerator();
|
LTOCodeGenerator(const llvm::LLVMContext& Context);
|
||||||
~LTOCodeGenerator();
|
~LTOCodeGenerator();
|
||||||
|
|
||||||
bool addModule(class LTOModule*, std::string& errMsg);
|
bool addModule(class LTOModule*, std::string& errMsg);
|
||||||
@ -54,7 +54,7 @@ private:
|
|||||||
|
|
||||||
typedef llvm::StringMap<uint8_t> StringSet;
|
typedef llvm::StringMap<uint8_t> StringSet;
|
||||||
|
|
||||||
llvm::LLVMContext* _context;
|
const llvm::LLVMContext& _context;
|
||||||
llvm::Linker _linker;
|
llvm::Linker _linker;
|
||||||
llvm::TargetMachine* _target;
|
llvm::TargetMachine* _target;
|
||||||
bool _emitDwarfDebugInfo;
|
bool _emitDwarfDebugInfo;
|
||||||
|
@ -69,7 +69,7 @@ bool LTOModule::isBitcodeFileForTarget(const char* path,
|
|||||||
bool LTOModule::isTargetMatch(MemoryBuffer* buffer, const char* triplePrefix)
|
bool LTOModule::isTargetMatch(MemoryBuffer* buffer, const char* triplePrefix)
|
||||||
{
|
{
|
||||||
OwningPtr<ModuleProvider> mp(getBitcodeModuleProvider(buffer,
|
OwningPtr<ModuleProvider> mp(getBitcodeModuleProvider(buffer,
|
||||||
new LLVMContext()));
|
*new LLVMContext()));
|
||||||
// on success, mp owns buffer and both are deleted at end of this method
|
// on success, mp owns buffer and both are deleted at end of this method
|
||||||
if ( !mp ) {
|
if ( !mp ) {
|
||||||
delete buffer;
|
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)
|
std::string& errMsg)
|
||||||
{
|
{
|
||||||
OwningPtr<MemoryBuffer> buffer(MemoryBuffer::getFile(path, &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,
|
LTOModule* LTOModule::makeLTOModule(const void* mem, size_t length,
|
||||||
LLVMContext* Context,
|
const LLVMContext& Context,
|
||||||
std::string& errMsg)
|
std::string& errMsg)
|
||||||
{
|
{
|
||||||
OwningPtr<MemoryBuffer> buffer(makeBuffer(mem, length));
|
OwningPtr<MemoryBuffer> buffer(makeBuffer(mem, length));
|
||||||
@ -140,7 +141,8 @@ std::string getFeatureString(const char *TargetTriple) {
|
|||||||
return Features.getString();
|
return Features.getString();
|
||||||
}
|
}
|
||||||
|
|
||||||
LTOModule* LTOModule::makeLTOModule(MemoryBuffer* buffer, LLVMContext* Context,
|
LTOModule* LTOModule::makeLTOModule(MemoryBuffer* buffer,
|
||||||
|
const LLVMContext& Context,
|
||||||
std::string& errMsg)
|
std::string& errMsg)
|
||||||
{
|
{
|
||||||
// parse bitcode buffer
|
// parse bitcode buffer
|
||||||
|
@ -52,10 +52,10 @@ public:
|
|||||||
const char* triplePrefix);
|
const char* triplePrefix);
|
||||||
|
|
||||||
static LTOModule* makeLTOModule(const char* path,
|
static LTOModule* makeLTOModule(const char* path,
|
||||||
llvm::LLVMContext* Context,
|
const llvm::LLVMContext& Context,
|
||||||
std::string& errMsg);
|
std::string& errMsg);
|
||||||
static LTOModule* makeLTOModule(const void* mem, size_t length,
|
static LTOModule* makeLTOModule(const void* mem, size_t length,
|
||||||
llvm::LLVMContext* Context,
|
const llvm::LLVMContext& Context,
|
||||||
std::string& errMsg);
|
std::string& errMsg);
|
||||||
|
|
||||||
const char* getTargetTriple();
|
const char* getTargetTriple();
|
||||||
@ -91,7 +91,7 @@ private:
|
|||||||
const char* triplePrefix);
|
const char* triplePrefix);
|
||||||
|
|
||||||
static LTOModule* makeLTOModule(llvm::MemoryBuffer* buffer,
|
static LTOModule* makeLTOModule(llvm::MemoryBuffer* buffer,
|
||||||
llvm::LLVMContext* Context,
|
const llvm::LLVMContext& Context,
|
||||||
std::string& errMsg);
|
std::string& errMsg);
|
||||||
static llvm::MemoryBuffer* makeBuffer(const void* mem, size_t length);
|
static llvm::MemoryBuffer* makeBuffer(const void* mem, size_t length);
|
||||||
|
|
||||||
|
@ -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)
|
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);
|
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,
|
lto_module_t lto_module_create_from_memory(const void* mem, size_t length,
|
||||||
LLVMContextRef Ctxt)
|
LLVMContextRef Ctxt)
|
||||||
{
|
{
|
||||||
return LTOModule::makeLTOModule(mem, length, llvm::unwrap(Ctxt),
|
return LTOModule::makeLTOModule(mem, length, *llvm::unwrap(Ctxt),
|
||||||
sLastErrorString);
|
sLastErrorString);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,9 +158,9 @@ lto_symbol_attributes lto_module_get_symbol_attribute(lto_module_t mod,
|
|||||||
// instantiates a code generator
|
// instantiates a code generator
|
||||||
// returns NULL if there is an error
|
// 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)
|
lto_codegen_debug_options(lto_code_gen_t cg, const char * opt)
|
||||||
{
|
{
|
||||||
cg->setCodeGenDebugOptions(opt);
|
cg->setCodeGenDebugOptions(opt);
|
||||||
}
|
}
|
@ -327,7 +327,7 @@ int main(int argc, char **argv) {
|
|||||||
std::auto_ptr<Module> M;
|
std::auto_ptr<Module> M;
|
||||||
if (MemoryBuffer *Buffer
|
if (MemoryBuffer *Buffer
|
||||||
= MemoryBuffer::getFileOrSTDIN(InputFilename, &ErrorMessage)) {
|
= MemoryBuffer::getFileOrSTDIN(InputFilename, &ErrorMessage)) {
|
||||||
M.reset(ParseBitcodeFile(Buffer, &Context, &ErrorMessage));
|
M.reset(ParseBitcodeFile(Buffer, Context, &ErrorMessage));
|
||||||
delete Buffer;
|
delete Buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ struct RecordingJITEventListener : public JITEventListener {
|
|||||||
class JITEventListenerTest : public testing::Test {
|
class JITEventListenerTest : public testing::Test {
|
||||||
protected:
|
protected:
|
||||||
JITEventListenerTest()
|
JITEventListenerTest()
|
||||||
: M(new Module("module", new LLVMContext())),
|
: M(new Module("module", *new LLVMContext())),
|
||||||
EE(ExecutionEngine::createJIT(new ExistingModuleProvider(M))) {
|
EE(ExecutionEngine::createJIT(new ExistingModuleProvider(M))) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -272,7 +272,7 @@ namespace llvm {
|
|||||||
char OnTheFlyTest::ID=0;
|
char OnTheFlyTest::ID=0;
|
||||||
|
|
||||||
TEST(PassManager, RunOnce) {
|
TEST(PassManager, RunOnce) {
|
||||||
Module M("test-once", new LLVMContext());
|
Module M("test-once", *new LLVMContext());
|
||||||
struct ModuleNDNM *mNDNM = new ModuleNDNM();
|
struct ModuleNDNM *mNDNM = new ModuleNDNM();
|
||||||
struct ModuleDNM *mDNM = new ModuleDNM();
|
struct ModuleDNM *mDNM = new ModuleDNM();
|
||||||
struct ModuleNDM *mNDM = new ModuleNDM();
|
struct ModuleNDM *mNDM = new ModuleNDM();
|
||||||
@ -296,7 +296,7 @@ namespace llvm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(PassManager, ReRun) {
|
TEST(PassManager, ReRun) {
|
||||||
Module M("test-rerun", new LLVMContext());
|
Module M("test-rerun", *new LLVMContext());
|
||||||
struct ModuleNDNM *mNDNM = new ModuleNDNM();
|
struct ModuleNDNM *mNDNM = new ModuleNDNM();
|
||||||
struct ModuleDNM *mDNM = new ModuleDNM();
|
struct ModuleDNM *mDNM = new ModuleDNM();
|
||||||
struct ModuleNDM *mNDM = new ModuleNDM();
|
struct ModuleNDM *mNDM = new ModuleNDM();
|
||||||
@ -387,7 +387,7 @@ namespace llvm {
|
|||||||
|
|
||||||
Module* makeLLVMModule() {
|
Module* makeLLVMModule() {
|
||||||
// Module Construction
|
// 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-"
|
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-"
|
"i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-"
|
||||||
"a0:0:64-s0:64:64-f80:128:128");
|
"a0:0:64-s0:64:64-f80:128:128");
|
||||||
|
Loading…
Reference in New Issue
Block a user