From c4fb6fdd8677530d9b1db34b6254edb0094b78ed Mon Sep 17 00:00:00 2001 From: Misha Brukman Date: Tue, 14 Oct 2003 21:39:53 +0000 Subject: Enabling incremental bytecode loading in the JIT: * Use the incremental bytecode reader interface to speed up execution git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9127 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/lli/lli.cpp | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'tools') diff --git a/tools/lli/lli.cpp b/tools/lli/lli.cpp index 0283b5da8c..5bd19fc901 100644 --- a/tools/lli/lli.cpp +++ b/tools/lli/lli.cpp @@ -11,6 +11,7 @@ #include "llvm/DerivedTypes.h" #include "llvm/Module.h" +#include "llvm/ModuleProvider.h" #include "llvm/Bytecode/Reader.h" #include "llvm/ExecutionEngine/ExecutionEngine.h" #include "llvm/ExecutionEngine/GenericValue.h" @@ -18,6 +19,7 @@ #include "llvm/Target/TargetData.h" #include "Support/CommandLine.h" #include "Support/Debug.h" +#include "Support/SystemUtils.h" namespace { cl::opt @@ -37,7 +39,7 @@ namespace { cl::init(false)); } -static std::vector makeStringVector(const char **envp) { +static std::vector makeStringVector(char * const *envp) { std::vector rv; for (unsigned i = 0; envp[i]; ++i) rv.push_back(envp[i]); @@ -92,10 +94,11 @@ static void *CreateArgv(ExecutionEngine *EE, /// from calling FnName, or -1 and prints an error msg. if the named /// function cannot be found. /// -int callAsMain(ExecutionEngine *EE, Module *M, const std::string &FnName, +int callAsMain(ExecutionEngine *EE, ModuleProvider *MP, + const std::string &FnName, const std::vector &Args, const std::vector &EnvVars) { - Function *Fn = M->getNamedFunction(FnName); + Function *Fn = MP->getModule()->getNamedFunction(FnName); if (!Fn) { std::cerr << "Function '" << FnName << "' not found in module.\n"; return -1; @@ -112,21 +115,22 @@ int callAsMain(ExecutionEngine *EE, Module *M, const std::string &FnName, //===----------------------------------------------------------------------===// // main Driver function // -int main(int argc, char **argv, const char **envp) { +int main(int argc, char **argv, char * const *envp) { cl::ParseCommandLineOptions(argc, argv, " llvm interpreter & dynamic compiler\n"); // Load the bytecode... std::string ErrorMsg; - Module *M = ParseBytecodeFile(InputFile, &ErrorMsg); - if (M == 0) { - std::cout << "Error parsing '" << InputFile << "': " - << ErrorMsg << "\n"; + ModuleProvider *MP = 0; + try { + MP = getBytecodeModuleProvider(InputFile); + } catch (std::string &err) { + std::cerr << "Error parsing '" << InputFile << "': " << err << "\n"; exit(1); } ExecutionEngine *EE = - ExecutionEngine::create(M, ForceInterpreter, TraceMode); + ExecutionEngine::create(MP, ForceInterpreter, TraceMode); assert(EE && "Couldn't create an ExecutionEngine, not even an interpreter?"); // Add the module's name to the start of the vector of arguments to main(). @@ -135,12 +139,12 @@ int main(int argc, char **argv, const char **envp) { const std::string ByteCodeFileSuffix(".bc"); if (InputFile.rfind(ByteCodeFileSuffix) == InputFile.length() - ByteCodeFileSuffix.length()) { - InputFile.erase(InputFile.length() - ByteCodeFileSuffix.length()); + InputFile.erase (InputFile.length() - ByteCodeFileSuffix.length()); } InputArgv.insert(InputArgv.begin(), InputFile); // Run the main function! - int ExitCode = callAsMain(EE, M, MainFunction, InputArgv, + int ExitCode = callAsMain(EE, MP, MainFunction, InputArgv, makeStringVector(envp)); // Now that we are done executing the program, shut down the execution engine -- cgit v1.2.3