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