[llvm] [AsmPrint] Correctly factor function entry count when dumping MBB frequencies (PR #67826)

Snehasish Kumar via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 29 09:30:59 PDT 2023


================
@@ -1929,18 +1929,35 @@ void AsmPrinter::emitFunctionBody() {
 
   // Output MBB ids, function names, and frequencies if the flag to dump
   // MBB profile information has been set
-  if (MBBProfileDumpFileOutput) {
+  if (MBBProfileDumpFileOutput && !MF->empty()) {
     if (!MF->hasBBLabels())
       MF->getContext().reportError(
           SMLoc(),
           "Unable to find BB labels for MBB profile dump. -mbb-profile-dump "
           "must be called with -basic-block-sections=labels");
     MachineBlockFrequencyInfo &MBFI =
         getAnalysis<LazyMachineBlockFrequencyInfoPass>().getBFI();
+    // The entry count and the entry basic block frequency aren't the same. We
+    // want to capture "absolute" frequencies, i.e. the frequency with which a
+    // MBB is executed when the program is executed - from there, we can derive
----------------
snehasish wrote:

nit: This sentence is pretty long, consider splitting it up at the hyphen to make it easier to parse?

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


More information about the llvm-commits mailing list