mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-25 06:46:05 +00:00

With commit r351627, LLVM gained the ability to apply (existing) IPO optimizations on indirections through callbacks, or transitive calls. The general idea is that we use an abstraction to hide the middle man and represent the callback call in the context of the initial caller. It is described in more detail in the commit message of the LLVM patch r351627, the llvm::AbstractCallSite class description, and the language reference section on callback-metadata. This commit enables clang to emit !callback metadata that is understood by LLVM. It does so in three different cases: 1) For known broker functions declarations that are directly generated, e.g., __kmpc_fork_call for the OpenMP pragma parallel. 2) For known broker functions that are identified by their name and source location through the builtin detection, e.g., pthread_create from the POSIX thread API. 3) For user annotated functions that carry the "callback(callee, ...)" attribute. The attribute has to include the name, or index, of the callback callee and how the passed arguments can be identified (as many as the callback callee has). See the callback attribute documentation for detailed information. Differential Revision: https://reviews.llvm.org/D55483 llvm-svn: 351629
15 lines
934 B
C
15 lines
934 B
C
// RUN: %clang_cc1 %s -verify -fsyntax-only
|
|
|
|
// expected-no-diagnostics
|
|
|
|
__attribute__((callback(1))) void no_args(void (*callback)(void));
|
|
__attribute__((callback(1, 2, 3))) void args_1(void (*callback)(int, double), int a, double b);
|
|
__attribute__((callback(2, 3, 3))) void args_2(int a, void (*callback)(double, double), double b);
|
|
__attribute__((callback(2, -1, -1))) void args_3(int a, void (*callback)(double, double), double b);
|
|
|
|
__attribute__((callback(callback))) void no_argsb(void (*callback)(void));
|
|
__attribute__((callback(callback, a, 3))) void args_1b(void (*callback)(int, double), int a, double b);
|
|
__attribute__((callback(callback, b, b))) void args_2b(int a, void (*callback)(double, double), double b);
|
|
__attribute__((callback(2, __, __))) void args_3b(int a, void (*callback)(double, double), double b);
|
|
__attribute__((callback(callback, -1, __))) void args_3c(int a, void (*callback)(double, double), double b);
|