[PATCH] D114204: [CSSPGO] Sorting nodes in a cycle of profiled call graph.

Hongtao Yu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 18 16:14:38 PST 2021


hoy created this revision.
Herald added subscribers: ormris, modimo, wenlei, hiraditya, eraman, mgorny.
hoy requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

For nodes that are in a cycle of a profiled call graph, the current order the underlying scc_iter computes purely depends on how those nodes are reached from outside the SCC and inside the SCC, based on the Tarjan algorithm. This does not honor profile edge hotness, thus does not gurantee hot callsites to be inlined prior to cold callsites. To mitigate that, I'm adding an extra sorter on top of scc_iter to sort scc functions in the order of callsite hotness, instead of changing the internal of scc_iter.

Sorting on callsite hotness can be optimally based on detecting cycles on a directed call graph, i.e, to remove the coldest edge until a cycle is broken. However, detecting cycles isn't cheap. I'm using an MST-based approach which is faster and appear to deliver some performance wins.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114204

Files:
  llvm/include/llvm/Transforms/IPO/ProfiledCallGraph.h
  llvm/lib/Transforms/IPO/CMakeLists.txt
  llvm/lib/Transforms/IPO/ProfiledCallGraph.cpp
  llvm/lib/Transforms/IPO/SampleProfile.cpp
  llvm/test/Transforms/SampleProfile/Inputs/profile-context-order-scc.prof
  llvm/test/Transforms/SampleProfile/profile-context-order.ll
  llvm/tools/llvm-profgen/CSPreInliner.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D114204.388348.patch
Type: text/x-patch
Size: 17394 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211119/00517d82/attachment.bin>


More information about the llvm-commits mailing list