Add a new LLVM custom attribute DWARF_AT_LLVM_annotation
so attributes with attribute((annotate("..."))) can be
passed to the dwarf debug_info. Please see
https://reviews.llvm.org/D103549 on why BPF community
wants this feature.
This patch added supports for annotation attributes
for global/local variables (including parameters),
static/global functions, record (struct/union) types
and record fields.
This is still work-in-progress. I would like to get feedback
on my current approach.
First, I named the new attribute as DWARF_AT_LLVM_annotations.
I avoided to use BTF/BPF in the name as this doesn't need
to be BPF specific and some other tools might find this useful
in the future.
Second, we don't want to emit DWARF_AT_LLVM_annotations by
default. Two reasons, first, the initial implementation will
be incomplete and heavily geared to BPF use case; second,
this is unlikely to be used outside BPF community initially.
So exposing to other users sounds unnecessary. So I added
a flag -gannotations to control the feature.
If -gannotations is not specified, DWARF_AT_LLVM_annotations
will not be generated.
Third, it is desirable to add IR/BitCode read/write support for
annotations. This will help writing tests too. I only
implemented for DIGlobalVariable. I am pretty sure that
my implementation may have some issues. It
be good to get some feedback before I continues.