[vmkit-commits] [vmkit] r80243 - in /vmkit/trunk: lib/Mvm/Compiler/EscapeAnalysis.cpp lib/N3/VMCore/CLIJit.cpp lib/N3/VMCore/CLIJit.h tools/llcj/llcj.cpp tools/vmjc/vmjc.cpp tools/vmkit/Launcher.cpp

Nicolas Geoffray nicolas.geoffray at lip6.fr
Thu Aug 27 06:38:58 PDT 2009


Author: geoffray
Date: Thu Aug 27 08:38:57 2009
New Revision: 80243

URL: http://llvm.org/viewvc/llvm-project?rev=80243&view=rev
Log:
Fix includes and use of streams.


Modified:
    vmkit/trunk/lib/Mvm/Compiler/EscapeAnalysis.cpp
    vmkit/trunk/lib/N3/VMCore/CLIJit.cpp
    vmkit/trunk/lib/N3/VMCore/CLIJit.h
    vmkit/trunk/tools/llcj/llcj.cpp
    vmkit/trunk/tools/vmjc/vmjc.cpp
    vmkit/trunk/tools/vmkit/Launcher.cpp

Modified: vmkit/trunk/lib/Mvm/Compiler/EscapeAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Compiler/EscapeAnalysis.cpp?rev=80243&r1=80242&r2=80243&view=diff

==============================================================================
--- vmkit/trunk/lib/Mvm/Compiler/EscapeAnalysis.cpp (original)
+++ vmkit/trunk/lib/Mvm/Compiler/EscapeAnalysis.cpp Thu Aug 27 08:38:57 2009
@@ -196,7 +196,7 @@
   // The object does not have a finalizer and is never used. Remove the
   // allocation as it will not have side effects.
   if (!hasFinalizer && !Alloc->getNumUses()) {
-    DOUT << "Escape analysis removes instruction " << *Alloc << ": ";
+    DEBUG(errs() << "Escape analysis removes instruction " << *Alloc << ": ");
     Alloc->eraseFromParent();
     return true;
   }
@@ -214,8 +214,9 @@
         // we don't end up with tons of allocations on the stack.
         BasicBlock* BB = CurLoop->getLoopPreheader();
         assert(BB && "No Preheader!");
-        DOUT << "Escape analysis hoisting to " << BB->getNameStr() << ": ";
-        DOUT << *Alloc;
+        DEBUG(errs() << "Escape analysis hoisting to " << BB->getNameStr());
+        DEBUG(errs() << ": ");
+        DEBUG(errs() << *Alloc);
         Alloc->removeFromParent();
         BB->getInstList().insert(BB->getTerminator(), Alloc);
       }
@@ -223,7 +224,8 @@
       AllocaInst* AI = new AllocaInst(Type::getInt8Ty(Context), Size, "",
                                       Alloc);
       BitCastInst* BI = new BitCastInst(AI, Alloc->getType(), "", Alloc);
-      DOUT << "escape" << Alloc->getParent()->getParent()->getNameStr() << "\n";
+      DEBUG(errs() << "escape");
+      DEBUG(errs() << Alloc->getParent()->getParent()->getNameStr() << "\n");
       Alloc->replaceAllUsesWith(BI);
       // If it's an invoke, replace the invoke with a direct branch.
       if (InvokeInst *CI = dyn_cast<InvokeInst>(Alloc)) {

Modified: vmkit/trunk/lib/N3/VMCore/CLIJit.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/CLIJit.cpp?rev=80243&r1=80242&r2=80243&view=diff

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/CLIJit.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/CLIJit.cpp Thu Aug 27 08:38:57 2009
@@ -11,20 +11,7 @@
 #define N3_COMPILE 0
 #define N3_EXECUTE 0
 
-#include "debug.h"
-#include "types.h"
 
-#include "llvm/CallingConv.h"
-#include <llvm/Constants.h>
-#include <llvm/DerivedTypes.h>
-#include <llvm/Function.h>
-#include <llvm/Instructions.h>
-#include <llvm/LinkAllPasses.h>
-#include <llvm/Module.h>
-#include <llvm/Type.h>
-#include <llvm/Analysis/LoopPass.h>
-#include <llvm/Support/CFG.h>
-#include <llvm/Support/MutexGuard.h>
 
 
 
@@ -44,6 +31,21 @@
 #include "VMClass.h"
 #include "VMThread.h"
 
+#include <llvm/CallingConv.h>
+#include <llvm/Constants.h>
+#include <llvm/DerivedTypes.h>
+#include <llvm/Function.h>
+#include <llvm/Instructions.h>
+#include <llvm/LinkAllPasses.h>
+#include <llvm/Module.h>
+#include <llvm/Type.h>
+#include <llvm/Analysis/LoopPass.h>
+#include <llvm/Support/CFG.h>
+#include <llvm/Support/MutexGuard.h>
+
+#include "debug.h"
+#include "types.h"
+
 using namespace llvm;
 using namespace n3;
 

Modified: vmkit/trunk/lib/N3/VMCore/CLIJit.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/CLIJit.h?rev=80243&r1=80242&r2=80243&view=diff

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/CLIJit.h (original)
+++ vmkit/trunk/lib/N3/VMCore/CLIJit.h Thu Aug 27 08:38:57 2009
@@ -19,11 +19,11 @@
 #include "llvm/DerivedTypes.h"
 #include "llvm/Function.h"
 #include "llvm/Instructions.h"
+#include "llvm/PassManager.h"
+#include "llvm/Type.h"
 #include "llvm/ExecutionEngine/ExecutionEngine.h"
 #include "llvm/ExecutionEngine/GenericValue.h"
-#include "llvm/PassManager.h"
 #include "llvm/Target/TargetData.h"
-#include "llvm/Type.h"
 
 #include "types.h"
 

Modified: vmkit/trunk/tools/llcj/llcj.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/tools/llcj/llcj.cpp?rev=80243&r1=80242&r2=80243&view=diff

==============================================================================
--- vmkit/trunk/tools/llcj/llcj.cpp (original)
+++ vmkit/trunk/tools/llcj/llcj.cpp Thu Aug 27 08:38:57 2009
@@ -131,10 +131,10 @@
   Out.appendComponent(className);
   Out.appendSuffix("bc");
   
-  vmjcArgv[0] = Prog.toString().c_str();
+  vmjcArgv[0] = Prog.c_str();
   vmjcArgv[vmjcArgc++] = "-f";
   vmjcArgv[vmjcArgc++] = "-o";
-  vmjcArgv[vmjcArgc++] = Out.toString().c_str();
+  vmjcArgv[vmjcArgc++] = Out.c_str();
 
   res = sys::Program::ExecuteAndWait(Prog, vmjcArgv);
 
@@ -151,11 +151,11 @@
     }
     
     const char* optArgv[7];
