r252558 - [Driver] Use platform-appropriate profiling libraries for WatchOS, TVOS

Vedant Kumar via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 9 16:20:34 PST 2015


Author: vedantk
Date: Mon Nov  9 18:20:34 2015
New Revision: 252558

URL: http://llvm.org/viewvc/llvm-project?rev=252558&view=rev
Log:
[Driver] Use platform-appropriate profiling libraries for WatchOS, TVOS

When adding profiling instrumentation, use libclang_rt.profile_tvos.a
for TVOS targets and libclang_rt.profile_watchos.a for WatchOS targets.

I've also fixed up a comment and added an assert() that prevents us from
defaulting to an incorrect platform.

Differential Revision: http://reviews.llvm.org/D14521

Reviewed-by: t.p.northover

Modified:
    cfe/trunk/include/clang/Driver/ToolChain.h
    cfe/trunk/lib/Driver/ToolChains.cpp
    cfe/trunk/test/Driver/instrprof-ld.c

Modified: cfe/trunk/include/clang/Driver/ToolChain.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/ToolChain.h?rev=252558&r1=252557&r2=252558&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/ToolChain.h (original)
+++ cfe/trunk/include/clang/Driver/ToolChain.h Mon Nov  9 18:20:34 2015
@@ -388,8 +388,8 @@ public:
   /// This checks for presence of the -Ofast, -ffast-math or -funsafe-math flags.
   virtual bool AddFastMathRuntimeIfAvailable(
       const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const;
-  /// addProfileRTLibs - When -fprofile-instr-profile is specified, add profile
-  /// runtime library, otherwise return false.
+  /// addProfileRTLibs - When -fprofile-instr-profile is specified, try to pass
+  /// a suitable profile runtime library to the linker.
   virtual void addProfileRTLibs(const llvm::opt::ArgList &Args,
                                 llvm::opt::ArgStringList &CmdArgs) const;
 

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=252558&r1=252557&r2=252558&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Mon Nov  9 18:20:34 2015
@@ -324,12 +324,20 @@ void Darwin::addProfileRTLibs(const ArgL
   if (!needsProfileRT(Args)) return;
 
   // Select the appropriate runtime library for the target.
-  if (isTargetIOSBased())
+  if (isTargetWatchOSBased()) {
+    AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.profile_watchos.a",
+                      /*AlwaysLink*/ true);
+  } else if (isTargetTvOSBased()) {
+    AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.profile_tvos.a",
+                      /*AlwaysLink*/ true);
+  } else if (isTargetIOSBased()) {
     AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.profile_ios.a",
                       /*AlwaysLink*/ true);
-  else
+  } else {
+    assert(isTargetMacOS() && "unexpected non MacOS platform");
     AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.profile_osx.a",
                       /*AlwaysLink*/ true);
+  }
   return;
 }
 

Modified: cfe/trunk/test/Driver/instrprof-ld.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/instrprof-ld.c?rev=252558&r1=252557&r2=252558&view=diff
==============================================================================
--- cfe/trunk/test/Driver/instrprof-ld.c (original)
+++ cfe/trunk/test/Driver/instrprof-ld.c Mon Nov  9 18:20:34 2015
@@ -89,3 +89,19 @@
 //
 // CHECK-DARWIN-ARM64: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
 // CHECK-DARWIN-ARM64: "{{.*}}/Inputs/resource_dir{{/|\\\\}}lib{{/|\\\\}}darwin{{/|\\\\}}libclang_rt.profile_ios.a"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN:     -target armv7-apple-darwin -mtvos-version-min=8.3 -fprofile-instr-generate \
+// RUN:     -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-TVOS-ARMV7 %s
+//
+// CHECK-TVOS-ARMV7: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
+// CHECK-TVOS-ARMV7: "{{.*}}/Inputs/resource_dir{{/|\\\\}}lib{{/|\\\\}}darwin{{/|\\\\}}libclang_rt.profile_tvos.a"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN:     -target armv7s-apple-darwin10 -mwatchos-version-min=2.0 -arch armv7k -fprofile-instr-generate \
+// RUN:     -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-WATCHOS-ARMV7 %s
+//
+// CHECK-WATCHOS-ARMV7: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
+// CHECK-WATCHOS-ARMV7: "{{.*}}/Inputs/resource_dir{{/|\\\\}}lib{{/|\\\\}}darwin{{/|\\\\}}libclang_rt.profile_watchos.a"




More information about the cfe-commits mailing list