[llvm] [BPF] Support wrapping BPF map structs into nested, single field structs (PR #144097)
Tamir Duberstein via llvm-commits
llvm-commits at lists.llvm.org
Sat Jun 14 09:32:21 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);
----------------
tamird wrote:
I think this suggestion came from the fact that the commit message and/or PR description haven't been updated?
https://github.com/llvm/llvm-project/pull/144097
More information about the llvm-commits
mailing list