-    optArgv[0] = Prog.toString().c_str();
-    optArgv[1] = Out.toString().c_str();
+    optArgv[0] = Prog.c_str();
+    optArgv[1] = Out.c_str();
     optArgv[2] = "-f";
     optArgv[3] = "-o";
-    optArgv[4] = OptOut.toString().c_str();
+    optArgv[4] = OptOut.c_str();
     if (opt) {
       optArgv[5] = opt;
       optArgv[6] = 0;
@@ -187,13 +187,13 @@
     
     const char* llcArgv[8];
     int i = 0;
-    llcArgv[i++] = Prog.toString().c_str();
-    llcArgv[i++] = Out.toString().c_str();
+    llcArgv[i++] = Prog.c_str();
+    llcArgv[i++] = Out.c_str();
     if (shared) llcArgv[i++] = "-relocation-model=pic";
     llcArgv[i++] = "-disable-fp-elim";
     llcArgv[i++] = "-f";
     llcArgv[i++] = "-o";
-    llcArgv[i++] = LlcOut.toString().c_str();
+    llcArgv[i++] = LlcOut.c_str();
     llcArgv[i++] = 0;
   
     res = sys::Program::ExecuteAndWait(Prog, llcArgv);
@@ -208,8 +208,8 @@
       goto cleanup;
     }
 
-    gccArgv[0] = Prog.toString().c_str();
-    gccArgv[gccArgc++] = Out.toString().c_str();
+    gccArgv[0] = Prog.c_str();
+    gccArgv[gccArgc++] = Out.c_str();
     gccArgv[gccArgc++] = LLVMLibs;
     gccArgv[gccArgc++] = VMKITLibs1;
     gccArgv[gccArgc++] = VMKITLibs2;

Modified: vmkit/trunk/tools/vmjc/vmjc.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/tools/vmjc/vmjc.cpp?rev=80243&r1=80242&r2=80243&view=diff

==============================================================================
--- vmkit/trunk/tools/vmjc/vmjc.cpp (original)
+++ vmkit/trunk/tools/vmjc/vmjc.cpp Thu Aug 27 08:38:57 2009
@@ -30,7 +30,6 @@
 #include "llvm/Support/PassNameParser.h"
 #include "llvm/Support/PluginLoader.h"
 #include "llvm/Support/RegistryParser.h"
-#include "llvm/Support/Streams.h"
 #include "llvm/Support/SystemUtils.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/System/Signals.h"
@@ -75,7 +74,7 @@
 WithJIT("with-jit", cl::desc("Generate main function with JIT support"));
 
 static cl::opt<bool>
-DontPrint("disable-output", cl::desc("Don't output the .ll file"), cl::Hidden);
+DisableOutput("disable-output", cl::desc("Disable output"), cl::init(false));
 
 
 // The OptimizationList is automatically populated with registered Passes by the
@@ -146,12 +145,12 @@
     if (PassInf->getNormalCtor())
       P = PassInf->getNormalCtor()();
     else
