Skip to content

[ProfileData] Remove the old version of getValueProfDataFromInst #97374

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

I've migrated uses of the old version of getValueProfDataFromInst to
the one that returns SmallVector<InstrProfValueData, 4>. This patch
removes the old version.

I've migrated uses of the old version of getValueProfDataFromInst to
the one that returns SmallVector<InstrProfValueData, 4>.  This patch
removes the old version.
@llvmbot llvmbot added the PGO Profile Guided Optimizations label Jul 2, 2024
@llvmbot
Copy link
Member

llvmbot commented Jul 2, 2024

@llvm/pr-subscribers-pgo

Author: Kazu Hirata (kazutakahirata)

Changes

I've migrated uses of the old version of getValueProfDataFromInst to
the one that returns SmallVector<InstrProfValueData, 4>. This patch
removes the old version.


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

2 Files Affected:

  • (modified) llvm/include/llvm/ProfileData/InstrProf.h (-10)
  • (modified) llvm/lib/ProfileData/InstrProf.cpp (-45)
diff --git a/llvm/include/llvm/ProfileData/InstrProf.h b/llvm/include/llvm/ProfileData/InstrProf.h
index 50e6f1d3b9b1f..9b34cb0b651f7 100644
--- a/llvm/include/llvm/ProfileData/InstrProf.h
+++ b/llvm/include/llvm/ProfileData/InstrProf.h
@@ -284,16 +284,6 @@ void annotateValueSite(Module &M, Instruction &Inst,
                        ArrayRef<InstrProfValueData> VDs, uint64_t Sum,
                        InstrProfValueKind ValueKind, uint32_t MaxMDCount);
 
-/// Extract the value profile data from \p Inst and returns them if \p Inst is
-/// annotated with value profile data. Returns nullptr otherwise. It's similar
-/// to `getValueProfDataFromInst` above except that an array is allocated only
-/// after a preliminary checking that the value profiles of kind `ValueKind`
-/// exist.
-std::unique_ptr<InstrProfValueData[]>
-getValueProfDataFromInst(const Instruction &Inst, InstrProfValueKind ValueKind,
-                         uint32_t MaxNumValueData, uint32_t &ActualNumValueData,
-                         uint64_t &TotalC, bool GetNoICPValue = false);
-
 // TODO: Unify metadata name 'PGOFuncName' and 'PGOName', by supporting read
 // of this metadata for backward compatibility and generating 'PGOName' only.
 /// Extract the value profile data from \p Inst and returns them if \p Inst is
diff --git a/llvm/lib/ProfileData/InstrProf.cpp b/llvm/lib/ProfileData/InstrProf.cpp
index 9dbaa2ca0f020..4695285787cf3 100644
--- a/llvm/lib/ProfileData/InstrProf.cpp
+++ b/llvm/lib/ProfileData/InstrProf.cpp
@@ -1342,51 +1342,6 @@ MDNode *mayHaveValueProfileOfKind(const Instruction &Inst,
   return MD;
 }
 
