[PATCH] D39339: [CallGraph] Refine call graph for indirect calls with !callees metadata

Matthew Simpson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 26 11:35:56 PDT 2017


mssimpso created this revision.

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 legacy call graph analysis so that it considers this metadata when encountering indirect call sites. 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.

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.

I believe the new lazy call graph analysis already solves the function traversal problem, so I haven't made any updates there. But please correct me if I'm wrong.


https://reviews.llvm.org/D39339

Files:
  include/llvm/Analysis/CallGraph.h
  lib/Analysis/CallGraph.cpp
  test/Analysis/CallGraph/callees-metadata.ll
  test/Analysis/CallGraph/non-leaf-intrinsics.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39339.120457.patch
Type: text/x-patch
Size: 7673 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171026/b1bb78fb/attachment.bin>


More information about the llvm-commits mailing list