llvm.org GIT mirror llvm / 7e43600
Pass sample pgo flags to thinlto. Summary: ThinLTO needs to invoke SampleProfileLoader pass during link time in order to annotate profile correctly after module importing. Reviewers: davidxl, mehdi_amini, tejohnson Subscribers: pcc, davide, llvm-commits, mehdi_amini Differential Revision: https://reviews.llvm.org/D27790 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@289957 91177308-0d34-0410-b5e6-96231b3b80d8 Dehao Chen 3 years ago
6 changed file(s) with 44 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
6363 /// Setting this field will replace unspecified target triples in input files
6464 /// with this triple.
6565 std::string DefaultTriple;
66
67 /// Sample PGO profile path.
68 std::string SampleProfile;
6669
6770 bool ShouldDiscardValueNames = true;
6871 DiagnosticHandlerFunction DiagHandler;
126126 GlobalValue::LinkageTypes Linkage = GS.second->linkage();
127127 Hasher.update(
128128 ArrayRef((const uint8_t *)&Linkage, sizeof(Linkage)));
129 }
130
131 if (!Conf.SampleProfile.empty()) {
132 auto FileOrErr = MemoryBuffer::getFile(Conf.SampleProfile);
133 if (FileOrErr)
134 Hasher.update(FileOrErr.get()->getBuffer());
129135 }
130136
131137 Key = toHex(Hasher.result());
181181 PMB.LoopVectorize = true;
182182 PMB.SLPVectorize = true;
183183 PMB.OptLevel = Conf.OptLevel;
184 PMB.PGOSampleUse = Conf.SampleProfile;
184185 if (IsThinLTO)
185186 PMB.populateThinLTOPassManager(passes);
186187 else
0 ; Generate summary sections
1 ; RUN: opt -module-summary %s -o %t1.o
2 ; RUN: opt -module-summary %p/Inputs/thinlto.ll -o %t2.o
3
4 ; RUN: rm -f %t1.o.4.opt.bc
5 ; RUN: %gold -plugin %llvmshlibdir/LLVMgold.so \
6 ; RUN: --plugin-opt=thinlto \
7 ; RUN: --plugin-opt=save-temps \
8 ; RUN: --plugin-opt=sample-profile=%p/Inputs/afdo.prof \
9 ; RUN: --plugin-opt=jobs=1 \
10 ; RUN: -shared %t1.o %t2.o -o %t3
11 ; RUN: opt -S %t1.o.4.opt.bc | FileCheck %s
12
13 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
14
15 ; CHECK: ProfileSummary
16 declare void @g(...)
17 declare void @h(...)
18
19 define void @f() {
20 entry:
21 call void (...) @g()
22 call void (...) @h()
23 ret void
24 }
170170 // Note: This array will contain all plugin options which are not claimed
171171 // as plugin exclusive to pass to the code generator.
172172 static std::vector extra;
173 // Sample profile file path
174 static std::string sample_profile;
173175
174176 static void process_plugin_option(const char *opt_)
175177 {
219221 message(LDPL_FATAL, "Invalid codegen partition level: %s", opt_ + 5);
220222 } else if (opt == "disable-verify") {
221223 DisableVerify = true;
224 } else if (opt.startswith("sample-profile=")) {
225 sample_profile= opt.substr(strlen("sample-profile="));
222226 } else {
223227 // Save this option to pass to the code generator.
224228 // ParseCommandLineOptions() expects argv[0] to be program name. Lazily
727731 break;
728732 }
729733
734 if (!options::sample_profile.empty())
735 Conf.SampleProfile = options::sample_profile;
736
730737 return llvm::make_unique(std::move(Conf), Backend,
731738 options::ParallelCodeGenParallelismLevel);
732739 }