|  | 
| 18 | 18 | #include "llvm/CodeGen/AsmPrinter.h" | 
| 19 | 19 | #include "llvm/CodeGen/MachineModuleInfo.h" | 
| 20 | 20 | #include "llvm/CodeGen/MachineOperand.h" | 
|  | 21 | +#include "llvm/IR/DebugInfoMetadata.h" | 
| 21 | 22 | #include "llvm/IR/Module.h" | 
| 22 | 23 | #include "llvm/MC/MCContext.h" | 
| 23 | 24 | #include "llvm/MC/MCObjectFileInfo.h" | 
| 24 | 25 | #include "llvm/MC/MCSectionELF.h" | 
| 25 | 26 | #include "llvm/MC/MCStreamer.h" | 
|  | 27 | +#include "llvm/Support/Casting.h" | 
| 26 | 28 | #include "llvm/Support/LineIterator.h" | 
| 27 | 29 | #include "llvm/Support/MemoryBuffer.h" | 
| 28 | 30 | #include "llvm/Target/TargetLoweringObjectFile.h" | 
| @@ -976,11 +978,23 @@ void BTFDebug::visitMapDefType(const DIType *Ty, uint32_t &TypeId) { | 
| 976 | 978 |   if (Tag != dwarf::DW_TAG_structure_type || CTy->isForwardDecl()) | 
| 977 | 979 |     return; | 
| 978 | 980 | 
 | 
| 979 |  | -  // Visit all struct members to ensure pointee type is visited | 
|  | 981 | +  // Visit all struct members to ensure their types are visited. | 
| 980 | 982 |   const DINodeArray Elements = CTy->getElements(); | 
| 981 | 983 |   for (const auto *Element : Elements) { | 
| 982 | 984 |     const auto *MemberType = cast<DIDerivedType>(Element); | 
| 983 |  | -    visitTypeEntry(MemberType->getBaseType()); | 
|  | 985 | +    const DIType *MemberBaseType = MemberType->getBaseType(); | 
|  | 986 | + | 
|  | 987 | +    // If the member is a composite type, that may indicate the currently | 
|  | 988 | +    // visited composite type is a wrapper, and the member represents the | 
|  | 989 | +    // actual map definition. | 
|  | 990 | +    // In that case, visit the member with `visitMapDefType` instead of | 
|  | 991 | +    // `visitTypeEntry`, treating it specifically as a map definition rather | 
|  | 992 | +    // than as a regular composite type. | 
|  | 993 | +    const auto *MemberCTy = dyn_cast<DICompositeType>(MemberBaseType); | 
|  | 994 | +    if (MemberCTy) { | 
|  | 995 | +      visitMapDefType(MemberBaseType, TypeId); | 
|  | 996 | +    } else | 
|  | 997 | +      visitTypeEntry(MemberBaseType); | 
| 984 | 998 |   } | 
| 985 | 999 | 
 | 
| 986 | 1000 |   // Visit this type, struct or a const/typedef/volatile/restrict type | 
|  | 
0 commit comments