[PATCH] D39869: [Inliner] Inline through indirect call sites having !callees metadata

Matthew Simpson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 9 13:53:08 PST 2017


mssimpso created this revision.
Herald added subscribers: eraman, mgorny, mehdi_amini.

This patch allows the inliner to inspect !callees metadata attached to an indirect call site, and then inline the subset of callees for which inlining is profitable. The inlined code is conditionally executed depending on the run-time value of the call site's function pointer. !callees metadata is attached to an indirect call by the called value propagation pass and indicates the set of functions the call site might call.

Functionally, the patch versions an indirect call site for each possible callee that can be inlined, and then promotes those call sites to direct calls. An indirect version of the call site remains if it can call more than two functions that cannot be inlined; otherwise, the indirect call site is fully promoted. Since inline cost is used as the heuristic for promotion as well as inlining, the cost is saved after promotion to avoid recomputing it during the actual inlining step. Although call site promotion based on !callees metadata could conceivably be performed as a stand-alone pass, performing it in the inliner avoids extra work, since inline cost is used as the determining measure. Moreover, knowing if a callee will be inlined is probably one of the most reasonable static estimates of whether a call site should be promoted.

A dependent revision (https://reviews.llvm.org/D39339) modifies the call graph analyses to consider !callees metadata. It ensures the inliner will visit all of the functions listed in a given !callees metadata node prior to the functions containing call sites annotated by that node. This means the inliner's normal bottom-up traversal of the call graph is valid when promoting and then inlining the subset of possible callees.


https://reviews.llvm.org/D39869

Files:
  include/llvm/Transforms/Utils/CallSitePromotion.h
  lib/Transforms/IPO/Inliner.cpp
  lib/Transforms/Utils/CMakeLists.txt
  lib/Transforms/Utils/CallSitePromotion.cpp
  test/Other/new-pm-defaults.ll
  test/Other/new-pm-thinlto-defaults.ll
  test/Transforms/Inline/callees-metadata.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39869.122320.patch
Type: text/x-patch
Size: 38139 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171109/0ae45551/attachment.bin>


More information about the llvm-commits mailing list