This revision was automatically updated to reflect the committed changes.
Closed by commit rL257983: Respect bound archs, even when they don't alter the 
toolchain. (authored by jlebar).

Changed prior to commit:
  http://reviews.llvm.org/D16250?vs=45061&id=45064#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D16250

Files:
  cfe/trunk/include/clang/Driver/Driver.h
  cfe/trunk/lib/Driver/Driver.cpp
  cfe/trunk/test/Driver/darwin-multiarch-arm.c

Index: cfe/trunk/lib/Driver/Driver.cpp
===================================================================
--- cfe/trunk/lib/Driver/Driver.cpp
+++ cfe/trunk/lib/Driver/Driver.cpp
@@ -1803,8 +1803,15 @@
     bool AtTopLevel, bool MultipleArchs, const char *LinkingOutput,
     std::map<std::pair<const Action *, std::string>, InputInfo> &CachedResults)
     const {
-  std::pair<const Action *, std::string> ActionTC = {
-      A, TC->getTriple().normalize()};
+  // The bound arch is not necessarily represented in the toolchain's triple --
+  // for example, armv7 and armv7s both map to the same triple -- so we need
+  // both in our map.
+  std::string TriplePlusArch = TC->getTriple().normalize();
+  if (BoundArch) {
+    TriplePlusArch += "-";
+    TriplePlusArch += BoundArch;
+  }
+  std::pair<const Action *, std::string> ActionTC = {A, TriplePlusArch};
   auto CachedResult = CachedResults.find(ActionTC);
   if (CachedResult != CachedResults.end()) {
     return CachedResult->second;
Index: cfe/trunk/include/clang/Driver/Driver.h
===================================================================
--- cfe/trunk/include/clang/Driver/Driver.h
+++ cfe/trunk/include/clang/Driver/Driver.h
@@ -380,9 +380,9 @@
                                const llvm::opt::ArgList &Args, phases::ID 
Phase,
                                Action *Input) const;
 
-  /// BuildJobsForAction - Construct the jobs to perform for the
-  /// action \p A and return an InputInfo for the result of running \p A.
-  /// Will only construct jobs for a given (Action, ToolChain) pair once.
+  /// BuildJobsForAction - Construct the jobs to perform for the action \p A 
and
+  /// return an InputInfo for the result of running \p A.  Will only construct
+  /// jobs for a given (Action, ToolChain, BoundArch) tuple once.
   InputInfo BuildJobsForAction(Compilation &C, const Action *A,
                                const ToolChain *TC, const char *BoundArch,
                                bool AtTopLevel, bool MultipleArchs,
Index: cfe/trunk/test/Driver/darwin-multiarch-arm.c
===================================================================
--- cfe/trunk/test/Driver/darwin-multiarch-arm.c
+++ cfe/trunk/test/Driver/darwin-multiarch-arm.c
@@ -0,0 +1,18 @@
+// Check that we compile correctly with multiple ARM -arch options.
+//
+// RUN: %clang -target arm7-apple-darwin10 -### \
+// RUN:   -arch armv7 -arch armv7s %s 2>&1 | FileCheck %s
+
+// CHECK: "-cc1" "-triple" "thumbv7-apple-ios5.0.0"
+// CHECK-SAME: "-o" "[[CC_OUT1:[^"]*]]"
+// CHECK:ld
+// CHECK-SAME: "-o" "[[LD_OUT1:[^"]*]]"
+// CHECK-SAME: "[[CC_OUT1]]"
+// CHECK:"-cc1" "-triple" "thumbv7s-apple-ios5.0.0"
+// CHECK-SAME: "-o" "[[CC_OUT2:[^"]*]]"
+// CHECK:ld
+// CHECK-SAME: "-o" "[[LD_OUT2:[^"]*]]"
+// CHECK-SAME: "[[CC_OUT2]]"
+// CHECK:lipo
+// CHECK-DAG: "[[LD_OUT1]]"
+// CHECK-DAG: "[[LD_OUT2]]"


Index: cfe/trunk/lib/Driver/Driver.cpp
===================================================================
--- cfe/trunk/lib/Driver/Driver.cpp
+++ cfe/trunk/lib/Driver/Driver.cpp
@@ -1803,8 +1803,15 @@
     bool AtTopLevel, bool MultipleArchs, const char *LinkingOutput,
     std::map<std::pair<const Action *, std::string>, InputInfo> &CachedResults)
     const {
-  std::pair<const Action *, std::string> ActionTC = {
-      A, TC->getTriple().normalize()};
+  // The bound arch is not necessarily represented in the toolchain's triple --
+  // for example, armv7 and armv7s both map to the same triple -- so we need
+  // both in our map.
+  std::string TriplePlusArch = TC->getTriple().normalize();
+  if (BoundArch) {
+    TriplePlusArch += "-";
+    TriplePlusArch += BoundArch;
+  }
+  std::pair<const Action *, std::string> ActionTC = {A, TriplePlusArch};
   auto CachedResult = CachedResults.find(ActionTC);
   if (CachedResult != CachedResults.end()) {
     return CachedResult->second;
Index: cfe/trunk/include/clang/Driver/Driver.h
===================================================================
--- cfe/trunk/include/clang/Driver/Driver.h
+++ cfe/trunk/include/clang/Driver/Driver.h
@@ -380,9 +380,9 @@
                                const llvm::opt::ArgList &Args, phases::ID Phase,
                                Action *Input) const;
 
-  /// BuildJobsForAction - Construct the jobs to perform for the
-  /// action \p A and return an InputInfo for the result of running \p A.
-  /// Will only construct jobs for a given (Action, ToolChain) pair once.
+  /// BuildJobsForAction - Construct the jobs to perform for the action \p A and
+  /// return an InputInfo for the result of running \p A.  Will only construct
+  /// jobs for a given (Action, ToolChain, BoundArch) tuple once.
   InputInfo BuildJobsForAction(Compilation &C, const Action *A,
                                const ToolChain *TC, const char *BoundArch,
                                bool AtTopLevel, bool MultipleArchs,
Index: cfe/trunk/test/Driver/darwin-multiarch-arm.c
===================================================================
--- cfe/trunk/test/Driver/darwin-multiarch-arm.c
+++ cfe/trunk/test/Driver/darwin-multiarch-arm.c
@@ -0,0 +1,18 @@
+// Check that we compile correctly with multiple ARM -arch options.
+//
+// RUN: %clang -target arm7-apple-darwin10 -### \
+// RUN:   -arch armv7 -arch armv7s %s 2>&1 | FileCheck %s
+
+// CHECK: "-cc1" "-triple" "thumbv7-apple-ios5.0.0"
+// CHECK-SAME: "-o" "[[CC_OUT1:[^"]*]]"
+// CHECK:ld
+// CHECK-SAME: "-o" "[[LD_OUT1:[^"]*]]"
+// CHECK-SAME: "[[CC_OUT1]]"
+// CHECK:"-cc1" "-triple" "thumbv7s-apple-ios5.0.0"
+// CHECK-SAME: "-o" "[[CC_OUT2:[^"]*]]"
+// CHECK:ld
+// CHECK-SAME: "-o" "[[LD_OUT2:[^"]*]]"
+// CHECK-SAME: "[[CC_OUT2]]"
+// CHECK:lipo
+// CHECK-DAG: "[[LD_OUT1]]"
+// CHECK-DAG: "[[LD_OUT2]]"
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to