@@ -469,7 +469,8 @@ class SampleProfileLoader final : public SampleProfileLoaderBaseImpl<Function> {
469
469
std::function<AssumptionCache &(Function &)> GetAssumptionCache,
470
470
std::function<TargetTransformInfo &(Function &)> GetTargetTransformInfo,
471
471
std::function<const TargetLibraryInfo &(Function &)> GetTLI,
472
- LazyCallGraph &CG)
472
+ LazyCallGraph &CG, bool DisableSampleProfileInlining,
473
+ bool UseFlattenedProfile)
473
474
: SampleProfileLoaderBaseImpl(std::string(Name), std::string(RemapName),
474
475
std::move (FS)),
475
476
GetAC(std::move(GetAssumptionCache)),
@@ -478,7 +479,9 @@ class SampleProfileLoader final : public SampleProfileLoaderBaseImpl<Function> {
478
479
AnnotatedPassName(AnnotateSampleProfileInlinePhase
479
480
? llvm::AnnotateInlinePassName(InlineContext{
480
481
LTOPhase, InlinePass::SampleProfileInliner})
481
- : CSINLINE_DEBUG) {}
482
+ : CSINLINE_DEBUG),
483
+ DisableSampleProfileInlining(DisableSampleProfileInlining),
484
+ UseFlattenedProfile(UseFlattenedProfile) {}
482
485
483
486
bool doInitialization (Module &M, FunctionAnalysisManager *FAM = nullptr );
484
487
bool runOnModule (Module &M, ModuleAnalysisManager *AM,
@@ -592,6 +595,10 @@ class SampleProfileLoader final : public SampleProfileLoaderBaseImpl<Function> {
592
595
// attribute.
593
596
bool ProfAccForSymsInList;
594
597
598
+ bool DisableSampleProfileInlining;
599
+
600
+ bool UseFlattenedProfile;
601
+
595
602
// External inline advisor used to replay inline decision from remarks.
596
603
std::unique_ptr<InlineAdvisor> ExternalInlineAdvisor;
597
604
@@ -919,7 +926,7 @@ bool SampleProfileLoader::tryPromoteAndInlineCandidate(
919
926
Function &F, InlineCandidate &Candidate, uint64_t SumOrigin, uint64_t &Sum,
920
927
SmallVector<CallBase *, 8 > *InlinedCallSite) {
921
928
// Bail out early if sample-loader inliner is disabled.
922
- if (DisableSampleLoaderInlining )
929
+ if (DisableSampleProfileInlining )
923
930
return false ;
924
931
925
932
// Bail out early if MaxNumPromotions is zero.
@@ -1230,7 +1237,7 @@ bool SampleProfileLoader::tryInlineCandidate(
1230
1237
InlineCandidate &Candidate, SmallVector<CallBase *, 8 > *InlinedCallSites) {
1231
1238
// Do not attempt to inline a candidate if
1232
1239
// --disable-sample-loader-inlining is true.
1233
- if (DisableSampleLoaderInlining )
1240
+ if (DisableSampleProfileInlining )
1234
1241
return false ;
1235
1242
1236
1243
CallBase &CB = *Candidate.CallInstr ;
@@ -1974,6 +1981,13 @@ bool SampleProfileLoader::doInitialization(Module &M,
1974
1981
1975
1982
PSL = Reader->getProfileSymbolList ();
1976
1983
1984
+ if (DisableSampleLoaderInlining.getNumOccurrences ())
1985
+ DisableSampleProfileInlining = DisableSampleLoaderInlining;
1986
+
1987
+ if (UseFlattenedProfile)
1988
+ ProfileConverter::flattenProfile (Reader->getProfiles (),
1989
+ Reader->profileIsCS ());
1990
+
1977
1991
// While profile-sample-accurate is on, ignore symbol list.
1978
1992
ProfAccForSymsInList =
1979
1993
ProfileAccurateForSymsInList && PSL && !ProfileSampleAccurate;
@@ -2304,9 +2318,12 @@ bool SampleProfileLoader::runOnFunction(Function &F, ModuleAnalysisManager *AM)
2304
2318
}
2305
2319
SampleProfileLoaderPass::SampleProfileLoaderPass (
2306
2320
std::string File, std::string RemappingFile, ThinOrFullLTOPhase LTOPhase,
2307
- IntrusiveRefCntPtr<vfs::FileSystem> FS)
2321
+ IntrusiveRefCntPtr<vfs::FileSystem> FS, bool DisableSampleProfileInlining,
2322
+ bool UseFlattenedProfile)
2308
2323
: ProfileFileName(File), ProfileRemappingFileName(RemappingFile),
2309
- LTOPhase(LTOPhase), FS(std::move(FS)) {}
2324
+ LTOPhase(LTOPhase), FS(std::move(FS)),
2325
+ DisableSampleProfileInlining(DisableSampleProfileInlining),
2326
+ UseFlattenedProfile(UseFlattenedProfile) {}
2310
2327
2311
2328
PreservedAnalyses SampleProfileLoaderPass::run (Module &M,
2312
2329
ModuleAnalysisManager &AM) {
@@ -2331,7 +2348,8 @@ PreservedAnalyses SampleProfileLoaderPass::run(Module &M,
2331
2348
ProfileFileName.empty () ? SampleProfileFile : ProfileFileName,
2332
2349
ProfileRemappingFileName.empty () ? SampleProfileRemappingFile
2333
2350
: ProfileRemappingFileName,
2334
- LTOPhase, FS, GetAssumptionCache, GetTTI, GetTLI, CG);
2351
+ LTOPhase, FS, GetAssumptionCache, GetTTI, GetTLI, CG,
2352
+ DisableSampleProfileInlining, UseFlattenedProfile);
2335
2353
if (!SampleLoader.doInitialization (M, &FAM))
2336
2354
return PreservedAnalyses::all ();
2337
2355
0 commit comments