<div class="gmail_quote">On 12 December 2010 13:36, Chandler Carruth <span dir="ltr"><<a href="mailto:chandlerc@gmail.com">chandlerc@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Author: chandlerc<br>
Date: Sun Dec 12 15:36:11 2010<br>
New Revision: 121644<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=121644&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=121644&view=rev</a><br>
Log:<br>
Move the functionality to mark all vtables of key functions as used within<br>
a translation unit to the ActOnEndOfTranslationUnit function instead of doing<br>
it at the start of DefineUsedVTables. The latter is now called *recursively*<br>
during template instantiation, which causes an absolutely insane number of<br>
walks of every record decl in the translation unit.<br>
<br>
After this patch, an extremely template instantiation heavy test case's compile<br>
time drops by 10x, and we see between 15% and 20% improvement in average<br>
compile times across a project. This is just recovering a regression, it<br>
doesn't make anything faster than it was several weeks ago.<br></blockquote><div><br>Ouch! Sorry about that, and thank you for the fix!!<br><br>Nick<br><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
Modified:<br>
cfe/trunk/lib/Sema/Sema.cpp<br>
cfe/trunk/lib/Sema/SemaDeclCXX.cpp<br>
<br>
Modified: cfe/trunk/lib/Sema/Sema.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=121644&r1=121643&r2=121644&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=121644&r1=121643&r2=121644&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Sema/Sema.cpp (original)<br>
+++ cfe/trunk/lib/Sema/Sema.cpp Sun Dec 12 15:36:11 2010<br>
@@ -285,6 +285,18 @@<br>
// At PCH writing, implicit instantiations and VTable handling info are<br>
// stored and performed when the PCH is included.<br>
if (CompleteTranslationUnit) {<br>
+ // If any dynamic classes have their key function defined within<br>
+ // this translation unit, then those vtables are considered "used" and must<br>
+ // be emitted.<br>
+ for (unsigned I = 0, N = DynamicClasses.size(); I != N; ++I) {<br>
+ if (const CXXMethodDecl *KeyFunction<br>
+ = Context.getKeyFunction(DynamicClasses[I])) {<br>
+ const FunctionDecl *Definition = 0;<br>
+ if (KeyFunction->hasBody(Definition))<br>
+ MarkVTableUsed(Definition->getLocation(), DynamicClasses[I], true);<br>
+ }<br>
+ }<br>
+<br>
// If DefinedUsedVTables ends up marking any virtual member functions it<br>
// might lead to more pending template instantiations, which we then need<br>
// to instantiate.<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=121644&r1=121643&r2=121644&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=121644&r1=121643&r2=121644&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Sun Dec 12 15:36:11 2010<br>
@@ -6895,21 +6895,9 @@<br>
}<br>
<br>
bool Sema::DefineUsedVTables() {<br>
- // If any dynamic classes have their key function defined within<br>
- // this translation unit, then those vtables are considered "used" and must<br>
- // be emitted.<br>
- for (unsigned I = 0, N = DynamicClasses.size(); I != N; ++I) {<br>
- if (const CXXMethodDecl *KeyFunction<br>
- = Context.getKeyFunction(DynamicClasses[I])) {<br>
- const FunctionDecl *Definition = 0;<br>
- if (KeyFunction->hasBody(Definition))<br>
- MarkVTableUsed(Definition->getLocation(), DynamicClasses[I], true);<br>
- }<br>
- }<br>
-<br>
if (VTableUses.empty())<br>
return false;<br>
-<br>
+<br>
// Note: The VTableUses vector could grow as a result of marking<br>
// the members of a class as "used", so we check the size each<br>
// time through the loop and prefer indices (with are stable) to<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br>