[Driver] Compute effective target triples once per job (NFCI)

Compute an effective target triple exactly once in ConstructJob(), and
then simply pass around references to it. This eliminates wasteful
re-computation of effective triples (e.g in getARMFloatABI()).

Differential Revision: https://reviews.llvm.org/D22290

llvm-svn: 275895
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 61e8fbb..8034e47 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -2256,7 +2256,21 @@
                                              TC->getTriple().normalize()),
                        BaseInput);
 
+  llvm::Triple EffectiveTriple;
+  const ArgList &Args = C.getArgsForToolChain(TC, BoundArch);
+  if (InputInfos.size() != 1) {
+    EffectiveTriple = llvm::Triple(
+        T->getToolChain().ComputeEffectiveClangTriple(Args));
+  } else {
+    // Pass along the input type if it can be unambiguously determined.
+    EffectiveTriple =
+        llvm::Triple(T->getToolChain().ComputeEffectiveClangTriple(
+            Args, InputInfos[0].getType()));
+  }
+
   if (CCCPrintBindings && !CCGenDiagnostics) {
+    // FIXME: We should be able to use the effective triple here, but doing so
+    // breaks some multi-arch tests.
     llvm::errs() << "# \"" << T->getToolChain().getTripleString() << '"'
                  << " - \"" << T->getName() << "\", inputs: [";
     for (unsigned i = 0, e = InputInfos.size(); i != e; ++i) {
@@ -2266,7 +2280,7 @@
     }
     llvm::errs() << "], output: " << Result.getAsString() << "\n";
   } else {
-    T->ConstructJob(C, *JA, Result, InputInfos,
+    T->ConstructJob(C, *JA, Result, InputInfos, EffectiveTriple,
                     C.getArgsForToolChain(TC, BoundArch), LinkingOutput);
   }
   return Result;