Skip to content

[Transforms] Migrate to a new version of getValueProfDataFromInst #95485

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

Conversation

kazutakahirata
Copy link
Contributor

Note that the version of getValueProfDataFromInst that returns bool
has been "deprecated" since:

commit 1e15371
Author: Mingming Liu [email protected]
Date: Mon Apr 1 15:14:49 2024 -0700

Note that the version of getValueProfDataFromInst that returns bool
has been "deprecated" since:

  commit 1e15371
  Author: Mingming Liu <[email protected]>
  Date:   Mon Apr 1 15:14:49 2024 -0700
@llvmbot llvmbot added PGO Profile Guided Optimizations llvm:transforms labels Jun 13, 2024
@llvmbot
Copy link
Member

llvmbot commented Jun 13, 2024

@llvm/pr-subscribers-llvm-transforms

@llvm/pr-subscribers-pgo

Author: Kazu Hirata (kazutakahirata)

Changes

Note that the version of getValueProfDataFromInst that returns bool
has been "deprecated" since:

commit 1e15371
Author: Mingming Liu <[email protected]>
Date: Mon Apr 1 15:14:49 2024 -0700


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

1 Files Affected:

  • (modified) llvm/lib/Transforms/IPO/SampleProfile.cpp (+7-12)
diff --git a/llvm/lib/Transforms/IPO/SampleProfile.cpp b/llvm/lib/Transforms/IPO/SampleProfile.cpp
index 7e6a8817b7a67..61078c4194b81 100644
--- a/llvm/lib/Transforms/IPO/SampleProfile.cpp
+++ b/llvm/lib/Transforms/IPO/SampleProfile.cpp
@@ -790,14 +790,12 @@ SampleProfileLoader::findFunctionSamples(const Instruction &Inst) const {
 static bool doesHistoryAllowICP(const Instruction &Inst, StringRef Candidate) {
   uint32_t NumVals = 0;
   uint64_t TotalCount = 0;
-  std::unique_ptr<InstrProfValueData[]> ValueData =
-      std::make_unique<InstrProfValueData[]>(MaxNumPromotions);
-  bool Valid =
+  auto ValueData =
       getValueProfDataFromInst(Inst, IPVK_IndirectCallTarget, MaxNumPromotions,
-                               ValueData.get(), NumVals, TotalCount, true);
+                               NumVals, TotalCount, true);
   // No valid value profile so no promoted targets have been recorded
   // before. Ok to do ICP.
-  if (!Valid)
+  if (!ValueData)
     return true;
 
   unsigned NumPromoted = 0;
@@ -837,11 +835,8 @@ updateIDTMetaData(Instruction &Inst,
   uint32_t NumVals = 0;
   // OldSum is the existing total count in the value profile data.
   uint64_t OldSum = 0;
-  std::unique_ptr<InstrProfValueData[]> ValueData =
-      std::make_unique<InstrProfValueData[]>(MaxNumPromotions);
-  bool Valid =
-      getValueProfDataFromInst(Inst, IPVK_IndirectCallTarget, MaxNumPromotions,
-                               ValueData.get(), NumVals, OldSum, true);
+  auto ValueData = getValueProfDataFromInst(
+      Inst, IPVK_IndirectCallTarget, MaxNumPromotions, NumVals, OldSum, true);
 
   DenseMap<uint64_t, uint64_t> ValueCountMap;
   if (Sum == 0) {
@@ -850,7 +845,7 @@ updateIDTMetaData(Instruction &Inst,
            "If sum is 0, assume only one element in CallTargets "
            "with count being NOMORE_ICP_MAGICNUM");
     // Initialize ValueCountMap with existing value profile data.
-    if (Valid) {
+    if (ValueData) {
       for (uint32_t I = 0; I < NumVals; I++)
         ValueCountMap[ValueData[I].Value] = ValueData[I].Count;
     }
@@ -866,7 +861,7 @@ updateIDTMetaData(Instruction &Inst,
   } else {
     // Initialize ValueCountMap with existing NOMORE_ICP_MAGICNUM
     // counts in the value profile.
-    if (Valid) {
+    if (ValueData) {
       for (uint32_t I = 0; I < NumVals; I++) {
         if (ValueData[I].Count == NOMORE_ICP_MAGICNUM)
           ValueCountMap[ValueData[I].Value] = ValueData[I].Count;

@kazutakahirata kazutakahirata merged commit 836ca5b into llvm:main Jun 14, 2024
8 of 9 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_getValueProfDataFromInst_SampleProfile branch June 14, 2024 01:21
EthanLuisMcDonough pushed a commit to EthanLuisMcDonough/llvm-project that referenced this pull request Aug 13, 2024
…vm#95485)

Note that the version of getValueProfDataFromInst that returns bool
has been "deprecated" since:

  commit 1e15371
  Author: Mingming Liu <[email protected]>
  Date:   Mon Apr 1 15:14:49 2024 -0700
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.

3 participants