@@ -195,7 +195,8 @@ static cl::opt<bool> ProfileSizeInline(
195195static cl::opt<bool > DisableSampleLoaderInlining (
196196 " disable-sample-loader-inlining" , cl::Hidden, cl::init(false ),
197197 cl::desc(" If true, artifically skip inline transformation in sample-loader "
198- " pass, and use flattened profiles to emit annotation." ));
198+ " pass, and merge (or scale) profiles (as configured by "
199+ " --sample-profile-merge-inlinee)." ));
199200
200201namespace llvm {
201202cl::opt<bool >
@@ -469,7 +470,8 @@ class SampleProfileLoader final : public SampleProfileLoaderBaseImpl<Function> {
469470 std::function<AssumptionCache &(Function &)> GetAssumptionCache,
470471 std::function<TargetTransformInfo &(Function &)> GetTargetTransformInfo,
471472 std::function<const TargetLibraryInfo &(Function &)> GetTLI,
472- LazyCallGraph &CG, bool DisableSampleProfileInlining)
473+ LazyCallGraph &CG, bool DisableSampleProfileInlining,
474+ bool UseFlattenedProfile)
473475 : SampleProfileLoaderBaseImpl(std::string(Name), std::string(RemapName),
474476 std::move (FS)),
475477 GetAC(std::move(GetAssumptionCache)),
@@ -479,7 +481,8 @@ class SampleProfileLoader final : public SampleProfileLoaderBaseImpl<Function> {
479481 ? llvm::AnnotateInlinePassName(InlineContext{
480482 LTOPhase, InlinePass::SampleProfileInliner})
481483 : CSINLINE_DEBUG),
482- DisableSampleProfileInlining(DisableSampleProfileInlining) {}
484+ DisableSampleProfileInlining(DisableSampleProfileInlining),
485+ UseFlattenedProfile(UseFlattenedProfile) {}
483486
484487 bool doInitialization (Module &M, FunctionAnalysisManager *FAM = nullptr );
485488 bool runOnModule (Module &M, ModuleAnalysisManager *AM,
@@ -595,6 +598,8 @@ class SampleProfileLoader final : public SampleProfileLoaderBaseImpl<Function> {
595598
596599 bool DisableSampleProfileInlining;
597600
601+ bool UseFlattenedProfile;
602+
598603 // External inline advisor used to replay inline decision from remarks.
599604 std::unique_ptr<InlineAdvisor> ExternalInlineAdvisor;
600605
@@ -1980,9 +1985,9 @@ bool SampleProfileLoader::doInitialization(Module &M,
19801985 if (DisableSampleLoaderInlining.getNumOccurrences ())
19811986 DisableSampleProfileInlining = DisableSampleLoaderInlining;
19821987
1983- // Use flattened profile if inlining is disabled.
1984- if (DisableSampleProfileInlining && ! Reader->profileIsCS ())
1985- ProfileConverter::flattenProfile ( Reader->getProfiles ());
1988+ if (UseFlattenedProfile)
1989+ ProfileConverter::flattenProfile ( Reader->getProfiles (),
1990+ Reader->profileIsCS ());
19861991
19871992 // While profile-sample-accurate is on, ignore symbol list.
19881993 ProfAccForSymsInList =
@@ -2314,10 +2319,12 @@ bool SampleProfileLoader::runOnFunction(Function &F, ModuleAnalysisManager *AM)
23142319}
23152320SampleProfileLoaderPass::SampleProfileLoaderPass (
23162321 std::string File, std::string RemappingFile, ThinOrFullLTOPhase LTOPhase,
2317- IntrusiveRefCntPtr<vfs::FileSystem> FS, bool DisableSampleProfileInlining)
2322+ IntrusiveRefCntPtr<vfs::FileSystem> FS, bool DisableSampleProfileInlining,
2323+ bool UseFlattenedProfile)
23182324 : ProfileFileName(File), ProfileRemappingFileName(RemappingFile),
23192325 LTOPhase(LTOPhase), FS(std::move(FS)),
2320- DisableSampleProfileInlining(DisableSampleProfileInlining) {}
2326+ DisableSampleProfileInlining(DisableSampleProfileInlining),
2327+ UseFlattenedProfile(UseFlattenedProfile) {}
23212328
23222329PreservedAnalyses SampleProfileLoaderPass::run (Module &M,
23232330 ModuleAnalysisManager &AM) {
@@ -2343,7 +2350,7 @@ PreservedAnalyses SampleProfileLoaderPass::run(Module &M,
23432350 ProfileRemappingFileName.empty () ? SampleProfileRemappingFile
23442351 : ProfileRemappingFileName,
23452352 LTOPhase, FS, GetAssumptionCache, GetTTI, GetTLI, CG,
2346- DisableSampleProfileInlining);
2353+ DisableSampleProfileInlining, UseFlattenedProfile );
23472354 if (!SampleLoader.doInitialization (M, &FAM))
23482355 return PreservedAnalyses::all ();
23492356
0 commit comments