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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@65896 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/bugpoint/ToolRunner.cpp b/tools/bugpoint/ToolRunner.cpp
index f6a151c..7c669ef 100644
--- a/tools/bugpoint/ToolRunner.cpp
+++ b/tools/bugpoint/ToolRunner.cpp
@@ -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);
 }