Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NFC][SampleFDO] Clean the unneeded field and the related loop #132376

Merged
merged 1 commit into from
Mar 28, 2025

Conversation

Jinjie-Huang
Copy link
Contributor

@Jinjie-Huang Jinjie-Huang commented Mar 21, 2025

Clean the unneeded field 'TotalCollectedSamples' and the unnecessary loop.
The field seems introduced in:https://reviews.llvm.org/D31952, and its uses were removed in: https://reviews.llvm.org/D19287, but this field and unnecessary calculation were not cleaned up.
This patch will remove these unneeded codes.

@llvmbot llvmbot added PGO Profile Guided Optimizations llvm:transforms labels Mar 21, 2025
@llvmbot
Copy link
Member

llvmbot commented Mar 21, 2025

@llvm/pr-subscribers-pgo

@llvm/pr-subscribers-llvm-transforms

Author: Jinjie Huang (Labman-001)

Changes

Clean the unneeded field 'TotalCollectedSamples' and the related sum loop.
The field seems introduced in:https://reviews.llvm.org/D31952
and its use was removed in: https://reviews.llvm.org/D19287
The loop calculation seems not to be cleaned up, this patch remove these unneeded codes.


Full diff: https://github.com/llvm/llvm-project/pull/132376.diff

1 Files Affected:

  • (modified) llvm/lib/Transforms/IPO/SampleProfile.cpp (-10)
diff --git a/llvm/lib/Transforms/IPO/SampleProfile.cpp b/llvm/lib/Transforms/IPO/SampleProfile.cpp
index 731ee7edb48c8..82d4db12586d7 100644
--- a/llvm/lib/Transforms/IPO/SampleProfile.cpp
+++ b/llvm/lib/Transforms/IPO/SampleProfile.cpp
@@ -562,12 +562,6 @@ class SampleProfileLoader final : public SampleProfileLoaderBaseImpl<Function> {
   /// used to generate the current profile.
   std::shared_ptr<ProfileSymbolList> PSL;
 
-  /// Total number of samples collected in this profile.
-  ///
-  /// This is the sum of all the samples collected in all the functions executed
-  /// at runtime.
-  uint64_t TotalCollectedSamples = 0;
-
   // Information recorded when we declined to inline a call site
   // because we have determined it is too cold is accumulated for
   // each callee function. Initially this is just the entry count.
@@ -2182,10 +2176,6 @@ bool SampleProfileLoader::runOnModule(Module &M, ModuleAnalysisManager *AM,
       rejectHighStalenessProfile(M, PSI, Reader->getProfiles()))
     return false;
 
-  // Compute the total number of samples collected in this profile.
-  for (const auto &I : Reader->getProfiles())
-    TotalCollectedSamples += I.second.getTotalSamples();
-
   auto Remapper = Reader->getRemapper();
   // Populate the symbol map.
   for (const auto &N_F : M.getValueSymbolTable()) {

@Jinjie-Huang Jinjie-Huang changed the title [SampleFdo] Clean the unneeded field, and the related loop [SampleFdo] Clean the unneeded field and the related loop Mar 21, 2025
@Jinjie-Huang
Copy link
Contributor Author

Jinjie-Huang commented Mar 21, 2025

@danielcdh @david-xl @dnovillo, can you help to review this? thx

Copy link

@dnovillo dnovillo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have not worked in this area of the compiler for a long time, but the change seems trivially correct.

Copy link
Contributor

@wlei-llvm wlei-llvm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Enna1 Enna1 changed the title [SampleFdo] Clean the unneeded field and the related loop [SampleFDO] Clean the unneeded field and the related loop Mar 25, 2025
@Jinjie-Huang Jinjie-Huang changed the title [SampleFDO] Clean the unneeded field and the related loop [NFC][SampleFDO] Clean the unneeded field and the related loop Mar 25, 2025
@Enna1 Enna1 merged commit c8b69c9 into llvm:main Mar 28, 2025
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
llvm:transforms PGO Profile Guided Optimizations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants