[PATCH] D106614: [Clang] add btf_tag attribute

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 28 05:39:54 PDT 2021


aaron.ballman added a comment.

This currently has no codegen, so it only adds the attribute to the AST and does nothing with it. Can you also add the codegen components to this patch?



================
Comment at: clang/include/clang/Basic/Attr.td:1835
+  let Args = [StringArgument<"BTFTag">];
+  let Subjects = SubjectList<[Var, Function, Record, Field], ErrorDiag>;
+  let Documentation = [BTFTagDocs];
----------------
ObjC method declarations?

Also, can this apply to *any* kind of variable declaration? e.g., does it do something useful on a `constexpr` variable that never gets emitted at runtime?


================
Comment at: clang/include/clang/Basic/AttrDocs.td:2019
+targets. This attribute may be attached to a struct/union, struct/union field,
+function or variables declaration. If -g is specified, the ARGUMENT info will
+be preserved in IR and be emitted to dwarf. For BPF target, the ARGUMENT info
----------------
yonghong-song wrote:
> anakryiko wrote:
> > can it be also applied to function's argument?
> The attribute does apply to function argument. I missed it in the documentation. Will add it.



================
Comment at: clang/include/clang/Basic/AttrDocs.td:2020
+function or variables declaration. If -g is specified, the ARGUMENT info will
+be preserved in IR and be emitted to dwarf. For BPF target, the ARGUMENT info
+will be emitted to .BTF ELF section too.
----------------



================
Comment at: clang/test/Sema/attr-btf_tag.c:15
+  return arg->a;
+}
----------------
There are quite a few test cases that are missing. Can you please add tests for applying the attribute to something invalid (like an enumeration), not given any arguments, given too many arguments.

Also missing are test cases for how this attribute merges on redeclarations, especially with conflicting arguments. e.g.,
```
void __attribute__((btf_tag("tag"))) bar();
void __attribute__((btf_tag("derp"))) bar() {} // Which argument "wins" or should this be an error?
```
Should it be valid to apply this to an incomplete structure declaration? e.g.,
```
struct __attribute__((btf_tag("tag"))) S; // Should this be valid or invalid?
```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106614/new/

https://reviews.llvm.org/D106614



More information about the cfe-commits mailing list