[llvm-commits] [llvm] r65896 - in /llvm/trunk/tools/bugpoint: ExecutionDriver.cpp ToolRunner.cpp ToolRunner.h

Bill Wendling isanbard at gmail.com
Mon Mar 2 15:13:18 PST 2009


Author: void
Date: Mon Mar  2 17:13:18 2009
New Revision: 65896

URL: http://llvm.org/viewvc/llvm-project?rev=65896&view=rev
Log:
Add a "-gcc-tool-args" option. This option acts like the "-tool-args" option,
but passes the arguments to the "gcc" invocation instead of to the "llc"
invocation.

Modified:
    llvm/trunk/tools/bugpoint/ExecutionDriver.cpp
    llvm/trunk/tools/bugpoint/ToolRunner.cpp
    llvm/trunk/tools/bugpoint/ToolRunner.h

Modified: llvm/trunk/tools/bugpoint/ExecutionDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/bugpoint/ExecutionDriver.cpp?rev=65896&r1=65895&r2=65896&view=diff

==============================================================================
--- llvm/trunk/tools/bugpoint/ExecutionDriver.cpp (original)
+++ llvm/trunk/tools/bugpoint/ExecutionDriver.cpp Mon Mar  2 17:13:18 2009
@@ -111,6 +111,11 @@
   SafeToolArgv("safe-tool-args", cl::Positional,
                cl::desc("<safe-tool arguments>..."),
                cl::ZeroOrMore, cl::PositionalEatsArgs);
+
+  cl::list<std::string>
+  GCCToolArgv("gcc-tool-args", cl::Positional,
+              cl::desc("<gcc-tool arguments>..."),
+              cl::ZeroOrMore, cl::PositionalEatsArgs);
 }
 
 //===----------------------------------------------------------------------===//
@@ -132,7 +137,8 @@
   case AutoPick:
     InterpreterSel = RunCBE;
     Interpreter =
-      AbstractInterpreter::createCBE(getToolName(), Message, &ToolArgv);
+      AbstractInterpreter::createCBE(getToolName(), Message, &ToolArgv,
+                                     &GCCToolArgv);
     if (!Interpreter) {
       InterpreterSel = RunJIT;
       Interpreter = AbstractInterpreter::createJIT(getToolName(), Message,
@@ -141,7 +147,7 @@
     if (!Interpreter) {
       InterpreterSel = RunLLC;
       Interpreter = AbstractInterpreter::createLLC(getToolName(), Message,
-                                                   &ToolArgv);
+                                                   &ToolArgv, &GCCToolArgv);
     }
     if (!Interpreter) {
       InterpreterSel = RunLLI;
@@ -160,7 +166,7 @@
   case RunLLC:
   case LLC_Safe:
     Interpreter = AbstractInterpreter::createLLC(getToolName(), Message,
-                                                 &ToolArgv);
+                                                 &ToolArgv, &GCCToolArgv);
     break;
   case RunJIT:
     Interpreter = AbstractInterpreter::createJIT(getToolName(), Message,
@@ -169,7 +175,7 @@
   case RunCBE:
   case CBE_bug:
     Interpreter = AbstractInterpreter::createCBE(getToolName(), Message,
-                                                 &ToolArgv);
+                                                 &ToolArgv, &GCCToolArgv);
     break;
   case Custom:
     Interpreter = AbstractInterpreter::createCustom(getToolName(), Message,
@@ -196,7 +202,8 @@
       SafeInterpreterSel = RunLLC;
       SafeToolArgs.push_back("--relocation-model=pic");
       SafeInterpreter = AbstractInterpreter::createLLC(Path, Message,
-                                                       &SafeToolArgs);
+                                                       &SafeToolArgs,
+                                                       &GCCToolArgv);
     }
 
     // In "llc-safe" mode, default to using LLC as the "safe" backend.
