r184504 - When building a module, keep *all* declared methods in the global method pool.
Douglas Gregor
dgregor at apple.com
Thu Jun 20 17:20:25 PDT 2013
Author: dgregor
Date: Thu Jun 20 19:20:25 2013
New Revision: 184504
URL: http://llvm.org/viewvc/llvm-project?rev=184504&view=rev
Log:
When building a module, keep *all* declared methods in the global method pool.
As an optimization, we only kept declared methods with distinct
signatures in the global method pool, to keep the method lists
small. Under modules, however, one could have two different methods
with the same signature that occur in different (sub)modules. If only
the later submodule is important, message sends to 'id' with that
selector would fail because the first method (the only one that got
into the method pool) was hidden. When building a module, keep *all*
of the declared methods.
I did a quick check of both module build time and uses of modules, and
found no performance regression despite this causing us to keep more
methods in the global method pool. Fixes <rdar://problem/14148896>.
Modified:
cfe/trunk/lib/Sema/SemaDeclObjC.cpp
cfe/trunk/test/Modules/Inputs/MethodPoolBSub.h
cfe/trunk/test/Modules/Inputs/module.map
cfe/trunk/test/Modules/method_pool.m
Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=184504&r1=184503&r2=184504&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Thu Jun 20 19:20:25 2013
@@ -2130,6 +2130,10 @@ void Sema::addMethodToGlobalList(ObjCMet
// signature.
ObjCMethodList *Previous = List;
for (; List; Previous = List, List = List->getNext()) {
+ // If we are building a module, keep all of the methods.
+ if (getLangOpts().Modules && !getLangOpts().CurrentModule.empty())
+ continue;
+
if (!MatchTwoMethodDeclarations(Method, List->Method))
continue;
Modified: cfe/trunk/test/Modules/Inputs/MethodPoolBSub.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/MethodPoolBSub.h?rev=184504&r1=184503&r2=184504&view=diff
==============================================================================
--- cfe/trunk/test/Modules/Inputs/MethodPoolBSub.h (original)
+++ cfe/trunk/test/Modules/Inputs/MethodPoolBSub.h Thu Jun 20 19:20:25 2013
@@ -1,4 +1,5 @@
@interface B (Sub)
- (char *)method3;
- (char*)method4;
+- (id)method6;
@end
Modified: cfe/trunk/test/Modules/Inputs/module.map
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/module.map?rev=184504&r1=184503&r2=184504&view=diff
==============================================================================
--- cfe/trunk/test/Modules/Inputs/module.map (original)
+++ cfe/trunk/test/Modules/Inputs/module.map Thu Jun 20 19:20:25 2013
@@ -131,6 +131,10 @@ module MethodPoolA {
module MethodPoolB {
header "MethodPoolB.h"
+ explicit module Sub2 {
+ header "MethodPoolBSub2.h"
+ }
+
explicit module Sub {
header "MethodPoolBSub.h"
}
Modified: cfe/trunk/test/Modules/method_pool.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/method_pool.m?rev=184504&r1=184503&r2=184504&view=diff
==============================================================================
--- cfe/trunk/test/Modules/method_pool.m (original)
+++ cfe/trunk/test/Modules/method_pool.m Thu Jun 20 19:20:25 2013
@@ -47,6 +47,10 @@ void testMethod3Again(id object) {
char *str = [object method3]; // okay: only found in MethodPoolB.Sub
}
+void testMethod6(id object) {
+ [object method6];
+}
+
@import MethodPoolA.Sub;
void testMethod3AgainAgain(id object) {
More information about the cfe-commits
mailing list