[PATCH] D61540: [PGO] Use sum of count values to fix func entry count and add a check to verify BFI counts

David Li via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 19 16:24:52 PST 2020


davidxl added inline comments.


================
Comment at: llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp:1657
+  uint64_t FuncEntryCount = Func.getBBInfo(&*F.begin()).CountValue;
+  uint64_t NewEntryCount = 0.5 + FuncEntryCount * Scale;
+  if (NewEntryCount == 0)
----------------
xur wrote:
> davidxl wrote:
> > Perhaps take the max of the original func entry count and the new entry count?
> Not sure if want a max here. Here a value of 1 makes the sum of raw counters and sum of BFI counters close to each other, better than original func entry count.
> 
> Using max will never reduce the entry count -- I don't think that is what we want.
I thought the intention of the patch is to correct the 'guessed' entry count which is usually '1'. If the original entry count is not 1, it is usually a value we can trust. Sometimes BFI can create insanely large counts which makes the scale really small. It ends up leading to new entry entry count to become 1 (from non-1 value). Is that the intended behavior?




CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61540/new/

https://reviews.llvm.org/D61540



More information about the llvm-commits mailing list