@@ -205,7 +212,8 @@
       SafeInterpreterSel = RunLLC;
       SafeToolArgs.push_back("--relocation-model=pic");
       SafeInterpreter = AbstractInterpreter::createLLC(Path, Message,
-                                                       &SafeToolArgs);
+                                                       &SafeToolArgs,
+                                                       &GCCToolArgv);
     }
 
     // Pick a backend that's different from the test backend. The JIT and
@@ -215,7 +223,8 @@
         InterpreterSel != RunCBE) {
       SafeInterpreterSel = RunCBE;
       SafeInterpreter = AbstractInterpreter::createCBE(Path, Message,
-                                                       &SafeToolArgs);
+                                                       &SafeToolArgs,
+                                                       &GCCToolArgv);
     }
     if (!SafeInterpreter &&
         InterpreterSel != RunLLC &&
@@ -223,7 +232,8 @@
       SafeInterpreterSel = RunLLC;
       SafeToolArgs.push_back("--relocation-model=pic");
       SafeInterpreter = AbstractInterpreter::createLLC(Path, Message,
-                                                       &SafeToolArgs);
+                                                       &SafeToolArgs,
+                                                       &GCCToolArgv);
     }
     if (!SafeInterpreter) {
       SafeInterpreterSel = AutoPick;
@@ -233,11 +243,13 @@
   case RunLLC:
     SafeToolArgs.push_back("--relocation-model=pic");
     SafeInterpreter = AbstractInterpreter::createLLC(Path, Message,
-                                                     &SafeToolArgs);
+                                                     &SafeToolArgs,
+                                                     &GCCToolArgv);
     break;
   case RunCBE:
     SafeInterpreter = AbstractInterpreter::createCBE(Path, Message,
-                                                     &SafeToolArgs);
+                                                     &SafeToolArgs,
+                                                     &GCCToolArgv);
     break;
   case Custom:
     SafeInterpreter = AbstractInterpreter::createCustom(Path, Message,
@@ -250,7 +262,7 @@
   }
   if (!SafeInterpreter) { std::cout << Message << "\nExiting.\n"; exit(1); }
   
-  gcc = GCC::create(getToolName(), Message);
+  gcc = GCC::create(getToolName(), Message, &GCCToolArgv);
   if (!gcc) { std::cout << Message << "\nExiting.\n"; exit(1); }
 
   // If there was an error creating the selected interpreter, quit with error.
