r290919 - Add -plugin-opt=sample-profile for thinLTO build.
Dehao Chen via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 3 16:33:24 PST 2017
Author: dehao
Date: Tue Jan 3 18:33:23 2017
New Revision: 290919
URL: http://llvm.org/viewvc/llvm-project?rev=290919&view=rev
Log:
Add -plugin-opt=sample-profile for thinLTO build.
Summary: ThinLTO needs to pass down the sample profile file path to linker.
Reviewers: tejohnson, davidxl, mehdi_amini
Subscribers: bruno, cfe-commits
Differential Revision: https://reviews.llvm.org/D27832
Added:
cfe/trunk/test/Driver/gold-lto-samplepgo.c
Modified:
cfe/trunk/lib/Driver/Tools.cpp
Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=290919&r1=290918&r2=290919&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Tue Jan 3 18:33:23 2017
@@ -2235,6 +2235,15 @@ static void AddGoldPlugin(const ToolChai
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
Added: cfe/trunk/test/Driver/gold-lto-samplepgo.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/gold-lto-samplepgo.c?rev=290919&view=auto
==============================================================================
--- cfe/trunk/test/Driver/gold-lto-samplepgo.c (added)
+++ cfe/trunk/test/Driver/gold-lto-samplepgo.c Tue Jan 3 18:33:23 2017
@@ -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=
More information about the cfe-commits
mailing list