[llvm] [BPF] Support for `DW_TAG_variant_part` in BTF generation (PR #155783)

Michal R via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 12 12:30:48 PDT 2025


vadorovsky wrote:

Good catch!

> Meaning that in BTF union representing the variant part has to have three members, not two.

Given that:

* The discriminant takes the first 4 bytes.
* The other variants have the 4 byte offset
* Discriminant and variants have different memory location.

Wouldn't it be more correct to represent the variant part as a struct with two members - discriminant and union? 

Another option would be extending BTF to actually represent the variant part in a similar way to either LLVM DI or DWARF, showing the discriminant and variants explicitly.

https://github.com/llvm/llvm-project/pull/155783


More information about the llvm-commits mailing list