# HG changeset patch # User Christian Kamm # Date 1234125886 -3600 # Node ID 780530d1cad3f52244ae60f185906fd41573f93d # Parent 9a10fa839dc5a18d096b1a60d6af2ad49bb05cba Revert templates to old behavior. While emitting a template instantiation only once is good for compile times and binary sizes, it doesn't work with linkonce linkage as inlined function bodies could be discarded. Since we don't want to inhibit inlining, templates are reverted to the previous behavior, where an instantiation is emitted for each module using it. In the future, a custom inlining pass may allow us to switch back to common/weak linkage and reenable smart template instance emission. diff -r 9a10fa839dc5 -r 780530d1cad3 dmd/template.c --- a/dmd/template.c Sun Feb 08 18:51:32 2009 +0100 +++ b/dmd/template.c Sun Feb 08 21:44:46 2009 +0100 @@ -2873,7 +2873,10 @@ this->havetempdecl = 0; this->isnested = NULL; this->errors = 0; + + // LDC this->tinst = NULL; + this->tmodule = NULL; } /***************** @@ -2988,6 +2991,7 @@ tmodule = tinst->tmodule; else tmodule = sc->module; + //printf("%s in %s\n", toChars(), tmodule->toChars()); #if LOG printf("\tdo semantic\n"); diff -r 9a10fa839dc5 -r 780530d1cad3 gen/llvmhelpers.cpp --- a/gen/llvmhelpers.cpp Sun Feb 08 18:51:32 2009 +0100 +++ b/gen/llvmhelpers.cpp Sun Feb 08 21:44:46 2009 +0100 @@ -1557,13 +1557,14 @@ bool mustDefineSymbol(Dsymbol* s) { -#if 0 +#if 1 return s->getModule() == gIR->dmodule || DtoIsTemplateInstance(s) != NULL; #else Module* M = DtoIsTemplateInstance(s); // if it's a template instance, check the instantiating module // not the module that defines the template if (M) { + //Logger::println("TINST %s from %s cur %s", s->toPrettyChars(), M->toChars(), gIR->dmodule->toChars()); return M == gIR->dmodule; } return s->getCompilationModule() == gIR->dmodule; @@ -1574,7 +1575,7 @@ bool needsTemplateLinkage(Dsymbol* s) { -#if 0 +#if 1 return DtoIsTemplateInstance(s) != NULL; #else Module* M = DtoIsTemplateInstance(s);