[PATCH] D30767: Updates branch_weights annotation for call instructions during inlining.

Dehao Chen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 10 22:13:50 PST 2017


danielcdh added inline comments.


================
Comment at: lib/IR/Instruction.cpp:691
+    auto *V = mdconst::dyn_extract<ConstantInt>(ProfileData->getOperand(i));
+    if (!V)
+      return;
----------------
eraman wrote:
> What are the assumptions on the MD_prof metadata here? Could you assert V here? If it is indeed possible that ith operand is not constant int, could the next operand be constant int (in which case you shouldn't return here)
removed the check.


================
Comment at: lib/Transforms/Utils/InlineFunction.cpp:1483
   else
-    Callee->setEntryCount(CalleeCount.getValue() - CallSiteCount.getValue());
+    Callee->setEntryCount(CalleeCount.getValue() - CallCount);
 }
----------------
eraman wrote:
> This gets confusing. You're now updating the entry count based on the metadata. When sample profile is used, is it expected that the sum of the calls' profile weights equal the entry count? Do you smooth out the entry count based on call instructions' profile weight  when you initially load the profile. In any case, more comments are helpful.
Code updated. Yes, the sample profile collection makes sure the function entry count meet with all call edges.

Let me know if you think there still need to add comments.


https://reviews.llvm.org/D30767





More information about the llvm-commits mailing list