[llvm] [BPF] Support for `DW_TAG_variant_part` in BTF generation (PR #155783)
Michal R via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 20 03:34:23 PDT 2025
================
@@ -672,16 +714,23 @@ void BTFDebug::visitStructType(const DICompositeType *CTy, bool IsStruct,
uint32_t &TypeId) {
const DINodeArray Elements = CTy->getElements();
uint32_t VLen = Elements.size();
+ // Variant parts have a discriminator. LLVM DI doesn't consider it as an
+ // element and instead keeps it as a separate reference. But we represent it
+ // as an element in BTF.
+ if (CTy->getTag() == dwarf::DW_TAG_variant_part)
+ VLen++;
----------------
vadorovsky wrote:
Sorry, should be done for real. I also agree with @tamird's point about extracting the `getDiscriminator` call - done here and in one other place.
https://github.com/llvm/llvm-project/pull/155783
More information about the llvm-commits
mailing list