[PATCH] D27832: Add -plugin-opt=sample-profile for thinLTO build.

Dehao Chen via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 16 08:40:39 PST 2016


danielcdh updated this revision to Diff 81759.
danielcdh added a comment.

add a test.


https://reviews.llvm.org/D27832

Files:
  lib/Driver/Tools.cpp
  test/Driver/gold-lto-samplepgo.c


Index: test/Driver/gold-lto-samplepgo.c
===================================================================
--- /dev/null
+++ test/Driver/gold-lto-samplepgo.c
@@ -0,0 +1,7 @@
+// RUN: touch %t.o
+//
+// RUN: %clang -target x86_64-unknown-linux -### %t.o -flto 2>&1 \
+// RUN:     -Wl,-plugin-opt=foo -O3 \
+// RUN:     -fprofile-sample-use=%s \
+// RUN:     | FileCheck %s
+// CHECK: -plugin-opt=sample-profile=
Index: lib/Driver/Tools.cpp
===================================================================
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -2206,6 +2206,15 @@
                    UseSeparateSections)) {
     CmdArgs.push_back("-plugin-opt=-data-sections");
   }
+
+  if (Arg *A = Args.getLastArg(options::OPT_fprofile_sample_use_EQ)) {
+    StringRef fname = A->getValue();
+    if (!llvm::sys::fs::exists(fname))
+      D.Diag(diag::err_drv_no_such_file) << fname;
+    else
+      CmdArgs.push_back(
+          Args.MakeArgString(Twine("-plugin-opt=sample-profile=") + fname));
+  }
 }
 
 /// This is a helper function for validating the optional refinement step


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27832.81759.patch
Type: text/x-patch
Size: 1087 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20161216/ccb64593/attachment.bin>


More information about the cfe-commits mailing list