[PATCH] D60903: [SampleFDO] Never set profile entry count to 0

Wei Mi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 19 09:49:59 PDT 2019


wmi added a comment.

In D60903#1472744 <https://reviews.llvm.org/D60903#1472744>, @davidxl wrote:

> It is possible to for an entry with zero count -- as for instance in instrumentation PGO.  Should it be fixed in place where the div by zero happens?


Oh, that is good to know. I think the problem only exists for SamplePGO because SamplePGO has prof meta data annotated on callsite instruction, and profile update in inlining needs to update that meta data proportionally according to entry count. Instrumentation PGO only use BFI and don't have to do that update.

I think it is possible to be fixed the error I am looking at in place where the div by zero happens. It is in Instruction::updateProfWeight when the function parameter T is 0. We can either change T to 1, or simply return. I slightly lean towards current approach because we may want to do it in a more consistent way -- currently adjusting 0 to 1 happens in multiple places in SamplePGO, even in profile generation tools). Another reason is Instruction::updateProfWeight is used by other components other than SamplePGO. Doing it in Instruction::updateProfWeight may silently suppress some floating point exception which may expose some other serious error, like the prof meta data is reset to 0 by memory overflow.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D60903





More information about the llvm-commits mailing list