[PATCH] D109632: [clang] de-duplicate methods from AST files

Richard Howell via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 16 14:27:10 PDT 2021


rmaz updated this revision to Diff 373072.
rmaz added a comment.

Update with single DenseSet per GlobalMethodPool


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D109632/new/

https://reviews.llvm.org/D109632

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaDeclObjC.cpp


Index: clang/lib/Sema/SemaDeclObjC.cpp
===================================================================
--- clang/lib/Sema/SemaDeclObjC.cpp
+++ clang/lib/Sema/SemaDeclObjC.cpp
@@ -3302,6 +3302,10 @@
 
 void Sema::addMethodToGlobalList(ObjCMethodList *List,
                                  ObjCMethodDecl *Method) {
+  // Do not insert duplicate methods into the method pool.
+  if (!MethodPool.addMethod(Method))
+    return;
+
   // Record at the head of the list whether there were 0, 1, or >= 2 methods
   // inside categories.
   if (ObjCCategoryDecl *CD =
Index: clang/include/clang/Sema/Sema.h
===================================================================
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -1431,9 +1431,13 @@
     }
     int count(Selector Sel) const { return Methods.count(Sel); }
     bool empty() const { return Methods.empty(); }
+    bool addMethod(ObjCMethodDecl *Method) {
+      return AddedMethods.insert(Method).second;
+    }
 
   private:
     llvm::DenseMap<Selector, Lists> Methods;
+    llvm::DenseSet<ObjCMethodDecl *> AddedMethods;
   };
 
   /// Method Pool - allows efficient lookup when typechecking messages to "id".


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109632.373072.patch
Type: text/x-patch
Size: 1197 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210916/832e06a4/attachment.bin>


More information about the cfe-commits mailing list