[llvm] [Inline][PGO] After inline, update InvokeInst profile counts in caller and cloned callee (PR #83809)

David Li via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 16 15:37:03 PDT 2024


================
@@ -77,11 +80,25 @@ bool isBranchWeightMD(const MDNode *ProfileData) {
   return isTargetMD(ProfileData, "branch_weights", MinBWOps);
 }
 
+bool isValueProfileMD(const MDNode *ProfileData) {
+  return isTargetMD(ProfileData, "VP", MinVPOps);
+}
+
 bool hasBranchWeightMD(const Instruction &I) {
   auto *ProfileData = I.getMetadata(LLVMContext::MD_prof);
   return isBranchWeightMD(ProfileData);
 }
 
+bool hasCountTypeMD(const Instruction &I) {
+  auto *ProfileData = I.getMetadata(LLVMContext::MD_prof);
+  // Value profiles record count-type information.
+  if (isValueProfileMD(ProfileData))
+    return true;
+  // Conservatively assume non CallBase instruction only get taken/not-taken
+  // branch probability, so not interpret them as count.
+  return isa<CallBase>(I) && !isBranchWeightMD(ProfileData);
----------------
david-xl wrote:

It seems that the check of CallBase is not necessary. Select instruction is another one taking prof MD, and it can only be branch weight type.

If checking callbase is not needed, passing Profile meta data pointer is better.

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


More information about the llvm-commits mailing list