This is an archive of the discontinued LLVM Phabricator instance.

Method pool in modules: sync up out of date selectors before writing the module
ClosedPublic

Authored by manmanren on Apr 28 2016, 12:35 PM.

Details

Reviewers
doug.gregor
Summary

Method Pool in modules: we make sure that if a module contains an entry for a selector, the entry should be complete, containing
everything introduced by that module and all modules it imports.

Before writing out the method pool of a module, we sync up the out of date selectors by pulling in methods for the selectors from all modules it imports.

In ReadMethodPool, after pulling in the method pool entry for module A, this lets us skip the modules that module A imports.

Diff Detail

Event Timeline

manmanren updated this revision to Diff 55458.Apr 28 2016, 12:35 PM
manmanren retitled this revision from to Method pool in modules: sync up out of date selectors before writing the module.
manmanren updated this object.
manmanren added a reviewer: doug.gregor.
manmanren added a subscriber: cfe-commits.
aprantl added inline comments.Apr 28 2016, 1:24 PM
include/clang/Serialization/ASTReader.h
657

///

test/Modules/method_pool_write.m
3

Is there anything meaningful that could be CHECKed in the output?

Adrian,

Thanks for reviewing the patch!

Manman

include/clang/Serialization/ASTReader.h
657

Yes.

test/Modules/method_pool_write.m
3

This commit makes sure that we don't emit an error message for not being able to find the method. That is why it checks for no diagnostics. Maybe I should use -fsyntax-only?

aprantl added inline comments.Apr 29 2016, 9:14 AM
test/Modules/method_pool_write.m
3

Using -fsyntax-only and expected-no-diagnostics is fine, too. I was just wondering whether it might make sense (or is possible at all) to check that the method was indeed found in the emitted IR on top of that.

doug.gregor edited edge metadata.Apr 29 2016, 11:15 AM

Mostly looks good, but see my comment about MapVector invalidation.

lib/Serialization/ASTWriter.cpp
4394

Are we certain that SelectorIDs cannot get updated during this iteration under any circumstances? If the underlying vector were to get reallocated, we'd end up with a horrible-to-reproduce use-after-free here. It might be worth copying SelectorIDs or indexing by an integer value rather than using the for-each loop.

manmanren updated this revision to Diff 55638.Apr 29 2016, 11:42 AM
manmanren edited edge metadata.

Addressing review comments from Doug and Adrian.

Manman

doug.gregor accepted this revision.Apr 29 2016, 11:43 AM
doug.gregor edited edge metadata.

LGTM!

This revision is now accepted and ready to land.Apr 29 2016, 11:43 AM
manmanren marked 3 inline comments as done.Apr 29 2016, 11:44 AM
manmanren added inline comments.
lib/Serialization/ASTWriter.cpp
4394

Nice catch. Thanks,

manmanren closed this revision.Jul 11 2016, 11:55 AM
manmanren marked an inline comment as done.

In r268091.