[PATCH] D140929: [BPF] Support for "btf_decl_tag" annotations for arguments of extern functions

Eduard Zingerman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 3 16:39:45 PST 2023


eddyz87 created this revision.
Herald added a subscriber: hiraditya.
Herald added a project: All.
eddyz87 retitled this revision from "This series of patches adds support for "btf_decl_tag" annotations
for arguments of extern functions. Patch descriptions follow.

[BPF] Triple::isBPF() utility method" to "[BPF] Support for "btf_decl_tag" annotations for arguments of extern functions".
eddyz87 edited the summary of this revision.
eddyz87 published this revision for review.
eddyz87 added a reviewer: yonghong-song.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

This adds support for "btf_decl_tag" annotations for arguments of extern functions. The changes are split into several commits:

- `Triple::isBPF() utility method` -- adds a simple utility method for llvm::Triple class;
- `preserve btf_decl_tag for parameters of extern functions` -- modifies CLang frontend to generate DILocalVariable entries with attached "btf_dec_tag" annotations for parameters of extern functions;
- `generate btf_decl_tag records for params of extern functions` -- modifies BPF backend to process "btf_decl_tag" annotations for parameters of extern functions.

Below are descriptions for the last two commits:

Preserve btf_decl_tag for parameters of extern functions
--------------------------------------------------------

Generate DILocalVariable entries for parameters of extern functions, the "annotations" field of DILocalVariable is used to link "btf_decl_tag" annotation with the parameter.

Do this only for BPF backend as there are no other users for this information. Final DWARF is valid as "Appendix A" is very much lax in
what is allowed as attributes for "DW_TAG_formal_parameter":

> DWARF does not in general require that a given debugging information entry contain a particular attribute or set of attributes. Instead, a DWARF producer is free to generate any, all, or none of the attributes ... other attributes ... may also appear in a given  debugging information entry.

DWARF Debugging Information Format Version 5,
Appendix A: Attributes by Tag Value (Informative)
Page 251, Line 3.

Generate btf_decl_tag records for params of extern functions
------------------------------------------------------------

After frontend changes in the following commit: "BPF: preserve btf_decl_tag for parameters of extern functions" same mechanics could be used to get the list of function parameters and associated btf_decl_tag entries for both extern and non-extern functions.

This commit extracts this mechanics as a separate auxiliary function BTFDebug::processDISubprogram(). The function is called for both
extern and non-extern functions in order to generated corresponding BTF_DECL_TAG records.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D140929

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGen/bpf-decl-tag-extern-func-args.c
  llvm/include/llvm/TargetParser/Triple.h
  llvm/lib/Target/BPF/BTFDebug.cpp
  llvm/lib/Target/BPF/BTFDebug.h
  llvm/test/CodeGen/BPF/BTF/tag-extern-func.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D140929.486116.patch
Type: text/x-patch
Size: 12354 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230104/a6314f59/attachment-0001.bin>


More information about the cfe-commits mailing list