-      cerr << argv[0] << ": cannot create pass: "
+      errs() << argv[0] << ": cannot create pass: "
            << PassInf->getPassName() << "\n";
     if (P) {
         bool isModulePass = dynamic_cast<ModulePass*>(P) != 0;
         if (isModulePass) 
-          cerr << argv[0] << ": vmkit does not support module pass: "
+          errs() << argv[0] << ": vmkit does not support module pass: "
              << PassInf->getPassName() << "\n";
         else addPass(Passes, P);
 
@@ -173,7 +172,6 @@
     cl::ParseCommandLineOptions(argc, argv, "vmkit .class -> .ll compiler\n");
     sys::PrintStackTraceOnErrorSignal();
 
-    std::ostream *Out = &std::cout;  // Default to printing to stdout.
     std::string ErrorMessage;
 
     
@@ -275,63 +273,48 @@
     if (PrintStats)
       Comp->printStats();
 
-    if (DontPrint) {
-      // Just use stdout.  We won't actually print anything on it.
-    } else if (OutputFilename != "") {   // Specified an output filename?
-      if (OutputFilename != "-") { // Not stdout?
-        if (!Force && std::ifstream(OutputFilename.c_str())) {
-          // If force is not specified, make sure not to overwrite a file!
-          cerr << argv[0] << ": error opening '" << OutputFilename
-               << "': file exists! Sending to standard output.\n";
-        } else {
-          Out = new std::ofstream(OutputFilename.c_str());
-        }
-      }
-    } else {
+    // Infer the output filename if needed.
+    if (OutputFilename.empty()) {
       if (InputFilename == "-") {
         OutputFilename = "-";
       } else {
         std::string IFN = InputFilename;
         int Len = IFN.length();
-        if (IFN[Len-3] == '.' && IFN[Len-2] == 'b' && IFN[Len-1] == 'c') {
-          // Source ends in .bc
-          OutputFilename = std::string(IFN.begin(), IFN.end()-3)+".bc";
+        if (IFN[Len-3] == '.' && IFN[Len-2] == 'l' && IFN[Len-1] == 'l') {
+          // Source ends in .ll
+          OutputFilename = std::string(IFN.begin(), IFN.end()-3);
         } else {
-          OutputFilename = IFN+".bc";
-        }
-
-        if (!Force && std::ifstream(OutputFilename.c_str())) {
-          // If force is not specified, make sure not to overwrite a file!
-          cerr << argv[0] << ": error opening '" << OutputFilename
-               << "': file exists! Sending to standard output.\n";
-        } else {
-          Out = new std::ofstream(OutputFilename.c_str());
-
-          // Make sure that the Out file gets unlinked from the disk if we get a
-          // SIGINT
-          sys::RemoveFileOnSignal(sys::Path(OutputFilename));
-        }
-      }
+          OutputFilename = IFN;   // Append a .bc to it
+        }   
+        OutputFilename += ".bc";
+      }   
     }
-
-    if (!Out->good()) {
-      cerr << argv[0] << ": error opening " << OutputFilename
-           << ": sending to stdout instead!\n";
-      Out = &std::cout;
+  
+    std::string ErrorInfo;
+    std::auto_ptr<raw_ostream> Out 
+    (new raw_fd_ostream(OutputFilename.c_str(), ErrorInfo,
+                        raw_fd_ostream::F_Binary));
+    if (!ErrorInfo.empty()) {
+      errs() << ErrorInfo << '\n';
+      return 1;
     }
-    
-    if (Force || !CheckBitcodeOutputToConsole(Out,true))
-      WriteBitcodeToFile(Comp->getLLVMModule(), *Out);
+  
+  
+    // Make sure that the Out file gets unlinked from the disk if we get a
+    // SIGINT.
+    if (OutputFilename != "-")
+      sys::RemoveFileOnSignal(sys::Path(OutputFilename));
+
+    if (!DisableOutput)
+      if (Force || !CheckBitcodeOutputToConsole(*Out, true))
+        WriteBitcodeToFile(Comp->getLLVMModule(), *Out);
 
-    if (Out != &std::cout) {
-      ((std::ofstream*)Out)->close();
-      delete Out;
-    }
     return 0;
+
   } catch (const std::string& msg) {
-    cerr << argv[0] << ": " << msg << "\n";
+    errs() << argv[0] << ": " << msg << "\n";
   } catch (...) {
-    cerr << argv[0] << ": Unexpected unknown exception occurred.\n";
+    errs() << argv[0] << ": Unexpected unknown exception occurred.\n";
   }
   return 1;
 }

Modified: vmkit/trunk/tools/vmkit/Launcher.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/tools/vmkit/Launcher.cpp?rev=80243&r1=80242&r2=80243&view=diff

==============================================================================
--- vmkit/trunk/tools/vmkit/Launcher.cpp (original)
+++ vmkit/trunk/tools/vmkit/Launcher.cpp Thu Aug 27 08:38:57 2009
@@ -90,12 +90,12 @@
     if (PassInf->getNormalCtor())
       P = PassInf->getNormalCtor()();
     else
-      cerr << argv[0] << ": cannot create pass: "
+      errs() << argv[0] << ": cannot create pass: "
            << PassInf->getPassName() << "\n";
     if (P) {
         bool isModulePass = dynamic_cast<ModulePass*>(P) != 0;
         if (isModulePass) 
-          cerr << argv[0] << ": vmkit does not support module pass: "
+          errs() << argv[0] << ": vmkit does not support module pass: "
              << PassInf->getPassName() << "\n";
         else addPass(Passes, P);
 





More information about the vmkit-commits mailing list