@@ -406,7 +418,7 @@
   }
   try {
     ReferenceOutputFile = executeProgramSafely(Filename);
-    std::cout << "Reference output is: " << ReferenceOutputFile << "\n\n";
+    std::cout << "\nReference output is: " << ReferenceOutputFile << "\n\n";
   } catch (ToolExecutionError &TEE) {
     std::cerr << TEE.what();
     if (Interpreter != SafeInterpreter) {

Modified: llvm/trunk/tools/bugpoint/ToolRunner.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/bugpoint/ToolRunner.cpp?rev=65896&r1=65895&r2=65896&view=diff

==============================================================================
--- llvm/trunk/tools/bugpoint/ToolRunner.cpp (original)
+++ llvm/trunk/tools/bugpoint/ToolRunner.cpp Mon Mar  2 17:13:18 2009
@@ -344,7 +344,8 @@
   FileRemover OutFileRemover(OutputAsmFile);
 
   std::vector<std::string> GCCArgs(ArgsForGCC);
-  GCCArgs.insert(GCCArgs.end(),SharedLibs.begin(),SharedLibs.end());
+  GCCArgs.insert(GCCArgs.end(), SharedLibs.begin(), SharedLibs.end());
+  GCCArgs.insert(GCCArgs.end(), gccArgs.begin(), gccArgs.end());
 
   // Assuming LLC worked, compile the result with GCC and run it.
   return gcc->ExecuteProgram(OutputAsmFile.toString(), Args, GCC::AsmFile,
@@ -356,7 +357,8 @@
 ///
 LLC *AbstractInterpreter::createLLC(const std::string &ProgramPath,
                                     std::string &Message,
-                                    const std::vector<std::string> *Args) {
+                                    const std::vector<std::string> *Args,
+                                    const std::vector<std::string> *GCCArgs) {
   std::string LLCPath = FindExecutable("llc", ProgramPath).toString();
   if (LLCPath.empty()) {
     Message = "Cannot find `llc' in executable directory or PATH!\n";
@@ -364,12 +366,12 @@
   }
 
   Message = "Found llc: " + LLCPath + "\n";
-  GCC *gcc = GCC::create(ProgramPath, Message);
+  GCC *gcc = GCC::create(ProgramPath, Message, GCCArgs);
   if (!gcc) {
     std::cerr << Message << "\n";
     exit(1);
   }
-  return new LLC(LLCPath, gcc, Args);
+  return new LLC(LLCPath, gcc, Args, GCCArgs);
 }
 
 //===---------------------------------------------------------------------===//
@@ -509,7 +511,8 @@
   FileRemover CFileRemove(OutputCFile);
 
   std::vector<std::string> GCCArgs(ArgsForGCC);
-  GCCArgs.insert(GCCArgs.end(),SharedLibs.begin(),SharedLibs.end());
+  GCCArgs.insert(GCCArgs.end(), SharedLibs.begin(), SharedLibs.end());
+
   return gcc->ExecuteProgram(OutputCFile.toString(), Args, GCC::CFile,
                              InputFile, OutputFile, GCCArgs,
                              Timeout, MemoryLimit);
@@ -519,7 +522,8 @@
 ///
 CBE *AbstractInterpreter::createCBE(const std::string &ProgramPath,
                                     std::string &Message,
-                                    const std::vector<std::string> *Args) {
+                                    const std::vector<std::string> *Args,
+                                    const std::vector<std::string> *GCCArgs) {
   sys::Path LLCPath = FindExecutable("llc", ProgramPath);
   if (LLCPath.isEmpty()) {
     Message =
@@ -528,7 +532,7 @@
   }
 
   Message = "Found llc: " + LLCPath.toString() + "\n";
-  GCC *gcc = GCC::create(ProgramPath, Message);
+  GCC *gcc = GCC::create(ProgramPath, Message, GCCArgs);
   if (!gcc) {
     std::cerr << Message << "\n";
     exit(1);
@@ -551,6 +555,10 @@
 
   GCCArgs.push_back(GCCPath.c_str());
 
+  for (std::vector<std::string>::const_iterator
+         I = gccArgs.begin(), E = gccArgs.end(); I != E; ++I)
+    GCCArgs.push_back(I->c_str());
+
   // Specify -x explicitly in case the extension is wonky
   GCCArgs.push_back("-x");
   if (fileType == CFile) {
@@ -725,7 +733,8 @@
 
 /// create - Try to find the `gcc' executable
 ///
-GCC *GCC::create(const std::string &ProgramPath, std::string &Message) {
+GCC *GCC::create(const std::string &ProgramPath, std::string &Message,
+                 const std::vector<std::string> *Args) {
   sys::Path GCCPath = FindExecutable("gcc", ProgramPath);
   if (GCCPath.isEmpty()) {
     Message = "Cannot find `gcc' in executable directory or PATH!\n";
@@ -737,5 +746,5 @@
     RemoteClientPath = FindExecutable(RemoteClient.c_str(), ProgramPath);
 
   Message = "Found gcc: " + GCCPath.toString() + "\n";
-  return new GCC(GCCPath, RemoteClientPath);
+  return new GCC(GCCPath, RemoteClientPath, Args);
 }

Modified: llvm/trunk/tools/bugpoint/ToolRunner.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/bugpoint/ToolRunner.h?rev=65896&r1=65895&r2=65896&view=diff

==============================================================================
--- llvm/trunk/tools/bugpoint/ToolRunner.h (original)
+++ llvm/trunk/tools/bugpoint/ToolRunner.h Mon Mar  2 17:13:18 2009
@@ -43,14 +43,19 @@
 // GCC abstraction
 //
 class GCC {
-  sys::Path GCCPath;          // The path to the gcc executable
-  sys::Path RemoteClientPath; // The path to the rsh / ssh executable
-  GCC(const sys::Path &gccPath, const sys::Path &RemotePath)
-    : GCCPath(gccPath), RemoteClientPath(RemotePath) { }
+  sys::Path GCCPath;                // The path to the gcc executable.
+  sys::Path RemoteClientPath;       // The path to the rsh / ssh executable.
+  std::vector<std::string> gccArgs; // GCC-specific arguments.
+  GCC(const sys::Path &gccPath, const sys::Path &RemotePath,
+      const std::vector<std::string> *GCCArgs)
+    : GCCPath(gccPath), RemoteClientPath(RemotePath) {
+    if (GCCArgs) gccArgs = *GCCArgs;
+  }
 public:
   enum FileType { AsmFile, CFile };
 
-  static GCC *create(const std::string &ProgramPath, std::string &Message);
+  static GCC *create(const std::string &ProgramPath, std::string &Message,
+                     const std::vector<std::string> *Args);
 
   /// ExecuteProgram - Execute the program specified by "ProgramFile" (which is
   /// either a .s file, or a .c file, specified by FileType), with the specified
@@ -86,9 +91,11 @@
 class AbstractInterpreter {
 public:
   static CBE *createCBE(const std::string &ProgramPath, std::string &Message,
-                        const std::vector<std::string> *Args = 0);
+                        const std::vector<std::string> *Args = 0,
+                        const std::vector<std::string> *GCCArgs = 0);
   static LLC *createLLC(const std::string &ProgramPath, std::string &Message,
-                        const std::vector<std::string> *Args = 0);
+                        const std::vector<std::string> *Args = 0,
+                        const std::vector<std::string> *GCCArgs = 0);
 
   static AbstractInterpreter* createLLI(const std::string &ProgramPath,
                                         std::string &Message,
@@ -139,14 +146,15 @@
 // CBE Implementation of AbstractIntepreter interface
 //
 class CBE : public AbstractInterpreter {
-  sys::Path LLCPath;          // The path to the `llc' executable
-  std::vector<std::string> ToolArgs; // Extra args to pass to LLC
+  sys::Path LLCPath;                 // The path to the `llc' executable.
+  std::vector<std::string> ToolArgs; // Extra args to pass to LLC.
   GCC *gcc;
 public:
   CBE(const sys::Path &llcPath, GCC *Gcc,
-      const std::vector<std::string> *Args) : LLCPath(llcPath), gcc(Gcc) {
+      const std::vector<std::string> *Args)
+    : LLCPath(llcPath), gcc(Gcc) {
     ToolArgs.clear ();
-    if (Args) { ToolArgs = *Args; }
+    if (Args) ToolArgs = *Args;
   }
   ~CBE() { delete gcc; }
 
@@ -180,14 +188,18 @@
 // LLC Implementation of AbstractIntepreter interface
 //
 class LLC : public AbstractInterpreter {
-  std::string LLCPath;          // The path to the LLC executable
-  std::vector<std::string> ToolArgs; // Extra args to pass to LLC
+  std::string LLCPath;               // The path to the LLC executable.
+  std::vector<std::string> ToolArgs; // Extra args to pass to LLC.
+  std::vector<std::string> gccArgs;  // Extra args to pass to GCC.
   GCC *gcc;
 public:
   LLC(const std::string &llcPath, GCC *Gcc,
-    const std::vector<std::string> *Args) : LLCPath(llcPath), gcc(Gcc) {
-    ToolArgs.clear ();
-    if (Args) { ToolArgs = *Args; }
+      const std::vector<std::string> *Args,
+      const std::vector<std::string> *GCCArgs)
+    : LLCPath(llcPath), gcc(Gcc) {
+    ToolArgs.clear();
+    if (Args) ToolArgs = *Args;
+    if (GCCArgs) gccArgs = *GCCArgs;
   }
   ~LLC() { delete gcc; }
 





More information about the llvm-commits mailing list