[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 Sep 1 07:10:20 PDT 2025


================
@@ -696,10 +710,14 @@ void BTFDebug::visitStructType(const DICompositeType *CTy, bool IsStruct,
   // Visit all struct members.
   int FieldNo = 0;
   for (const auto *Element : Elements) {
-    const auto Elem = cast<DIDerivedType>(Element);
-    visitTypeEntry(Elem);
-    processDeclAnnotations(Elem->getAnnotations(), TypeId, FieldNo);
-    FieldNo++;
+    if (const auto *Elem = dyn_cast<DIDerivedType>(Element)) {
+      visitTypeEntry(Elem);
+      processDeclAnnotations(Elem->getAnnotations(), TypeId, FieldNo);
+      FieldNo++;
+    } else if (const auto *Elem = dyn_cast<DICompositeType>(Element)) {
+      auto Tag = CTy->getTag();
+      visitStructType(Elem, Tag == dwarf::DW_TAG_structure_type, TypeId);
----------------
vadorovsky wrote:

Done

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


More information about the llvm-commits mailing list