[llvm-commits] CVS: llvm/tools/llvmc/CompilerDriver.cpp CompilerDriver.h

Reid Spencer reid at x10sys.com
Mon Aug 16 00:06:48 PDT 2004



Changes in directory llvm/tools/llvmc:

CompilerDriver.cpp updated: 1.4 -> 1.5
CompilerDriver.h updated: 1.4 -> 1.5
---
Log message:

Back out dependencies on lib/System/Path.h


---
Diffs of the changes:  (+32 -26)

Index: llvm/tools/llvmc/CompilerDriver.cpp
diff -u llvm/tools/llvmc/CompilerDriver.cpp:1.4 llvm/tools/llvmc/CompilerDriver.cpp:1.5
--- llvm/tools/llvmc/CompilerDriver.cpp:1.4	Sun Aug 15 03:19:46 2004
+++ llvm/tools/llvmc/CompilerDriver.cpp	Mon Aug 16 02:06:38 2004
@@ -70,8 +70,19 @@
     std::cerr << "Linker: ";
     DumpAction(&cd->Linker);
   }
-}
 
+  void CleanupTempFile(const char* fname) {
+    if (0 == access(fname, F_OK | R_OK))
+      unlink(fname);
+  }
+
+  /// This specifies the passes to run for OPT_FAST_COMPILE (-O1)
+  /// which should reduce the volume of code and make compilation
+  /// faster. This is also safe on any llvm module. 
+  static const char* DefaultOptimizations[] = {
+    "-simplifycfg", "-mem2reg", "-mergereturn", "-instcombine",
+  };
+}
 
 CompilerDriver::CompilerDriver(ConfigDataProvider& confDatProv )
   : cdp(&confDatProv)
@@ -215,7 +226,7 @@
 }
 
 int CompilerDriver::execute(const InputList& InpList, 
-                            const sys::Path& Output ) {
+                            const std::string& Output ) {
   // Echo the configuration of options if we're running verbose
   if (isDebug)
   {
@@ -248,12 +259,15 @@
   std::vector<Action*> actions;
 
   // Create a temporary directory for our temporary files
-  sys::Path TempDir(sys::Path::CONSTRUCT_TEMP_DIR);
-  sys::Path TempPreprocessorOut;
-  sys::Path TempTranslatorOut;
-  sys::Path TempOptimizerOut;
-  sys::Path TempAssemblerOut;
-  sys::Path TempLinkerOut;
+  char temp_name[64];
+  strcpy(temp_name,"/tmp/llvm_XXXXXX");
+  if (0 == mkdtemp(temp_name))
+      error("Can't create temporary directory");
+  std::string TempDir(temp_name);
+  std::string TempPreprocessorOut(TempDir + "/preproc.tmp");
+  std::string TempTranslatorOut(TempDir + "/trans.tmp");
+  std::string TempOptimizerOut(TempDir + "/opt.tmp");
+  std::string TempAssemblerOut(TempDir + "/asm.tmp");
 
   /// PRE-PROCESSING / TRANSLATION / OPTIMIZATION / ASSEMBLY phases
   // for each input item
@@ -304,8 +318,6 @@
     // Get the preprocessing action, if needed, or error if appropriate
     if (!a.program.empty()) {
       if (a.isSet(REQUIRED_FLAG) || finalPhase == PREPROCESSING) {
-        TempPreprocessorOut = TempDir;
-        TempPreprocessorOut.append_file("preproc.out");
         actions.push_back(GetAction(cd,I->first,
               TempPreprocessorOut,PREPROCESSING));
       }
@@ -324,8 +336,6 @@
     // Get the translation action, if needed, or error if appropriate
     if (!a.program.empty()) {
       if (a.isSet(REQUIRED_FLAG) || finalPhase == TRANSLATION) {
-        TempTranslatorOut = TempDir;
-        TempTranslatorOut.append_file("trans.out");
         actions.push_back(GetAction(cd,I->first,TempTranslatorOut,TRANSLATION));
       }
     } else if (finalPhase == TRANSLATION) {
@@ -342,8 +352,6 @@
 
     // Get the optimization action, if needed, or error if appropriate
     if (!a.program.empty()) {
-      TempOptimizerOut = TempDir;
-      TempOptimizerOut.append_file("trans.out");
       actions.push_back(GetAction(cd,I->first,TempOptimizerOut,OPTIMIZATION));
     } else if (finalPhase == OPTIMIZATION) {
       error(cd->langName + " does not support optimization");
@@ -367,14 +375,13 @@
   }
 
   // Cleanup files
-  if (TempPreprocessorOut.exists())
-    TempPreprocessorOut.remove_file();
-  if (TempTranslatorOut.exists())
-    TempTranslatorOut.remove_file();
-  if (TempOptimizerOut.exists())
-    TempOptimizerOut.remove_file();
-  if (TempDir.exists())
-    TempDir.remove_directory();
+  CleanupTempFile(TempPreprocessorOut.c_str());
+  CleanupTempFile(TempTranslatorOut.c_str());
+  CleanupTempFile(TempOptimizerOut.c_str());
+
+  // Cleanup temporary directory we created
+  if (0 == access(TempDir.c_str(), F_OK | W_OK))
+    rmdir(TempDir.c_str());
 
   return 0;
 }


Index: llvm/tools/llvmc/CompilerDriver.h
diff -u llvm/tools/llvmc/CompilerDriver.h:1.4 llvm/tools/llvmc/CompilerDriver.h:1.5
--- llvm/tools/llvmc/CompilerDriver.h:1.4	Sun Aug 15 03:19:46 2004
+++ llvm/tools/llvmc/CompilerDriver.h	Mon Aug 16 02:06:38 2004
@@ -14,7 +14,6 @@
 #ifndef LLVM_TOOLS_LLVMC_COMPILERDRIVER_H
 #define LLVM_TOOLS_LLVMC_COMPILERDRIVER_H
 
-#include "llvm/System/Path.h"
 #include <string>
 #include <vector>
 
@@ -66,7 +65,7 @@
       /// a vector of filename/filetype pairs. The filetype is used to look up
       /// the configuration of the actions to be taken by the driver.
       /// @brief The Input Data to the execute method
-      typedef std::vector<std::pair<sys::Path,std::string> > InputList;
+      typedef std::vector<std::pair<std::string,std::string> > InputList;
 
       /// This type is read from configuration files or otherwise provided to
       /// the CompilerDriver through a "ConfigDataProvider". It serves as both
@@ -75,7 +74,7 @@
       /// language.
       struct Action {
         Action() : inputAt(0) , outputAt(0), flags(0) {}
-        sys::Path program;     ///< The program to execve
+        std::string program;   ///< The program to execve
         StringVector args;     ///< Arguments to the program
         size_t inputAt;        ///< Argument index to insert input file
         size_t outputAt;       ///< Argument index to insert output file
@@ -122,7 +121,7 @@
       virtual void error(const std::string& errmsg);
 
       /// @brief Execute the actions requested for the given input list.
-      virtual int execute(const InputList& list, const sys::Path& output);
+      virtual int execute(const InputList& list, const std::string& output);
 
     /// @}
     /// @name Mutators






More information about the llvm-commits mailing list