summaryrefslogtreecommitdiff
path: root/tools/lli
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2008-04-22 06:51:41 +0000
committerEvan Cheng <evan.cheng@apple.com>2008-04-22 06:51:41 +0000
commitc290a5b9ffa6ade5a02e9d8c46fc521a5b71529e (patch)
treec27135aae8d583984cfd32a9de73c0339b3b8491 /tools/lli
parentd38c14e6ed0136624a18cf8338c82f1709d804aa (diff)
downloadllvm-c290a5b9ffa6ade5a02e9d8c46fc521a5b71529e.tar.gz
llvm-c290a5b9ffa6ade5a02e9d8c46fc521a5b71529e.tar.bz2
llvm-c290a5b9ffa6ade5a02e9d8c46fc521a5b71529e.tar.xz
Added command line option -no-lazy to disable JIT lazy compilation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50095 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/lli')
-rw-r--r--tools/lli/lli.cpp38
1 files changed, 30 insertions, 8 deletions
diff --git a/tools/lli/lli.cpp b/tools/lli/lli.cpp
index 1013651ffa..5d34d9f1dd 100644
--- a/tools/lli/lli.cpp
+++ b/tools/lli/lli.cpp
@@ -52,6 +52,11 @@ namespace {
cl::opt<bool>
DisableCoreFiles("disable-core-files", cl::Hidden,
cl::desc("Disable emission of core files if possible"));
+
+ cl::opt<bool>
+ NoLazyCompilation("no-lazy",
+ cl::desc("Disable JIT lazy compilation"),
+ cl::init(false));
}
static ExecutionEngine *EE = 0;
@@ -76,8 +81,8 @@ int main(int argc, char **argv, char * const *envp) {
// Load the bitcode...
std::string ErrorMsg;
- ModuleProvider *MP = 0;
- if (MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(InputFile,&ErrorMsg)){
+ ModuleProvider *MP = NULL;
+ if (MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(InputFile,&ErrorMsg)) {
MP = getBitcodeModuleProvider(Buffer, &ErrorMsg);
if (!MP) delete Buffer;
}
@@ -89,18 +94,27 @@ int main(int argc, char **argv, char * const *envp) {
}
// Get the module as the MP could go away once EE takes over.
- Module *Mod = MP->getModule();
+ Module *Mod = NoLazyCompilation
+ ? MP->materializeModule(&ErrorMsg) : MP->getModule();
+ if (!Mod) {
+ std::cerr << argv[0] << ": bitcode didn't read correctly.\n";
+ std::cerr << "Reason: " << ErrorMsg << "\n";
+ exit(1);
+ }
// If we are supposed to override the target triple, do so now.
if (!TargetTriple.empty())
Mod->setTargetTriple(TargetTriple);
-
+
EE = ExecutionEngine::create(MP, ForceInterpreter, &ErrorMsg);
if (!EE && !ErrorMsg.empty()) {
std::cerr << argv[0] << ":error creating EE: " << ErrorMsg << "\n";
exit(1);
}
+ if (NoLazyCompilation)
+ EE->DisableLazyCompilation();
+
// If the user specifically requested an argv[0] to pass into the program,
// do it now.
if (!FakeArgv0.empty()) {
@@ -120,8 +134,8 @@ int main(int argc, char **argv, char * const *envp) {
// using the contents of Args to determine argc & argv, and the contents of
// EnvVars to determine envp.
//
- Function *Fn = Mod->getFunction("main");
- if (!Fn) {
+ Function *MainFn = Mod->getFunction("main");
+ if (!MainFn) {
std::cerr << "'main' function not found in module.\n";
return -1;
}
@@ -136,9 +150,17 @@ int main(int argc, char **argv, char * const *envp) {
// Run static constructors.
EE->runStaticConstructorsDestructors(false);
-
+
+ if (NoLazyCompilation) {
+ for (Module::iterator I = Mod->begin(), E = Mod->end(); I != E; ++I) {
+ Function *Fn = &*I;
+ if (Fn != MainFn && !Fn->isDeclaration())
+ EE->getPointerToFunction(Fn);
+ }
+ }
+
// Run main.
- int Result = EE->runFunctionAsMain(Fn, InputArgv, envp);
+ int Result = EE->runFunctionAsMain(MainFn, InputArgv, envp);
// Run static destructors.
EE->runStaticConstructorsDestructors(true);