diff --git a/llvm/tools/llvm-profgen/MissingFrameInferrer.cpp b/llvm/tools/llvm-profgen/MissingFrameInferrer.cpp index d692de75cfb8..1141c4197842 100644 --- a/llvm/tools/llvm-profgen/MissingFrameInferrer.cpp +++ b/llvm/tools/llvm-profgen/MissingFrameInferrer.cpp @@ -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 } diff --git a/llvm/tools/llvm-profgen/PerfReader.h b/llvm/tools/llvm-profgen/PerfReader.h index 6e233d17f8e6..2a4c7594d3a9 100644 --- a/llvm/tools/llvm-profgen/PerfReader.h +++ b/llvm/tools/llvm-profgen/PerfReader.h @@ -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; } diff --git a/llvm/tools/llvm-profgen/ProfileGenerator.cpp b/llvm/tools/llvm-profgen/ProfileGenerator.cpp index 33931f3ef993..c3f489040007 100644 --- a/llvm/tools/llvm-profgen/ProfileGenerator.cpp +++ b/llvm/tools/llvm-profgen/ProfileGenerator.cpp @@ -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; diff --git a/llvm/tools/llvm-profgen/ProfileGenerator.h b/llvm/tools/llvm-profgen/ProfileGenerator.h index a4b738016ec3..2c512779319d 100644 --- a/llvm/tools/llvm-profgen/ProfileGenerator.h +++ b/llvm/tools/llvm-profgen/ProfileGenerator.h @@ -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 &ProfiledFunctions) override; }; diff --git a/llvm/tools/llvm-profgen/llvm-profgen.cpp b/llvm/tools/llvm-profgen/llvm-profgen.cpp index 8d2ed2850e38..0ab6c6f87382 100644 --- a/llvm/tools/llvm-profgen/llvm-profgen.cpp +++ b/llvm/tools/llvm-profgen/llvm-profgen.cpp @@ -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 Reader = std::move(ReaderOrErr.get()); Reader->read();