[PATCH] D28588: Pass -fprofile-sample-use to lto backends.
Dehao Chen via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 12 17:01:33 PST 2017
danielcdh updated this revision to Diff 84193.
danielcdh added a comment.
Updates the unittests to clang_cc1 to see if it fixes the buildbot failure.
https://reviews.llvm.org/D28588
Files:
lib/CodeGen/BackendUtil.cpp
test/CodeGen/thinlto_backend.ll
Index: test/CodeGen/thinlto_backend.ll
===================================================================
--- test/CodeGen/thinlto_backend.ll
+++ test/CodeGen/thinlto_backend.ll
@@ -8,6 +8,10 @@
; RUN: not %clang_cc1 -O2 -o %t1.o -x c %s -c -fthinlto-index=%t.thinlto.bc 2>&1 | FileCheck %s -check-prefix=CHECK-WARNING
; CHECK-WARNING: error: invalid argument '-fthinlto-index={{.*}}' only allowed with '-x ir'
+; Ensure sample profile pass are passed to backend
+; RUN: %clang_cc1 -emit-obj -O2 -o %t5.o -x ir %t1.o -fthinlto-index=%t.thinlto.bc -fprofile-sample-use=%S/Inputs/pgo-sample.prof -mllvm -debug-pass=Structure 2>&1 | FileCheck %s -check-prefix=CHECK-SAMPLEPGO
+; CHECK-SAMPLEPGO: Sample profile pass
+
; Ensure we get expected error for missing index file
; RUN: %clang -O2 -o %t4.o -x ir %t1.o -c -fthinlto-index=bad.thinlto.bc 2>&1 | FileCheck %s -check-prefix=CHECK-ERROR1
; CHECK-ERROR1: Error loading index file 'bad.thinlto.bc'
Index: lib/CodeGen/BackendUtil.cpp
===================================================================
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -862,7 +862,8 @@
}
static void runThinLTOBackend(ModuleSummaryIndex *CombinedIndex, Module *M,
- std::unique_ptr<raw_pwrite_stream> OS) {
+ std::unique_ptr<raw_pwrite_stream> OS,
+ std::string SampleProfile) {
StringMap<std::map<GlobalValue::GUID, GlobalValueSummary *>>
ModuleToDefinedGVSummaries;
CombinedIndex->collectDefinedGVSummariesPerModule(ModuleToDefinedGVSummaries);
@@ -930,6 +931,7 @@
return llvm::make_unique<lto::NativeObjectStream>(std::move(OS));
};
lto::Config Conf;
+ Conf.SampleProfile = SampleProfile;
if (Error E = thinBackend(
Conf, 0, AddStream, *M, *CombinedIndex, ImportList,
ModuleToDefinedGVSummaries[M->getModuleIdentifier()], ModuleMap)) {
@@ -965,7 +967,8 @@
// of an error).
bool DoThinLTOBackend = CombinedIndex != nullptr;
if (DoThinLTOBackend) {
- runThinLTOBackend(CombinedIndex.get(), M, std::move(OS));
+ runThinLTOBackend(CombinedIndex.get(), M, std::move(OS),
+ CGOpts.SampleProfileFile);
return;
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28588.84193.patch
Type: text/x-patch
Size: 2270 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170113/8f991e34/attachment.bin>
More information about the cfe-commits
mailing list