diff options
author | Wei Mi <wmi@google.com> | 2019-01-17 20:48:34 +0000 |
---|---|---|
committer | Wei Mi <wmi@google.com> | 2019-01-17 20:48:34 +0000 |
commit | 3bcccdfe38f28f8d19faa957cd56ed4d03cd40fb (patch) | |
tree | 21a5f3a7d03365f95cbdf1ead65d549c1f7bf85f /llvm/lib/Passes/PassBuilder.cpp | |
parent | edd653bc072dcafa5e54c2c91b7cf20343b2664c (diff) | |
download | bcm5719-llvm-3bcccdfe38f28f8d19faa957cd56ed4d03cd40fb.tar.gz bcm5719-llvm-3bcccdfe38f28f8d19faa957cd56ed4d03cd40fb.zip |
[SampleFDO] Skip profile reading when flattened profile used in ThinLTO postlink
If the sample profile has no inlining hierachy information included, we call
the sample profile is flattened. For flattened profile, in ThinLTO postlink
phase, SampleProfileLoader's hot function inlining and profile annotation will
do nothing, so it is better to save the effort to read in the profile and run
the sample profile loader pass. It is helpful for reducing compile time when
the flattened profile is huge.
Differential Revision: https://reviews.llvm.org/D54819
llvm-svn: 351476
Diffstat (limited to 'llvm/lib/Passes/PassBuilder.cpp')
-rw-r--r-- | llvm/lib/Passes/PassBuilder.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp index 5ec94ea6f40..e56c2d4c8fb 100644 --- a/llvm/lib/Passes/PassBuilder.cpp +++ b/llvm/lib/Passes/PassBuilder.cpp @@ -211,6 +211,8 @@ static cl::opt<bool> extern cl::opt<bool> EnableHotColdSplit; +extern cl::opt<bool> FlattenedProfileUsed; + static bool isOptimizingForSize(PassBuilder::OptimizationLevel Level) { switch (Level) { case PassBuilder::O0: @@ -615,9 +617,13 @@ PassBuilder::buildModuleSimplificationPipeline(OptimizationLevel Level, if (PGOOpt && !PGOOpt->SampleProfileFile.empty()) { // Annotate sample profile right after early FPM to ensure freshness of // the debug info. - MPM.addPass(SampleProfileLoaderPass(PGOOpt->SampleProfileFile, - PGOOpt->ProfileRemappingFile, - Phase == ThinLTOPhase::PreLink)); + // In ThinLTO mode, when flattened profile is used, all the available + // profile information will be annotated in PreLink phase so there is + // no need to load the profile again in PostLink. + if (!(FlattenedProfileUsed && Phase == ThinLTOPhase::PostLink)) + MPM.addPass(SampleProfileLoaderPass(PGOOpt->SampleProfileFile, + PGOOpt->ProfileRemappingFile, + Phase == ThinLTOPhase::PreLink)); // Do not invoke ICP in the ThinLTOPrelink phase as it makes it hard // for the profile annotation to be accurate in the ThinLTO backend. if (Phase != ThinLTOPhase::PreLink) |