[PATCH] D41059: [PGO] MST min edge selection heuristic to ensure non-zero entry count

David Li via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Dec 10 15:20:01 PST 2017


davidxl created this revision.
Herald added a subscriber: sanjoy.

In many programs, event handling loop (not statically infinite) runs forever and the normal exit path is not executed unless there is error condition. Profile dumping can happen asynchronously. For such functions, if the entry block is not instrumented, we will get zero entry count which can be bad -- PGO relies on entry count to get BB count via scaling. See test case in https://reviews.llvm.org/D41058

This patch implements a new heuristic to select min edges -- if entry edges and exit edges have similar weight, prefer to select exit edges to be min edges.

This patch also fixes the problem with the real infinite loop case where entry count is zero.


https://reviews.llvm.org/D41059

Files:
  lib/Transforms/Instrumentation/CFGMST.h
  test/Transforms/PGOProfile/Inputs/landingpad.proftext
  test/Transforms/PGOProfile/Inputs/noreturncall.proftext
  test/Transforms/PGOProfile/branch1.ll
  test/Transforms/PGOProfile/counter_promo.ll
  test/Transforms/PGOProfile/infinite_loop_gen.ll
  test/Transforms/PGOProfile/landingpad.ll
  test/Transforms/PGOProfile/loop1.ll
  test/Transforms/PGOProfile/loop2.ll
  test/Transforms/PGOProfile/noreturncall.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41059.126303.patch
Type: text/x-patch
Size: 10655 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171210/57d09835/attachment.bin>


More information about the llvm-commits mailing list