<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Aug 23, 2015 at 8:33 PM, Richard Smith via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: rsmith<br>
Date: Sun Aug 23 22:33:22 2015<br>
New Revision: 245821<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=245821&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=245821&view=rev</a><br>
Log:<br>
[modules] Stop updating all identifiers when writing a module. This is<br>
unnecessary in C++ modules (where we don't need the identifiers for their<br>
Decls) and expensive.<br></blockquote><div><br></div><div>Why specifically C++ modules?</div><div><br></div><div>-- Sean Silva</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Modified:<br>
cfe/trunk/lib/Serialization/ASTReader.cpp<br>
cfe/trunk/lib/Serialization/ASTReaderInternals.h<br>
cfe/trunk/lib/Serialization/ASTWriter.cpp<br>
cfe/trunk/test/Modules/macros.c<br>
<br>
Modified: cfe/trunk/lib/Serialization/ASTReader.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=245821&r1=245820&r2=245821&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=245821&r1=245820&r2=245821&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)<br>
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Sun Aug 23 22:33:22 2015<br>
@@ -755,6 +755,12 @@ static bool readBit(unsigned &Bits) {<br>
return Value;<br>
}<br>
<br>
+IdentID ASTIdentifierLookupTrait::ReadIdentifierID(const unsigned char *d) {<br>
+ using namespace llvm::support;<br>
+ unsigned RawID = endian::readNext<uint32_t, little, unaligned>(d);<br>
+ return Reader.getGlobalIdentifierID(F, RawID >> 1);<br>
+}<br>
+<br>
IdentifierInfo *ASTIdentifierLookupTrait::ReadData(const internal_key_type& k,<br>
const unsigned char* d,<br>
unsigned DataLen) {<br>
@@ -3455,7 +3461,20 @@ ASTReader::ASTReadResult ASTReader::Read<br>
ASTIdentifierLookupTrait Trait(*this, F);<br>
auto KeyDataLen = Trait.ReadKeyDataLength(Data);<br>
auto Key = Trait.ReadKey(Data, KeyDataLen.first);<br>
- PP.getIdentifierTable().getOwn(Key).setOutOfDate(true);<br>
+ auto &II = PP.getIdentifierTable().getOwn(Key);<br>
+ II.setOutOfDate(true);<br>
+<br>
+ // Mark this identifier as being from an AST file so that we can track<br>
+ // whether we need to serialize it.<br>
+ if (!II.isFromAST()) {<br>
+ II.setIsFromAST();<br>
+ if (isInterestingIdentifier(*this, II, F.isModule()))<br>
+ II.setChangedSinceDeserialization();<br>
+ }<br>
+<br>
+ // Associate the ID with the identifier so that the writer can reuse it.<br>
+ auto ID = Trait.ReadIdentifierID(Data + KeyDataLen.first);<br>
+ SetIdentifierInfo(ID, &II);<br>
}<br>
}<br>
<br>
<br>
Modified: cfe/trunk/lib/Serialization/ASTReaderInternals.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderInternals.h?rev=245821&r1=245820&r2=245821&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderInternals.h?rev=245821&r1=245820&r2=245821&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Serialization/ASTReaderInternals.h (original)<br>
+++ cfe/trunk/lib/Serialization/ASTReaderInternals.h Sun Aug 23 22:33:22 2015<br>
@@ -137,6 +137,8 @@ public:<br>
const unsigned char* d,<br>
unsigned DataLen);<br>
<br>
+ IdentID ReadIdentifierID(const unsigned char *d);<br>
+<br>
ASTReader &getReader() const { return Reader; }<br>
};<br>
<br>
<br>
Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=245821&r1=245820&r2=245821&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=245821&r1=245820&r2=245821&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)<br>
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Sun Aug 23 22:33:22 2015<br>
@@ -4273,22 +4273,24 @@ void ASTWriter::WriteASTCore(Sema &SemaR<br>
}<br>
<br>
// Make sure all decls associated with an identifier are registered for<br>
- // serialization.<br>
- llvm::SmallVector<const IdentifierInfo*, 256> IIs;<br>
- for (IdentifierTable::iterator ID = PP.getIdentifierTable().begin(),<br>
- IDEnd = PP.getIdentifierTable().end();<br>
- ID != IDEnd; ++ID) {<br>
- const IdentifierInfo *II = ID->second;<br>
- if (!Chain || !II->isFromAST() || II->hasChangedSinceDeserialization())<br>
- IIs.push_back(II);<br>
- }<br>
- // Sort the identifiers to visit based on their name.<br>
- std::sort(IIs.begin(), IIs.end(), llvm::less_ptr<IdentifierInfo>());<br>
- for (const IdentifierInfo *II : IIs) {<br>
- for (IdentifierResolver::iterator D = SemaRef.IdResolver.begin(II),<br>
- DEnd = SemaRef.IdResolver.end();<br>
- D != DEnd; ++D) {<br>
- GetDeclRef(*D);<br>
+ // serialization, if we're storing decls with identifiers.<br>
+ if (!WritingModule || !getLangOpts().CPlusPlus) {<br>
+ llvm::SmallVector<const IdentifierInfo*, 256> IIs;<br>
+ for (IdentifierTable::iterator ID = PP.getIdentifierTable().begin(),<br>
+ IDEnd = PP.getIdentifierTable().end();<br>
+ ID != IDEnd; ++ID) {<br>
+ const IdentifierInfo *II = ID->second;<br>
+ if (!Chain || !II->isFromAST() || II->hasChangedSinceDeserialization())<br>
+ IIs.push_back(II);<br>
+ }<br>
+ // Sort the identifiers to visit based on their name.<br>
+ std::sort(IIs.begin(), IIs.end(), llvm::less_ptr<IdentifierInfo>());<br>
+ for (const IdentifierInfo *II : IIs) {<br>
+ for (IdentifierResolver::iterator D = SemaRef.IdResolver.begin(II),<br>
+ DEnd = SemaRef.IdResolver.end();<br>
+ D != DEnd; ++D) {<br>
+ GetDeclRef(*D);<br>
+ }<br>
}<br>
}<br>
<br>
<br>
Modified: cfe/trunk/test/Modules/macros.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/macros.c?rev=245821&r1=245820&r2=245821&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/macros.c?rev=245821&r1=245820&r2=245821&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/Modules/macros.c (original)<br>
+++ cfe/trunk/test/Modules/macros.c Sun Aug 23 22:33:22 2015<br>
@@ -2,8 +2,14 @@<br>
// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -x objective-c -verify -fmodules-cache-path=%t -I %S/Inputs %s<br>
// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -x objective-c -verify -fmodules-cache-path=%t -I %S/Inputs %s -DALT<br>
// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -x objective-c -verify -fmodules-cache-path=%t -I %S/Inputs %s -detailed-preprocessing-record<br>
-// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -DLOCAL_VISIBILITY -fmodules-local-submodule-visibility -x objective-c++ -verify -fmodules-cache-path=%t -I %S/Inputs %s<br>
// RUN: not %clang_cc1 -E -fmodules -fimplicit-module-maps -x objective-c -fmodules-cache-path=%t -I %S/Inputs %s | FileCheck -check-prefix CHECK-PREPROCESSED %s<br>
+//<br>
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -x objective-c++ -verify -fmodules-cache-path=%t -I %S/Inputs %s<br>
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -x objective-c++ -verify -fmodules-cache-path=%t -I %S/Inputs %s -DALT<br>
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -x objective-c++ -verify -fmodules-cache-path=%t -I %S/Inputs %s -detailed-preprocessing-record<br>
+// RUN: not %clang_cc1 -E -fmodules -fimplicit-module-maps -x objective-c++ -fmodules-cache-path=%t -I %S/Inputs %s | FileCheck -check-prefix CHECK-PREPROCESSED %s<br>
+//<br>
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -DLOCAL_VISIBILITY -fmodules-local-submodule-visibility -x objective-c++ -verify -fmodules-cache-path=%t -I %S/Inputs %s<br>
// FIXME: When we have a syntax for modules in C, use that.<br>
// These notes come from headers in modules, and are bogus.<br>
<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div></div>