@@ -773,31 +773,15 @@ void BTFDebug::visitTypeEntry(const DIType *Ty, uint32_t &TypeId,
773773 // already defined, we should keep moving to eventually
774774 // bring in types for "struct t". Otherwise, the "struct s2"
775775 // definition won't be correct.
776- //
777- // In the above, we have following debuginfo:
778- // {ptr, struct_member} -> typedef -> struct
779- // and BTF type for 'typedef' is generated while 'struct' may
780- // be in FixUp. But let us generalize the above to handle
781- // {different types} -> [various derived types]+ -> another type.
782- // For example,
783- // {func_param, struct_member} -> const -> ptr -> volatile -> struct
784- // We will traverse const/ptr/volatile which already have corresponding
785- // BTF types and generate type for 'struct' which might be in Fixup
786- // state.
787776 if (Ty && (!CheckPointer || !SeenPointer)) {
788777 if (const auto *DTy = dyn_cast<DIDerivedType>(Ty)) {
789- while (DTy) {
790- const DIType *BaseTy = DTy->getBaseType ();
791- if (!BaseTy)
792- break ;
793-
794- if (DIToIdMap.find (BaseTy) != DIToIdMap.end ()) {
795- DTy = dyn_cast<DIDerivedType>(BaseTy);
796- } else {
797- uint32_t TmpTypeId;
798- visitTypeEntry (BaseTy, TmpTypeId, CheckPointer, SeenPointer);
799- break ;
800- }
778+ unsigned Tag = DTy->getTag ();
779+ if (Tag == dwarf::DW_TAG_typedef || Tag == dwarf::DW_TAG_const_type ||
780+ Tag == dwarf::DW_TAG_volatile_type ||
781+ Tag == dwarf::DW_TAG_restrict_type) {
782+ uint32_t TmpTypeId;
783+ visitTypeEntry (DTy->getBaseType (), TmpTypeId, CheckPointer,
784+ SeenPointer);
801785 }
802786 }
803787 }
0 commit comments