-
Notifications
You must be signed in to change notification settings - Fork 12.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A new attribute btf_tag is added. The syntax looks like __attribute__((btf_tag(<string>))) Users may tag a particular structure/member/function/func_parameter/variable declaration with an arbitrary string and the intention is that this string is passed to dwarf so it is available for post-compilation analysis. The string will be also passed to .BTF section if the target is BPF. For each permitted declaration, multiple btf_tag's are allowed. For detailed use cases, please see https://lists.llvm.org/pipermail/llvm-dev/2021-June/151009.html In case that there exist redeclarations, the btf_tag attributes will be accumulated along with different declarations, and the last declaration will contain all attributes. Differential Revision: https://reviews.llvm.org/D106614
- Loading branch information
1 parent
adb96d2
commit 1b194ef
Showing
7 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// RUN: %clang_cc1 -x c -triple x86_64-pc-linux-gnu -dwarf-version=4 -fsyntax-only -verify %s | ||
|
||
#define __tag1 __attribute__((btf_tag("tag1"))) | ||
#define __tag2 __attribute__((btf_tag("tag2"))) | ||
#define __tag3 __attribute__((btf_tag("tag3"))) | ||
|
||
#define __tag_no_arg __attribute__((btf_tag())) | ||
#define __tag_2_arg __attribute__((btf_tag("tag1", "tag2"))) | ||
#define __invalid __attribute__((btf_tag(1))) | ||
|
||
struct __tag1 __tag2 t1; | ||
struct t1 { | ||
int a __tag1; | ||
} __tag3; | ||
|
||
struct __tag1 t2; | ||
struct __tag2 __tag3 t2 { | ||
int a __tag1; | ||
}; | ||
|
||
int g1 __tag1; | ||
int g2 __tag_no_arg; // expected-error {{'btf_tag' attribute takes one argument}} | ||
int g3 __tag_2_arg; // expected-error {{'btf_tag' attribute takes one argument}} | ||
int i1 __invalid; // expected-error {{'btf_tag' attribute requires a string}} | ||
|
||
enum e1 { | ||
E1 | ||
} __tag1; // expected-error {{'btf_tag' attribute only applies to variables, functions, structs, unions, classes, and non-static data members}} | ||
|
||
enum e2 { | ||
E2 | ||
} __tag_no_arg; // expected-error {{'btf_tag' attribute only applies to variables, functions, structs, unions, classes, and non-static data members}} | ||
|
||
enum e3 { | ||
E3 | ||
} __tag_2_arg; // expected-error {{'btf_tag' attribute only applies to variables, functions, structs, unions, classes, and non-static data members}} | ||
|
||
int __tag1 __tag2 foo(struct t1 *arg, struct t2 *arg2); | ||
int __tag2 __tag3 foo(struct t1 *arg, struct t2 *arg2); | ||
int __tag1 foo(struct t1 *arg __tag1, struct t2 *arg2) { | ||
return arg->a + arg2->a; | ||
} |