[llvm] [SampleProfile] Add option to limit number of (indirect) call target and inlined callsites when reading a Sample Profile (PR #74677)

via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 6 15:37:57 PST 2023


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff 6016455d8810f5b19a275f3a149ab523f1821fb3 264cab4cb58fdf7e089362db0ecf737391532fae -- llvm/include/llvm/ProfileData/SampleProf.h llvm/include/llvm/ProfileData/SampleProfReader.h llvm/lib/ProfileData/SampleProfReader.cpp llvm/lib/Transforms/IPO/SampleProfile.cpp llvm/tools/llvm-profdata/llvm-profdata.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/llvm/include/llvm/ProfileData/SampleProf.h b/llvm/include/llvm/ProfileData/SampleProf.h
index e7bbc171c9..08647f5cfb 100644
--- a/llvm/include/llvm/ProfileData/SampleProf.h
+++ b/llvm/include/llvm/ProfileData/SampleProf.h
@@ -782,8 +782,8 @@ public:
   }
 
   SampleRecord &getOrCreateBodySample(uint32_t LineOffset,
-                                      uint32_t Discriminator,
-                                      uint64_t Num, uint64_t Weight = 1) {
+                                      uint32_t Discriminator, uint64_t Num,
+                                      uint64_t Weight = 1) {
     SampleRecord &Sample = BodySamples[LineLocation(LineOffset, Discriminator)];
     Sample.addSamples(Num, Weight);
     return Sample;
@@ -991,7 +991,7 @@ public:
       FunctionSamplesMap &FunctionSamples = CallsiteSample.second;
       if (ProfileInlineCallsiteMax < FunctionSamples.size()) {
         auto It = llvm::map_range(FunctionSamples,
-                                  [](FunctionSamplesMap::value_type &V){
+                                  [](FunctionSamplesMap::value_type &V) {
                                     return V.second.getTotalSamples();
                                   });
         std::vector<uint64_t> TotalSamples(It.begin(), It.end());
diff --git a/llvm/lib/ProfileData/SampleProfReader.cpp b/llvm/lib/ProfileData/SampleProfReader.cpp
index 7b4f604d80..515478db31 100644
--- a/llvm/lib/ProfileData/SampleProfReader.cpp
+++ b/llvm/lib/ProfileData/SampleProfReader.cpp
@@ -409,7 +409,7 @@ std::error_code SampleProfileReaderText::readImpl() {
       }
       case LineType::BodyProfile: {
         FunctionSamples &FProfile = *InlineStack.back();
-        if (ProfileCallTargetMax != 0)  {
+        if (ProfileCallTargetMax != 0) {
           std::multimap<uint64_t, FunctionId> CallTargets;
           for (const auto &CallTarget : TargetCountMap) {
             CallTargets.emplace(CallTarget.second, CallTarget.first);
@@ -423,10 +423,10 @@ std::error_code SampleProfileReaderText::readImpl() {
           }
         } else {
           for (const auto &name_count : TargetCountMap) {
-            MergeResult(Result, FProfile.addCalledTargetSamples(
-                                    LineOffset, Discriminator,
-                                    FunctionId(name_count.first),
-                                    name_count.second));
+            MergeResult(Result,
+                        FProfile.addCalledTargetSamples(
+                            LineOffset, Discriminator,
+                            FunctionId(name_count.first), name_count.second));
           }
         }
         MergeResult(Result, FProfile.addBodySamples(LineOffset, Discriminator,
@@ -624,9 +624,8 @@ SampleProfileReaderBinary::readProfile(FunctionSamples &FProfile) {
     // Here we handle FS discriminators:
     uint32_t DiscriminatorVal = (*Discriminator) & getDiscriminatorMask();
 
-    SampleRecord &Sample =
-        FProfile.getOrCreateBodySample(*LineOffset, DiscriminatorVal,
-                                       *NumSamples);
+    SampleRecord &Sample = FProfile.getOrCreateBodySample(
+        *LineOffset, DiscriminatorVal, *NumSamples);
 
     if (ProfileCallTargetMax != 0) {
       // ProfileCallTargetMax is only used by SampleProfile.cpp at compilation,
@@ -647,7 +646,7 @@ SampleProfileReaderBinary::readProfile(FunctionSamples &FProfile) {
           CallTargets.erase(CallTargets.begin());
       }
 
-      for (auto & CallTarget : CallTargets) {
+      for (auto &CallTarget : CallTargets) {
         Sample.addCalledTarget(CallTarget.second, CallTarget.first);
       }
     } else {

``````````

</details>


https://github.com/llvm/llvm-project/pull/74677


More information about the llvm-commits mailing list