In clang-scan-deps contexts, the number of interesting identifiers in PCM files is fairly low (only macros), while the number of identifiers in the importing instance is high (builtins). Marking the whole identifier table out-of-date triggers lots of benign and expensive calls to ASTReader::updateOutOfDateIdentifiers(). (That unfortunately happens even for unused identifiers due to SemaRef.IdResolver.begin(II) line in ASTWriter::WriteASTCore().)
This patch makes the main code path more similar to C++ modules, where the PCM files have INTERESTING_IDENTIFIERS section which lists identifiers that get created in the identifier table of the importing instance and marked as out-of-date. The only difference is that the main code path doesn't *create* identifiers in the table and relies on the importing instance calling ASTReader::get() when creating new identifier on-demand. It only marks existing identifiers as out-of-date.
This speeds up clang-scan-deps by 5-10%. Impact on explicitly built modules TBD.