Skip to content

Commit 8563a8d

Browse files
[𝘀𝗽𝗿] initial version
Created using spr 1.3.6
1 parent fadea8c commit 8563a8d

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

llvm/lib/Transforms/IPO/SampleProfile.cpp

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -485,11 +485,11 @@ class SampleProfileLoader final : public SampleProfileLoaderBaseImpl<Function> {
485485
UseFlattenedProfile(UseFlattenedProfile) {}
486486

487487
bool doInitialization(Module &M, FunctionAnalysisManager *FAM = nullptr);
488-
bool runOnModule(Module &M, ModuleAnalysisManager *AM,
488+
bool runOnModule(Module &M, ModuleAnalysisManager &AM,
489489
ProfileSummaryInfo *_PSI);
490490

491491
protected:
492-
bool runOnFunction(Function &F, ModuleAnalysisManager *AM);
492+
bool runOnFunction(Function &F, ModuleAnalysisManager &AM);
493493
bool emitAnnotations(Function &F);
494494
ErrorOr<uint64_t> getInstWeight(const Instruction &I) override;
495495
const FunctionSamples *findCalleeFunctionSamples(const CallBase &I) const;
@@ -2160,7 +2160,7 @@ void SampleProfileLoader::removePseudoProbeInstsDiscriminator(Module &M) {
21602160
}
21612161
}
21622162

2163-
bool SampleProfileLoader::runOnModule(Module &M, ModuleAnalysisManager *AM,
2163+
bool SampleProfileLoader::runOnModule(Module &M, ModuleAnalysisManager &AM,
21642164
ProfileSummaryInfo *_PSI) {
21652165
GUIDToFuncNameMapper Mapper(M, *Reader, GUIDToFuncNameMap);
21662166

@@ -2238,7 +2238,7 @@ bool SampleProfileLoader::runOnModule(Module &M, ModuleAnalysisManager *AM,
22382238
return retval;
22392239
}
22402240

2241-
bool SampleProfileLoader::runOnFunction(Function &F, ModuleAnalysisManager *AM) {
2241+
bool SampleProfileLoader::runOnFunction(Function &F, ModuleAnalysisManager &AM) {
22422242
LLVM_DEBUG(dbgs() << "\n\nProcessing Function " << F.getName() << "\n");
22432243
DILocation2SampleMap.clear();
22442244
// By default the entry count is initialized to -1, which will be treated
@@ -2290,15 +2290,10 @@ bool SampleProfileLoader::runOnFunction(Function &F, ModuleAnalysisManager *AM)
22902290
if (!F.getEntryCount())
22912291
F.setEntryCount(ProfileCount(initialEntryCount, Function::PCT_Real));
22922292
std::unique_ptr<OptimizationRemarkEmitter> OwnedORE;
2293-
if (AM) {
2294-
auto &FAM =
2295-
AM->getResult<FunctionAnalysisManagerModuleProxy>(*F.getParent())
2296-
.getManager();
2297-
ORE = &FAM.getResult<OptimizationRemarkEmitterAnalysis>(F);
2298-
} else {
2299-
OwnedORE = std::make_unique<OptimizationRemarkEmitter>(&F);
2300-
ORE = OwnedORE.get();
2301-
}
2293+
auto &FAM =
2294+
AM.getResult<FunctionAnalysisManagerModuleProxy>(*F.getParent())
2295+
.getManager();
2296+
ORE = &FAM.getResult<OptimizationRemarkEmitterAnalysis>(F);
23022297

23032298
if (FunctionSamples::ProfileIsCS)
23042299
Samples = ContextTracker->getBaseSamplesFor(F);
@@ -2363,7 +2358,7 @@ PreservedAnalyses SampleProfileLoaderPass::run(Module &M,
23632358
return PreservedAnalyses::all();
23642359

23652360
ProfileSummaryInfo *PSI = &AM.getResult<ProfileSummaryAnalysis>(M);
2366-
if (!SampleLoader.runOnModule(M, &AM, PSI))
2361+
if (!SampleLoader.runOnModule(M, AM, PSI))
23672362
return PreservedAnalyses::all();
23682363

23692364
return PreservedAnalyses::none();

0 commit comments

Comments
 (0)