Push bound architecture name into Compilation::getArgsForToolChain.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81365 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/Driver/Compilation.h b/include/clang/Driver/Compilation.h
index 9e026b9..56786a7 100644
--- a/include/clang/Driver/Compilation.h
+++ b/include/clang/Driver/Compilation.h
@@ -47,7 +47,8 @@
   JobList Jobs;
 
   /// Cache of translated arguments for a particular tool chain.
-  llvm::DenseMap<const ToolChain*, DerivedArgList*> TCArgs;
+  llvm::DenseMap<std::pair<const ToolChain*, const char*>,
+                 DerivedArgList*> TCArgs;
 
   /// Temporary files which should be removed on exit.
   ArgStringList TempFiles;
@@ -79,7 +80,10 @@
   /// getArgsForToolChain - Return the derived argument list for the
   /// tool chain \arg TC (or the default tool chain, if TC is not
   /// specified).
-  const DerivedArgList &getArgsForToolChain(const ToolChain *TC = 0);
+  ///
+  /// \param BoundArch - The bound architecture name, or 0.
+  const DerivedArgList &getArgsForToolChain(const ToolChain *TC,
+                                            const char *BoundArch);
 
   /// addTempFile - Add a file to remove on exit, and returns its
   /// argument.
diff --git a/include/clang/Driver/Driver.h b/include/clang/Driver/Driver.h
index c18d9e0..d05d319 100644
--- a/include/clang/Driver/Driver.h
+++ b/include/clang/Driver/Driver.h
@@ -229,6 +229,7 @@
   void BuildJobsForAction(Compilation &C,
                           const Action *A,
                           const ToolChain *TC,
+                          const char *BoundArch,
                           bool CanAcceptPipe,
                           bool AtTopLevel,
                           const char *LinkingOutput,
diff --git a/lib/Driver/Compilation.cpp b/lib/Driver/Compilation.cpp
index ad3cb8d..f6e1885 100644
--- a/lib/Driver/Compilation.cpp
+++ b/lib/Driver/Compilation.cpp
@@ -31,8 +31,9 @@
   delete Args;
 
   // Free any derived arg lists.
-  for (llvm::DenseMap<const ToolChain*, DerivedArgList*>::iterator
-         it = TCArgs.begin(), ie = TCArgs.end(); it != ie; ++it)
+  for (llvm::DenseMap<std::pair<const ToolChain*, const char*>,
+                      DerivedArgList*>::iterator it = TCArgs.begin(),
+         ie = TCArgs.end(); it != ie; ++it)
     delete it->second;
 
   // Free the actions, if built.
@@ -41,11 +42,12 @@
     delete *it;
 }
 
-const DerivedArgList &Compilation::getArgsForToolChain(const ToolChain *TC) {
+const DerivedArgList &Compilation::getArgsForToolChain(const ToolChain *TC,
+                                                       const char *BoundArch) {
   if (!TC)
     TC = &DefaultToolChain;
 
-  DerivedArgList *&Entry = TCArgs[TC];
+  DerivedArgList *&Entry = TCArgs[std::make_pair(TC, BoundArch)];
   if (!Entry)
     Entry = TC->TranslateArgs(*Args);
 
diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp
index 24f462f..7a0527d 100644
--- a/lib/Driver/Driver.cpp
+++ b/lib/Driver/Driver.cpp
@@ -948,6 +948,7 @@
 
     InputInfo II;
     BuildJobsForAction(C, A, &C.getDefaultToolChain(),
+                       /*BoundArch*/0,
                        /*CanAcceptPipe*/ true,
                        /*AtTopLevel*/ true,
                        /*LinkingOutput*/ LinkingOutput,
@@ -1001,6 +1002,7 @@
 void Driver::BuildJobsForAction(Compilation &C,
                                 const Action *A,
                                 const ToolChain *TC,
+                                const char *BoundArch,
                                 bool CanAcceptPipe,
                                 bool AtTopLevel,
                                 const char *LinkingOutput,
@@ -1032,8 +1034,8 @@
     if (BAA->getArchName())
       TC = Host->CreateToolChain(C.getArgs(), BAA->getArchName());
 
-    BuildJobsForAction(C, *BAA->begin(), TC, CanAcceptPipe, AtTopLevel,
-                       LinkingOutput, Result);
+    BuildJobsForAction(C, *BAA->begin(), TC, BAA->getArchName(),
+                       CanAcceptPipe, AtTopLevel, LinkingOutput, Result);
     return;
   }
 
@@ -1061,10 +1063,8 @@
   for (ActionList::const_iterator it = Inputs->begin(), ie = Inputs->end();
        it != ie; ++it) {
     InputInfo II;
-    BuildJobsForAction(C, *it, TC, TryToUsePipeInput,
-                       /*AtTopLevel*/false,
-                       LinkingOutput,
-                       II);
+    BuildJobsForAction(C, *it, TC, BoundArch, TryToUsePipeInput,
+                       /*AtTopLevel*/false, LinkingOutput, II);
     InputInfos.push_back(II);
   }
 
@@ -1125,7 +1125,7 @@
     llvm::errs() << "], output: " << Result.getAsString() << "\n";
   } else {
     T.ConstructJob(C, *JA, *Dest, Result, InputInfos,
-                   C.getArgsForToolChain(TC), LinkingOutput);
+                   C.getArgsForToolChain(TC, BoundArch), LinkingOutput);
   }
 }