[PATCH] D103667: [WIP] BPF: add support for DWARF_AT_LLVM_annotations attribute
Yonghong Song via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 3 21:29:42 PDT 2021
yonghong-song created this revision.
yonghong-song added a reviewer: dblaikie.
yonghong-song added a project: debug-info.
Herald added subscribers: dexonsmith, dang, ormris, hiraditya.
yonghong-song requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.
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.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D103667
Files:
clang/include/clang/Basic/CodeGenOptions.def
clang/include/clang/Driver/Options.td
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/CodeGen/annotation-1.c
clang/test/CodeGen/annotation-2.c
llvm/include/llvm/BinaryFormat/Dwarf.def
llvm/include/llvm/IR/DebugInfoMetadata.h
llvm/lib/AsmParser/LLParser.cpp
llvm/lib/Bitcode/Reader/MetadataLoader.cpp
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h
llvm/lib/IR/AsmWriter.cpp
llvm/lib/IR/DIBuilder.cpp
llvm/lib/IR/DebugInfoMetadata.cpp
llvm/lib/IR/LLVMContextImpl.h
llvm/test/DebugInfo/annotation-1.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D103667.349764.patch
Type: text/x-patch
Size: 33143 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210604/311c98e0/attachment-0001.bin>
More information about the cfe-commits
mailing list