Page MenuHomePhabricator

[CallGraph] Refine call graph for indirect calls with !callees metadata
Needs ReviewPublic

Authored by mssimpso on Oct 26 2017, 11:35 AM.



For indirect call sites having a small set of possible callees, !callees metadata can be used to indicate what those callees are. This patch updates the call graph and lazy call graph analyses so that they consider this metadata when encountering call sites. For the call graph, it adds a new external call graph node to the graph for each unique !callees metadata node. A call graph edge connects an indirect call site with the external node associated with the !callees metadata that is attached to it. And there is an edge from this external node to each of the callees indicated by the metadata. Similarly, for the lazy call graph, the patch adds Ref edges from a caller to the possible callees indicated by the metadata.

The primary purpose of the patch is to facilitate iterating over the functions in a module such that all of the callees indicated by a given !callees metadata node will be visited prior to the functions containing call sites annotated by that node. This property is required by optimizations performing a bottom-up traversal of the SCC DAG. For example, the inliner can be made to inline through an indirect call. If the call site is annotated with !callees metadata, this patch ensures that the inliner will have visited all of the callees prior to the caller, allowing it to reliably compute the cost of inlining one or more of the potential callees.

Diff Detail

Event Timeline

mssimpso created this revision.Oct 26 2017, 11:35 AM
mssimpso updated this revision to Diff 122317.Nov 9 2017, 1:52 PM
mssimpso edited the summary of this revision. (Show Details)
  • Incorporated the change into the lazy call graph as well. The metadata is represented as ref edges there.
  • Added a helper in CallSite to get the functions listed in the metadata.
fhahn added a subscriber: fhahn.Nov 10 2017, 2:01 AM
mssimpso updated this revision to Diff 141407.Apr 6 2018, 12:57 PM

Updated to work with the latest revision of D39869.

davidxl added a subscriber: davidxl.