This is an archive of the discontinued LLVM Phabricator instance.

[clang] Properly cache member pointer LLVM types
ClosedPublic

Authored by aeubanks on Feb 7 2022, 10:05 PM.

Details

Summary

When not going through the main Clang->LLVM type cache, we'd
accidentally create multiple different opaque types for a member pointer
type.

This allows us to remove the -verify-type-cache flag now that
check-clang passes with it on. We can do the verification in expensive
builds. Previously microsoft-abi-member-pointers.cpp was failing with
-verify-type-cache.

I suspect that there may be more issues when we have multiple member
pointer types and we clear the cache, but we can leave that for later.

Followup to D118744.

Diff Detail

Event Timeline

aeubanks requested review of this revision.Feb 7 2022, 10:05 PM
aeubanks created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptFeb 7 2022, 10:05 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
rnk added a comment.Feb 8 2022, 9:53 AM

Seems reasonable

clang/lib/CodeGen/CodeGenTypes.cpp
776

Can this use something like the insert get-or-create pattern?

auto Insertion = RecordsWithOpaqueMemberPointers.insert({C, StructType*{}});
if (Insertion.second) Insertion.first->second = llvm::StructType::create(...);
return Insertion.first->second;
rnk accepted this revision.Feb 8 2022, 11:45 AM

lgtm

This revision is now accepted and ready to land.Feb 8 2022, 11:45 AM
This revision was landed with ongoing or failed builds.Feb 8 2022, 1:22 PM
This revision was automatically updated to reflect the committed changes.