[PGO] Fix incorrect function entry count
authorRong Xu <xur@google.com>
Sat, 25 Jul 2020 00:39:55 +0000 (17:39 -0700)
committerRong Xu <xur@google.com>
Sat, 25 Jul 2020 00:39:55 +0000 (17:39 -0700)
commit1dd39b1133136c58847d9f2d3c73d2ad8e76e25d
tree2db1e38c9390d337b2d8851aa9a54ca6d4ca3791
parent31bd15c562449954d8211c067fc38b1907d60615
[PGO] Fix incorrect function entry count

Function entry count might be zero after the profile counts reset and
before reentry to the function.

Zero profile entry count is very bad as the profile count from BFI will
be wrong.

A simple fix is to set the profile entry count to 1 if there are
non-zero profile counts in this function.

Differential Revision: https://reviews.llvm.org/D84378
llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
llvm/test/Transforms/PGOProfile/Inputs/fix_entry_count.proftext [new file with mode: 0644]
llvm/test/Transforms/PGOProfile/fix_entry_count.ll [new file with mode: 0644]