[llvm] [BPF] Handle nested wrapper structs in BPF map definition traversal (PR #144097)
Michal Rostecki via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 16 00:35:43 PDT 2025
================
@@ -976,11 +978,23 @@ void BTFDebug::visitMapDefType(const DIType *Ty, uint32_t &TypeId) {
if (Tag != dwarf::DW_TAG_structure_type || CTy->isForwardDecl())
return;
- // Visit all struct members to ensure pointee type is visited
+ // Visit all struct members to ensure their types are visited.
const DINodeArray Elements = CTy->getElements();
for (const auto *Element : Elements) {
const auto *MemberType = cast<DIDerivedType>(Element);
- visitTypeEntry(MemberType->getBaseType());
+ const DIType *MemberBaseType = MemberType->getBaseType();
+
+ // If the member is a composite type, that may indicate the currently
+ // visited composite type is a wrapper, and the member represents the
+ // actual map definition.
+ // In that case, visit the member with `visitMapDefType` instead of
+ // `visitTypeEntry`, treating it specifically as a map definition rather
+ // than as a regular composite type.
+ const auto *MemberCTy = dyn_cast<DICompositeType>(MemberBaseType);
+ if (MemberCTy) {
+ visitMapDefType(MemberBaseType, TypeId);
+ } else
+ visitTypeEntry(MemberBaseType);
----------------
vadorovsky wrote:
Done
https://github.com/llvm/llvm-project/pull/144097
More information about the llvm-commits
mailing list