[all-commits] [llvm/llvm-project] 3ca174: [DebugInfo][BPF] Add 'annotations' field for DIBas...

eddyz87 via All-commits all-commits at lists.llvm.org
Tue Jun 18 00:23:46 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 3ca17443ef4af21bdb1f3b4fbcfff672cbc6176c
      https://github.com/llvm/llvm-project/commit/3ca17443ef4af21bdb1f3b4fbcfff672cbc6176c
  Author: eddyz87 <eddyz87 at gmail.com>
  Date:   2024-06-18 (Tue, 18 Jun 2024)

  Changed paths:
    M llvm/include/llvm/IR/DebugInfoMetadata.h
    M llvm/lib/AsmParser/LLParser.cpp
    M llvm/lib/Bitcode/Reader/MetadataLoader.cpp
    M llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
    M llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
    M llvm/lib/IR/AsmWriter.cpp
    M llvm/lib/IR/DebugInfoMetadata.cpp
    M llvm/lib/IR/LLVMContextImpl.h
    A llvm/test/Bitcode/attr-btf_tag-dibasic.ll
    A llvm/test/Bitcode/attr-btf_tag-disubroutine.ll
    M llvm/test/DebugInfo/attr-btf_type_tag.ll

  Log Message:
  -----------
  [DebugInfo][BPF] Add 'annotations' field for DIBasicType & DISubroutineType (#91422)

Extend `DIBasicType` and `DISubroutineType` with additional field
`annotations`, e.g. as below:

```
  !5 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed, annotations: !6)
  !6 = !{!7}
  !7 = !{!"btf:type_tag", !"tag1"}
```

The field would be used by BPF backend to generate DWARF attributes
corresponding to `btf_type_tag` type attributes, e.g.:

```
  0x00000029:   DW_TAG_base_type
                  DW_AT_name	("int")
                  DW_AT_encoding	(DW_ATE_signed)
                  DW_AT_byte_size	(0x04)

  0x0000002d:     DW_TAG_LLVM_annotation
                    DW_AT_name	("btf:type_tag")
                    DW_AT_const_value	("tag1")
```

Such DWARF entries would be used to generate BTF definitions by tools
like [pahole](https://github.com/acmel/dwarves).

Note: similar fields with similar purposes are already present in
DIDerivedType and DICompositeType.

Currently "btf_type_tag" attributes are represented in debug information
as 'annotations' fields in DIDerivedType with DW_TAG_pointer_type tag.
The annotation on a pointer corresponds to pointee having the attributes
in the final BTF.

The discussion in
[thread](https://lore.kernel.org/bpf/87r0w9jjoq.fsf@oracle.com/) came to
conclusion, that such annotations should apply to the annotated type
itself. Hence the necessity to extend `DIBasicType` & `DISubroutineType`
types with 'annotations' field to represent cases like below:

```
  int __attribute__((btf_type_tag("foo"))) bar;
```

This was previously tracked as differential revision:
https://reviews.llvm.org/D143966



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list