[PATCH] D50146: [FunctionAttrs] Introduce transitive call sites to represent callbacks

Johannes Doerfert via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 1 09:46:00 PDT 2018


jdoerfert created this revision.
jdoerfert added reviewers: hfinkel, chandlerc.
Herald added subscribers: bollu, mgorny.

This patch adds transitive call sites that represent a (potential) call
made by the callee of a direct call site. Thus, if assume we have three
functions that can call each other:

  foo --> bar --> baz

A transitive call site does now represent a call of baz in bar,
with regards to the values passed to bar when it is called in foo.

The reason transitive call sites are useful is because the code of the
"broker function", in the example above bar, might not be available.
However, if we know the function, or if recognized callbacks when we
analyzed its code at some earlier point, we can now make a connection
between the caller, foo in the above example, and the transitively
called value, here baz.

The first "real" use case for this extensions are outlined functions
passed to OpenMP runtime calls. Providing proper annotations for these
(see also https://reviews.llvm.org/D50125) has already proven to have a significant performance
impact [1,2].  However, there are also other kinds of callbacks which
often heavily restrict the set of applied optimizations.

To show how transitive call sites can be used, we added logic that can
deduce parameter attributes for call sites to broker functions. Though,
in this initial version we simply assume that a function with the
callback annotation will only "pass through" all arguments that are
referenced by the annotation. Thus, these arguments are not inspected,
nor captured by the broker function. As this might be too restrictive
for custom callbacks, we should look into a "passthrough" attribute for
arguments or some other encoding that allows us to match parameter to
arguments.

[1] http://compilers.cs.uni-saarland.de/people/doerfert/par_opt18.pdf
[2] https://llvm.org/devmtg/2018-04/talks.html#Talk_1


Repository:
  rL LLVM

https://reviews.llvm.org/D50146

Files:
  include/llvm/IR/CallSite.h
  lib/Analysis/CMakeLists.txt
  lib/Analysis/CallbackInfo.cpp
  lib/Transforms/IPO/FunctionAttrs.cpp
  test/Transforms/FunctionAttrs/transitive_call.ll
  test/Transforms/FunctionAttrs/transitive_var_arg_call.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50146.158558.patch
Type: text/x-patch
Size: 29137 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180801/599f548a/attachment-0001.bin>


More information about the llvm-commits mailing list