[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 21:44:49 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:

Right, I forgot about SwitchInst with only default case.  (Note that the documentation is out of date. SelectInst also supports branch_weights). LGTM.
    

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


More information about the llvm-commits mailing list