This is an archive of the discontinued LLVM Phabricator instance.

[FunctionAttrs] Introduce transitive call sites to represent callbacks
AbandonedPublic

Authored by jdoerfert on Aug 1 2018, 9:45 AM.

Details

Reviewers
hfinkel
chandlerc
Summary

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 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

Diff Detail

Event Timeline

jdoerfert created this revision.Aug 1 2018, 9:45 AM
jdoerfert abandoned this revision.Nov 6 2019, 10:02 PM

Abstract call sites are in and the Attributor can do IPO based on them.

Herald added a project: Restricted Project. · View Herald TranscriptNov 6 2019, 10:03 PM