@@ -221,10 +221,9 @@ bool BPFAbstractMemberAccess::run(Function &F) {
221
221
222
222
void BPFAbstractMemberAccess::ResetMetadata (struct CallInfo &CInfo) {
223
223
if (auto Ty = dyn_cast<DICompositeType>(CInfo.Metadata )) {
224
- if (AnonRecords.find (Ty) != AnonRecords.end ()) {
225
- if (AnonRecords[Ty] != nullptr )
226
- CInfo.Metadata = AnonRecords[Ty];
227
- }
224
+ auto It = AnonRecords.find (Ty);
225
+ if (It != AnonRecords.end () && It->second != nullptr )
226
+ CInfo.Metadata = It->second ;
228
227
}
229
228
}
230
229
@@ -234,18 +233,12 @@ void BPFAbstractMemberAccess::CheckCompositeType(DIDerivedType *ParentTy,
234
233
ParentTy->getTag () != dwarf::DW_TAG_typedef)
235
234
return ;
236
235
237
- if (AnonRecords.find (CTy) == AnonRecords.end ()) {
238
- AnonRecords[CTy] = ParentTy;
239
- return ;
240
- }
241
-
236
+ auto [It, Inserted] = AnonRecords.try_emplace (CTy, ParentTy);
242
237
// Two or more typedef's may point to the same anon record.
243
238
// If this is the case, set the typedef DIType to be nullptr
244
239
// to indicate the duplication case.
245
- DIDerivedType *CurrTy = AnonRecords[CTy];
246
- if (CurrTy == ParentTy)
247
- return ;
248
- AnonRecords[CTy] = nullptr ;
240
+ if (!Inserted && It->second != ParentTy)
241
+ It->second = nullptr ;
249
242
}
250
243
251
244
void BPFAbstractMemberAccess::CheckDerivedType (DIDerivedType *ParentTy,
0 commit comments