@@ -2115,24 +2115,24 @@ DIMacroFile *DIMacroFile::getImpl(LLVMContext &Context, unsigned MIType,
21152115 DEFINE_GETIMPL_STORE (DIMacroFile, (MIType, Line), Ops);
21162116}
21172117
2118- DIArgList *DIArgList::getImpl (LLVMContext &Context,
2119- ArrayRef<ValueAsMetadata *> Args,
2120- StorageType Storage, bool ShouldCreate) {
2121- DEFINE_GETIMPL_LOOKUP (DIArgList, (Args));
2122- DEFINE_GETIMPL_STORE_NO_OPS (DIArgList, (Args));
2118+ DIArgList *DIArgList::get (LLVMContext &Context,
2119+ ArrayRef<ValueAsMetadata *> Args) {
2120+ auto ExistingIt = Context.pImpl ->DIArgLists .find_as (DIArgListKeyInfo (Args));
2121+ if (ExistingIt != Context.pImpl ->DIArgLists .end ())
2122+ return *ExistingIt;
2123+ DIArgList *NewArgList = new DIArgList (Context, Args);
2124+ Context.pImpl ->DIArgLists .insert (NewArgList);
2125+ return NewArgList;
21232126}
21242127
21252128void DIArgList::handleChangedOperand (void *Ref, Metadata *New) {
21262129 ValueAsMetadata **OldVMPtr = static_cast <ValueAsMetadata **>(Ref);
21272130 assert ((!New || isa<ValueAsMetadata>(New)) &&
21282131 " DIArgList must be passed a ValueAsMetadata" );
21292132 untrack ();
2130- bool Uniq = isUniqued ();
2131- if (Uniq) {
2132- // We need to update the uniqueness once the Args are updated since they
2133- // form the key to the DIArgLists store.
2134- eraseFromStore ();
2135- }
2133+ // We need to update the set storage once the Args are updated since they
2134+ // form the key to the DIArgLists store.
2135+ getContext ().pImpl ->DIArgLists .erase (this );
21362136 ValueAsMetadata *NewVM = cast_or_null<ValueAsMetadata>(New);
21372137 for (ValueAsMetadata *&VM : Args) {
21382138 if (&VM == OldVMPtr) {
@@ -2142,28 +2142,19 @@ void DIArgList::handleChangedOperand(void *Ref, Metadata *New) {
21422142 VM = ValueAsMetadata::get (PoisonValue::get (VM->getValue ()->getType ()));
21432143 }
21442144 }
2145- if (Uniq) {
2146- // In the RemoveDIs project (eliminating debug-info-intrinsics), DIArgLists
2147- // can be referred to by DebugValueUser objects, which necessitates them
2148- // being unique and replaceable metadata. This causes a slight
2149- // performance regression that's to be avoided during the early stages of
2150- // the RemoveDIs prototype, see D154080.
2151- #ifdef EXPERIMENTAL_DEBUGINFO_ITERATORS
2152- MDNode *UniqueArgList = uniquify ();
2153- if (UniqueArgList != this ) {
2154- replaceAllUsesWith (UniqueArgList);
2155- // Clear this here so we don't try to untrack in the destructor.
2156- Args.clear ();
2157- delete this ;
2158- return ;
2159- }
2160- #else
2161- // Otherwise, don't fully unique, become distinct instead. See D108968,
2162- // there's a latent bug that presents here as nondeterminism otherwise.
2163- if (uniquify () != this )
2164- storeDistinctInContext ();
2165- #endif
2145+ // We've changed the contents of this DIArgList, and the set storage may
2146+ // already contain a DIArgList with our new set of args; if it does, then we
2147+ // must RAUW this with the existing DIArgList, otherwise we simply insert this
2148+ // back into the set storage.
2149+ DIArgList *ExistingArgList = getUniqued (getContext ().pImpl ->DIArgLists , this );
2150+ if (ExistingArgList) {
2151+ replaceAllUsesWith (ExistingArgList);
2152+ // Clear this here so we don't try to untrack in the destructor.
2153+ Args.clear ();
2154+ delete this ;
2155+ return ;
21662156 }
2157+ getContext ().pImpl ->DIArgLists .insert (this );
21672158 track ();
21682159}
21692160void DIArgList::track () {
@@ -2176,8 +2167,9 @@ void DIArgList::untrack() {
21762167 if (VAM)
21772168 MetadataTracking::untrack (&VAM, *VAM);
21782169}
2179- void DIArgList::dropAllReferences () {
2180- untrack ();
2170+ void DIArgList::dropAllReferences (bool Untrack) {
2171+ if (Untrack)
2172+ untrack ();
21812173 Args.clear ();
2182- MDNode::dropAllReferences ( );
2174+ ReplaceableMetadataImpl::resolveAllUses ( /* ResolveUsers */ false );
21832175}
0 commit comments