-static bool getValueProfDataFromInstImpl(const MDNode *const MD,
-                                         const uint32_t MaxNumDataWant,
-                                         InstrProfValueData ValueData[],
-                                         uint32_t &ActualNumValueData,
-                                         uint64_t &TotalC, bool GetNoICPValue) {
-  const unsigned NOps = MD->getNumOperands();
-  // Get total count
-  ConstantInt *TotalCInt = mdconst::dyn_extract<ConstantInt>(MD->getOperand(2));
-  if (!TotalCInt)
-    return false;
-  TotalC = TotalCInt->getZExtValue();
-  ActualNumValueData = 0;
-
-  for (unsigned I = 3; I < NOps; I += 2) {
-    if (ActualNumValueData >= MaxNumDataWant)
-      break;
-    ConstantInt *Value = mdconst::dyn_extract<ConstantInt>(MD->getOperand(I));
-    ConstantInt *Count =
-        mdconst::dyn_extract<ConstantInt>(MD->getOperand(I + 1));
-    if (!Value || !Count)
-      return false;
-    uint64_t CntValue = Count->getZExtValue();
-    if (!GetNoICPValue && (CntValue == NOMORE_ICP_MAGICNUM))
-      continue;
-    ValueData[ActualNumValueData].Value = Value->getZExtValue();
-    ValueData[ActualNumValueData].Count = CntValue;
-    ActualNumValueData++;
-  }
-  return true;
-}
-
-std::unique_ptr<InstrProfValueData[]>
-getValueProfDataFromInst(const Instruction &Inst, InstrProfValueKind ValueKind,
-                         uint32_t MaxNumValueData, uint32_t &ActualNumValueData,
-                         uint64_t &TotalC, bool GetNoICPValue) {
-  MDNode *MD = mayHaveValueProfileOfKind(Inst, ValueKind);
-  if (!MD)
-    return nullptr;
-  auto ValueDataArray = std::make_unique<InstrProfValueData[]>(MaxNumValueData);
-  if (!getValueProfDataFromInstImpl(MD, MaxNumValueData, ValueDataArray.get(),
-                                    ActualNumValueData, TotalC, GetNoICPValue))
-    return nullptr;
-  return ValueDataArray;
-}
-
 SmallVector<InstrProfValueData, 4>
 getValueProfDataFromInst(const Instruction &Inst, InstrProfValueKind ValueKind,
                          uint32_t MaxNumValueData, uint64_t &TotalC,

Copy link
Contributor

@mingmingl-llvm mingmingl-llvm left a comment

Choose a reason for hiding this comment

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

Thanks for the work!

@kazutakahirata kazutakahirata merged commit b8eaa5b into llvm:main Jul 2, 2024
7 of 9 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_ProfileData_getValueProfDataFromInst_remove branch July 2, 2024 18:46
@llvm-ci
Copy link
Collaborator

llvm-ci commented Jul 2, 2024

LLVM Buildbot has detected a new failure on builder llvm-nvptx64-nvidia-ubuntu running on as-builder-7 while building llvm at step 6 "test-build-unified-tree-check-llvm".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/160/builds/1071

Here is the relevant piece of the build log for the reference:

Step 6 (test-build-unified-tree-check-llvm) failure: test (failure)
******************** TEST 'LLVM :: Analysis/StructuralHash/structural-hash-printer.ll' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
RUN: at line 1: /home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx64-nvidia-ubuntu/build/bin/opt -passes='print<structural-hash>' -disable-output /home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx64-nvidia-ubuntu/llvm-project/llvm/test/Analysis/StructuralHash/structural-hash-printer.ll 2>&1 | /home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx64-nvidia-ubuntu/build/bin/FileCheck /home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx64-nvidia-ubuntu/llvm-project/llvm/test/Analysis/StructuralHash/structural-hash-printer.ll
+ /home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx64-nvidia-ubuntu/build/bin/opt '-passes=print<structural-hash>' -disable-output /home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx64-nvidia-ubuntu/llvm-project/llvm/test/Analysis/StructuralHash/structural-hash-printer.ll
+ /home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx64-nvidia-ubuntu/build/bin/FileCheck /home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx64-nvidia-ubuntu/llvm-project/llvm/test/Analysis/StructuralHash/structural-hash-printer.ll
RUN: at line 2: /home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx64-nvidia-ubuntu/build/bin/opt -passes='print<structural-hash><detailed>' -disable-output /home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx64-nvidia-ubuntu/llvm-project/llvm/test/Analysis/StructuralHash/structural-hash-printer.ll 2>&1 | /home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx64-nvidia-ubuntu/build/bin/FileCheck /home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx64-nvidia-ubuntu/llvm-project/llvm/test/Analysis/StructuralHash/structural-hash-printer.ll -check-prefix=DETAILED-HASH
+ /home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx64-nvidia-ubuntu/build/bin/opt '-passes=print<structural-hash><detailed>' -disable-output /home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx64-nvidia-ubuntu/llvm-project/llvm/test/Analysis/StructuralHash/structural-hash-printer.ll
+ /home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx64-nvidia-ubuntu/build/bin/FileCheck /home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx64-nvidia-ubuntu/llvm-project/llvm/test/Analysis/StructuralHash/structural-hash-printer.ll -check-prefix=DETAILED-HASH
/home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx64-nvidia-ubuntu/llvm-project/llvm/test/Analysis/StructuralHash/structural-hash-printer.ll:22:23: error: DETAILED-HASH-NEXT: expected string not found in input
; DETAILED-HASH-NEXT: Function f1 Hash: [[DF1H:([a-z0-9]{14,})]]
                      ^
<stdin>:1:30: note: scanning from here
Module Hash: 89b93403dc2523e0
                             ^
<stdin>:2:1: note: possible intended match here
Function f1 Hash: 53be183e6f7fd
^

Input file: <stdin>
Check file: /home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx64-nvidia-ubuntu/llvm-project/llvm/test/Analysis/StructuralHash/structural-hash-printer.ll

-dump-input=help explains the following input dump.

Input was:
<<<<<<
           1: Module Hash: 89b93403dc2523e0 
next:22'0                                  X error: no match found
           2: Function f1 Hash: 53be183e6f7fd 
next:22'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
next:22'1     ?                                possible intended match
           3: Function f2 Hash: 1b3549d1714a01ed 
next:22'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>>>>>

--

********************


lravenclaw pushed a commit to lravenclaw/llvm-project that referenced this pull request Jul 3, 2024
…m#97374)

I've migrated uses of the old version of getValueProfDataFromInst to
the one that returns SmallVector<InstrProfValueData, 4>.  This patch
removes the old version.
kbluck pushed a commit to kbluck/llvm-project that referenced this pull request Jul 6, 2024
…m#97374)

I've migrated uses of the old version of getValueProfDataFromInst to
the one that returns SmallVector<InstrProfValueData, 4>.  This patch
removes the old version.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PGO Profile Guided Optimizations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants