[llvm] [BPF] Support for `DW_TAG_variant_part` in BTF generation (PR #155783)
Tamir Duberstein via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 17 11:58:01 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++;
----------------
tamird wrote:
Should this be nested to avoid a second `getDiscriminator()` call?
```c++
if (CTy->getTag() == dwarf::DW_TAG_variant_part) {
const auto *foo = CTy->getDiscriminator();
if (foo) {
visitTypeEntry(foo);
VLen++;
}
}
```
https://github.com/llvm/llvm-project/pull/155783
More information about the llvm-commits
mailing list