[llvm-commits] CVS: llvm/tools/lli/lli.cpp

Chris Lattner lattner at cs.uiuc.edu
Wed Mar 8 10:43:49 PST 2006



Changes in directory llvm/tools/lli:

lli.cpp updated: 1.54 -> 1.55
---
Log message:

Fit to 80 columns.
Add support for running static ctor/dtors that aren't handled by __main.
This fixes programs with the JIT and the new CFE, such as HBD.


---
Diffs of the changes:  (+14 -7)

 lli.cpp |   21 ++++++++++++++-------
 1 files changed, 14 insertions(+), 7 deletions(-)


Index: llvm/tools/lli/lli.cpp
diff -u llvm/tools/lli/lli.cpp:1.54 llvm/tools/lli/lli.cpp:1.55
--- llvm/tools/lli/lli.cpp:1.54	Thu Dec 15 23:19:18 2005
+++ llvm/tools/lli/lli.cpp	Wed Mar  8 12:43:36 2006
@@ -60,7 +60,8 @@
     try {
       MP = getBytecodeModuleProvider(InputFile);
     } catch (std::string &err) {
-      std::cerr << "Error loading program '" << InputFile << "': " << err << "\n";
+      std::cerr << "Error loading program '" << InputFile << "': "
+                << err << "\n";
       exit(1);
     }
 
@@ -69,10 +70,10 @@
       MP->getModule()->setTargetTriple(TargetTriple);
     
     ExecutionEngine *EE = ExecutionEngine::create(MP, ForceInterpreter);
-    assert(EE && "Couldn't create an ExecutionEngine, not even an interpreter?");
+    assert(EE &&"Couldn't create an ExecutionEngine, not even an interpreter?");
 
-    // If the user specifically requested an argv[0] to pass into the program, do
-    // it now.
+    // If the user specifically requested an argv[0] to pass into the program,
+    // do it now.
     if (!FakeArgv0.empty()) {
       InputFile = FakeArgv0;
     } else {
@@ -96,11 +97,17 @@
       return -1;
     }
 
-    // Run main...
+    // Run static constructors.
+    EE->runStaticConstructorsDestructors(false);
+    
+    // Run main.
     int Result = EE->runFunctionAsMain(Fn, InputArgv, envp);
 
-    // If the program didn't explicitly call exit, call exit now, for the program.
-    // This ensures that any atexit handlers get called correctly.
+    // Run static destructors.
+    EE->runStaticConstructorsDestructors(true);
+    
+    // If the program didn't explicitly call exit, call exit now, for the
+    // program. This ensures that any atexit handlers get called correctly.
     Function *Exit = MP->getModule()->getOrInsertFunction("exit", Type::VoidTy,
                                                           Type::IntTy,
                                                           (Type *)0);






More information about the llvm-commits mailing list