[NFC][llvm-profgen] Fix a few minor issues (#190019)

A few NFC (mostly) fixes:
- Drop unused parameters.
- Check return error.
- Fix return type.
This commit is contained in:
Wei Wang 2026-04-06 15:30:30 -07:00 committed by GitHub
parent 1ae179b325
commit ce61fe5c48
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 16 additions and 14 deletions

View File

@ -118,12 +118,14 @@ void MissingFrameInferrer::initialize(
}
};
LLVM_DEBUG(dbgs() << "============================\n ";
dbgs() << "Call targets:\n";
PrintCallTargets(CallEdges, false);
dbgs() << "\nTail call targets:\n";
PrintCallTargets(CallEdges, true);
dbgs() << "============================\n";);
LLVM_DEBUG({
dbgs() << "============================\n ";
dbgs() << "Call targets:\n";
PrintCallTargets(CallEdges, false);
dbgs() << "\nTail call targets:\n";
PrintCallTargets(TailCallEdges, true);
dbgs() << "============================\n";
});
#endif
}

View File

@ -299,7 +299,7 @@ struct UnwindState {
uint64_t getCurrentLBRTarget() const { return LBRStack[LBRIndex].Target; }
const LBREntry &getCurrentLBR() const { return LBRStack[LBRIndex]; }
bool IsLastLBR() const { return LBRIndex == 0; }
bool getLBRStackSize() const { return LBRStack.size(); }
size_t getLBRStackSize() const { return LBRStack.size(); }
void advanceLBR() { LBRIndex++; }
ProfiledFrame *getParentFrame() { return CurrentLeafFrame->Parent; }

View File

@ -244,10 +244,10 @@ bool ProfileGeneratorBase::filterAmbiguousProfile(FunctionSamples &FS) {
// from the profile map during the profile generation time. The profiles are all
// cold functions, it won't have perf impact.
void ProfileGeneratorBase::filterAmbiguousProfile(SampleProfileMap &Profiles) {
for (auto I = ProfileMap.begin(); I != ProfileMap.end();) {
for (auto I = Profiles.begin(); I != Profiles.end();) {
auto FS = I++;
if (filterAmbiguousProfile(FS->second))
ProfileMap.erase(FS);
Profiles.erase(FS);
}
}
@ -529,15 +529,14 @@ void ProfileGeneratorBase::markAllContextPreinlined(
void ProfileGenerator::postProcessProfiles() {
computeSummaryAndThreshold(ProfileMap);
trimColdProfiles(ProfileMap, ColdCountThreshold);
trimColdProfiles(ColdCountThreshold);
filterAmbiguousProfile(ProfileMap);
if (MarkAllContextPreinlined)
markAllContextPreinlined(ProfileMap);
calculateAndShowDensity(ProfileMap);
}
void ProfileGenerator::trimColdProfiles(const SampleProfileMap &Profiles,
uint64_t ColdCntThreshold) {
void ProfileGenerator::trimColdProfiles(uint64_t ColdCntThreshold) {
if (!TrimColdProfile)
return;

View File

@ -184,8 +184,7 @@ private:
void
populateTypeSamplesForAllFunctions(const DataAccessSample &DataAccessSamples);
void postProcessProfiles();
void trimColdProfiles(const SampleProfileMap &Profiles,
uint64_t ColdCntThreshold);
void trimColdProfiles(uint64_t ColdCntThreshold);
bool collectFunctionsFromLLVMProfile(
std::unordered_set<const BinaryFunction *> &ProfiledFunctions) override;
};

View File

@ -168,6 +168,8 @@ int main(int argc, const char *argv[]) {
auto FS = vfs::getRealFileSystem();
auto ReaderOrErr =
SampleProfileReader::create(SampleProfFilename, Context, *FS);
if (std::error_code EC = ReaderOrErr.getError())
exitWithError(EC, SampleProfFilename);
std::unique_ptr<sampleprof::SampleProfileReader> Reader =
std::move(ReaderOrErr.get());
Reader->read();