Skip to content

Commit

Permalink
[LegacyPM] Remove SampleProfileLoaderLegacyPass
Browse files Browse the repository at this point in the history
Following recent changes removing non-core features of the legacy
PM/optimization pipeline (e.g. PGO), remove SamplePGO.
  • Loading branch information
MaskRay committed Jul 17, 2022
1 parent 5250e7a commit dd5e3f0
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 92 deletions.
1 change: 0 additions & 1 deletion llvm/include/llvm/InitializePasses.h
Expand Up @@ -390,7 +390,6 @@ void initializeSLPVectorizerPass(PassRegistry&);
void initializeSROALegacyPassPass(PassRegistry&);
void initializeSafeStackLegacyPassPass(PassRegistry&);
void initializeSafepointIRVerifierPass(PassRegistry&);
void initializeSampleProfileLoaderLegacyPassPass(PassRegistry&);
void initializeSelectOptimizePass(PassRegistry &);
void initializeScalarEvolutionWrapperPassPass(PassRegistry&);
void initializeScalarizeMaskedMemIntrinLegacyPassPass(PassRegistry &);
Expand Down
6 changes: 0 additions & 6 deletions llvm/include/llvm/Transforms/IPO.h
Expand Up @@ -276,12 +276,6 @@ createWholeProgramDevirtPass(ModuleSummaryIndex *ExportSummary,
/// devirtualization and control-flow integrity.
ModulePass *createGlobalSplitPass();

//===----------------------------------------------------------------------===//
// SampleProfilePass - Loads sample profile data from disk and generates
// IR metadata to reflect the profile.
ModulePass *createSampleProfileLoaderPass();
ModulePass *createSampleProfileLoaderPass(StringRef Name);

/// Write ThinLTO-ready bitcode to Str.
ModulePass *createWriteThinLTOBitcodePass(raw_ostream &Str,
raw_ostream *ThinLinkOS = nullptr);
Expand Down
1 change: 0 additions & 1 deletion llvm/lib/Transforms/IPO/IPO.cpp
Expand Up @@ -60,7 +60,6 @@ void llvm::initializeIPO(PassRegistry &Registry) {
initializeStripNonDebugSymbolsPass(Registry);
initializeBarrierNoopPass(Registry);
initializeEliminateAvailableExternallyLegacyPassPass(Registry);
initializeSampleProfileLoaderLegacyPassPass(Registry);
initializeFunctionImportLegacyPassPass(Registry);
initializeWholeProgramDevirtPass(Registry);
}
Expand Down
9 changes: 0 additions & 9 deletions llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
Expand Up @@ -594,15 +594,6 @@ void PassManagerBuilder::populateModulePassManager(
legacy::PassManagerBase &MPM) {
MPM.add(createAnnotation2MetadataLegacyPass());

if (!PGOSampleUse.empty()) {
MPM.add(createPruneEHPass());
// 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 && PerformThinLTO))
MPM.add(createSampleProfileLoaderPass(PGOSampleUse));
}

// Allow forcing function attributes as a debugging and tuning aid.
MPM.add(createForceFunctionAttrsLegacyPass());

Expand Down
75 changes: 0 additions & 75 deletions llvm/lib/Transforms/IPO/SampleProfile.cpp
Expand Up @@ -546,53 +546,6 @@ class SampleProfileLoader final
return AnnotatedPassName.c_str();
}
};

