[llvm-branch-commits] [cfe-branch] r360828 - Merging r360674:

Tom Stellard via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed May 15 17:07:53 PDT 2019


Author: tstellar
Date: Wed May 15 17:07:53 2019
New Revision: 360828

URL: http://llvm.org/viewvc/llvm-project?rev=360828&view=rev
Log:
Merging r360674:

------------------------------------------------------------------------
r360674 | russell_gallop | 2019-05-14 07:01:40 -0700 (Tue, 14 May 2019) | 7 lines

[Driver][Windows] Add dependent lib argument for profile instr generate

This is needed so lld-link can find clang_rt.profile when self hosting
on Windows with PGO. Using clang-cl as a linker knows to add the library
but self hosting, using -DCMAKE_LINKER=<...>/lld-link.exe doesn't.

Differential Revision: https://reviews.llvm.org/D61742
------------------------------------------------------------------------

Modified:
    cfe/branches/release_80/lib/Driver/ToolChains/Clang.cpp
    cfe/branches/release_80/test/Driver/cl-options.c
    cfe/branches/release_80/test/Driver/instrprof-ld.c

Modified: cfe/branches/release_80/lib/Driver/ToolChains/Clang.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_80/lib/Driver/ToolChains/Clang.cpp?rev=360828&r1=360827&r2=360828&view=diff
==============================================================================
--- cfe/branches/release_80/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/branches/release_80/lib/Driver/ToolChains/Clang.cpp Wed May 15 17:07:53 2019
@@ -718,8 +718,9 @@ static void appendUserToPath(SmallVector
   Result.append(UID.begin(), UID.end());
 }
 
-static void addPGOAndCoverageFlags(Compilation &C, const Driver &D,
-                                   const InputInfo &Output, const ArgList &Args,
+static void addPGOAndCoverageFlags(const ToolChain &TC, Compilation &C,
+                                   const Driver &D, const InputInfo &Output,
+                                   const ArgList &Args,
                                    ArgStringList &CmdArgs) {
 
   auto *PGOGenerateArg = Args.getLastArg(options::OPT_fprofile_generate,
@@ -759,6 +760,11 @@ static void addPGOAndCoverageFlags(Compi
                                            ProfileGenerateArg->getValue()));
     // The default is to use Clang Instrumentation.
     CmdArgs.push_back("-fprofile-instrument=clang");
+    if (TC.getTriple().isWindowsMSVCEnvironment()) {
+      // Add dependent lib for clang_rt.profile
+      CmdArgs.push_back(Args.MakeArgString("--dependent-lib=" +
+                                           TC.getCompilerRT(Args, "profile")));
+    }
   }
 
   if (PGOGenerateArg) {
@@ -4118,7 +4124,7 @@ void Clang::ConstructJob(Compilation &C,
   // sampling, overhead of call arc collection is way too high and there's no
   // way to collect the output.
   if (!Triple.isNVPTX())
-    addPGOAndCoverageFlags(C, D, Output, Args, CmdArgs);
+    addPGOAndCoverageFlags(TC, C, D, Output, Args, CmdArgs);
 
   if (auto *ABICompatArg = Args.getLastArg(options::OPT_fclang_abi_compat_EQ))
     ABICompatArg->render(Args, CmdArgs);

Modified: cfe/branches/release_80/test/Driver/cl-options.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_80/test/Driver/cl-options.c?rev=360828&r1=360827&r2=360828&view=diff
==============================================================================
--- cfe/branches/release_80/test/Driver/cl-options.c (original)
+++ cfe/branches/release_80/test/Driver/cl-options.c Wed May 15 17:07:53 2019
@@ -66,7 +66,7 @@
 // RUN: %clang_cl -### /FA -fprofile-instr-generate=/tmp/somefile.profraw -- %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-GENERATE-FILE %s
 // RUN: %clang_cl -### /FA -fprofile-instr-generate -fprofile-instr-use -- %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GEN-USE %s
 // RUN: %clang_cl -### /FA -fprofile-instr-generate -fprofile-instr-use=file -- %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GEN-USE %s
-// CHECK-PROFILE-GENERATE: "-fprofile-instrument=clang"
+// CHECK-PROFILE-GENERATE: "-fprofile-instrument=clang" "--dependent-lib={{[^"]*}}clang_rt.profile-{{[^"]*}}.lib"
 // CHECK-PROFILE-GENERATE-FILE: "-fprofile-instrument-path=/tmp/somefile.profraw"
 // CHECK-NO-MIX-GEN-USE: '{{[a-z=-]*}}' not allowed with '{{[a-z=-]*}}'
 

Modified: cfe/branches/release_80/test/Driver/instrprof-ld.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_80/test/Driver/instrprof-ld.c?rev=360828&r1=360827&r2=360828&view=diff
==============================================================================
--- cfe/branches/release_80/test/Driver/instrprof-ld.c (original)
+++ cfe/branches/release_80/test/Driver/instrprof-ld.c Wed May 15 17:07:53 2019
@@ -121,3 +121,17 @@
 //
 // CHECK-WINDOWS-X86-64: "{{.*}}link{{(.exe)?}}"
 // CHECK-WINDOWS-X86-64: "{{.*}}clang_rt.profile-x86_64.lib"
+
+// Test instrumented profiling dependent-lib flags
+//
+// RUN: %clang %s -### -o %t.o -target x86_64-pc-win32 \
+// RUN:     -fprofile-instr-generate 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-WINDOWS-X86-64-DEPENDENT-LIB %s
+//
+// CHECK-WINDOWS-X86-64-DEPENDENT-LIB: "--dependent-lib={{[^"]*}}clang_rt.profile-{{[^"]*}}.lib"
+//
+// RUN: %clang %s -### -o %t.o -target x86_64-mingw32 \
+// RUN:     -fprofile-instr-generate 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MINGW-X86-64-DEPENDENT-LIB %s
+//
+// CHECK-MINGW-X86-64-DEPENDENT-LIB-NOT: "--dependent-lib={{[^"]*}}clang_rt.profile-{{[^"]*}}.a"




More information about the llvm-branch-commits mailing list