class SampleProfileLoaderLegacyPass : public ModulePass {
public:
// Class identification, replacement for typeinfo
static char ID;

SampleProfileLoaderLegacyPass(
StringRef Name = SampleProfileFile,
ThinOrFullLTOPhase LTOPhase = ThinOrFullLTOPhase::None)
: ModulePass(ID), SampleLoader(
Name, SampleProfileRemappingFile, LTOPhase,
[&](Function &F) -> AssumptionCache & {
return ACT->getAssumptionCache(F);
},
[&](Function &F) -> TargetTransformInfo & {
return TTIWP->getTTI(F);
},
[&](Function &F) -> TargetLibraryInfo & {
return TLIWP->getTLI(F);
}) {
initializeSampleProfileLoaderLegacyPassPass(
*PassRegistry::getPassRegistry());
}

void dump() { SampleLoader.dump(); }

bool doInitialization(Module &M) override {
return SampleLoader.doInitialization(M);
}

StringRef getPassName() const override { return "Sample profile pass"; }
bool runOnModule(Module &M) override;

void getAnalysisUsage(AnalysisUsage &AU) const override {
AU.addRequired<AssumptionCacheTracker>();
AU.addRequired<TargetTransformInfoWrapperPass>();
AU.addRequired<TargetLibraryInfoWrapperPass>();
AU.addRequired<ProfileSummaryInfoWrapperPass>();
}

private:
SampleProfileLoader SampleLoader;
AssumptionCacheTracker *ACT = nullptr;
TargetTransformInfoWrapperPass *TTIWP = nullptr;
TargetLibraryInfoWrapperPass *TLIWP = nullptr;
};

} // end anonymous namespace

ErrorOr<uint64_t> SampleProfileLoader::getInstWeight(const Instruction &Inst) {
Expand Down Expand Up @@ -1825,17 +1778,6 @@ bool SampleProfileLoader::emitAnnotations(Function &F) {
return Changed;
}

char SampleProfileLoaderLegacyPass::ID = 0;

INITIALIZE_PASS_BEGIN(SampleProfileLoaderLegacyPass, "sample-profile",
"Sample Profile loader", false, false)
INITIALIZE_PASS_DEPENDENCY(AssumptionCacheTracker)
INITIALIZE_PASS_DEPENDENCY(TargetTransformInfoWrapperPass)
INITIALIZE_PASS_DEPENDENCY(TargetLibraryInfoWrapperPass)
INITIALIZE_PASS_DEPENDENCY(ProfileSummaryInfoWrapperPass)
INITIALIZE_PASS_END(SampleProfileLoaderLegacyPass, "sample-profile",
"Sample Profile loader", false, false)

std::unique_ptr<ProfiledCallGraph>
SampleProfileLoader::buildProfiledCallGraph(CallGraph &CG) {
std::unique_ptr<ProfiledCallGraph> ProfiledCG;
Expand Down Expand Up @@ -2073,14 +2015,6 @@ bool SampleProfileLoader::doInitialization(Module &M,
return true;
}

ModulePass *llvm::createSampleProfileLoaderPass() {
return new SampleProfileLoaderLegacyPass();
}

ModulePass *llvm::createSampleProfileLoaderPass(StringRef Name) {
return new SampleProfileLoaderLegacyPass(Name);
}

bool SampleProfileLoader::runOnModule(Module &M, ModuleAnalysisManager *AM,
ProfileSummaryInfo *_PSI, CallGraph *CG) {
GUIDToFuncNameMapper Mapper(M, *Reader, GUIDToFuncNameMap);
Expand Down Expand Up @@ -2141,15 +2075,6 @@ bool SampleProfileLoader::runOnModule(Module &M, ModuleAnalysisManager *AM,
return retval;
}

bool SampleProfileLoaderLegacyPass::runOnModule(Module &M) {
ACT = &getAnalysis<AssumptionCacheTracker>();
TTIWP = &getAnalysis<TargetTransformInfoWrapperPass>();
TLIWP = &getAnalysis<TargetLibraryInfoWrapperPass>();
ProfileSummaryInfo *PSI =
&getAnalysis<ProfileSummaryInfoWrapperPass>().getPSI();
return SampleLoader.runOnModule(M, nullptr, PSI, nullptr);
}

bool SampleProfileLoader::runOnFunction(Function &F, ModuleAnalysisManager *AM) {
LLVM_DEBUG(dbgs() << "\n\nProcessing Function " << F.getName() << "\n");
DILocation2SampleMap.clear();
Expand Down

0 comments on commit dd5e3f0

Please sign in to comment.