diff gen/functions.cpp @ 940:39519a1ff603

Changed the way LDC determines if a template instantiation needs to get a definition, seems to speed up compile times quite a bit in some cases.
author Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
date Wed, 04 Feb 2009 18:48:03 +0100
parents cac9895be400
children 03d7c4aac654
line wrap: on
line diff
--- a/gen/functions.cpp	Wed Feb 04 18:39:39 2009 +0100
+++ b/gen/functions.cpp	Wed Feb 04 18:48:03 2009 +0100
@@ -486,20 +486,9 @@
     Type* t = fdecl->type->toBasetype();
     TypeFunction* f = (TypeFunction*)t;
 
-    bool declareOnly = false;
-    bool templInst = fdecl->parent && DtoIsTemplateInstance(fdecl->parent);
-    if (!templInst && fdecl->getModule() != gIR->dmodule)
-    {
-        Logger::println("not template instance, and not in this module. declare only!");
-        Logger::println("current module: %s", gIR->dmodule->ident->toChars());
-        if(fdecl->getModule())
-            Logger::println("func module: %s", fdecl->getModule()->ident->toChars());
-        else {
-            Logger::println("func not in a module, is runtime");
-        }
-        declareOnly = true;
-    }
-    else if (fdecl->llvmInternal == LLVMva_start)
+    bool declareOnly = !mustDefineSymbol(fdecl);
+
+    if (fdecl->llvmInternal == LLVMva_start)
         declareOnly = true;
 
     if (!fdecl->ir.irFunc) {
@@ -668,9 +657,8 @@
     llvm::Function* func = fd->ir.irFunc->func;
     const llvm::FunctionType* functype = func->getFunctionType();
 
-    // only members of the current module or template instances maybe be defined
-    if (!(fd->getModule() == gIR->dmodule || DtoIsTemplateInstance(fd->parent)))
-        return;
+    // sanity check
+    assert(mustDefineSymbol(fd));
 
     // set module owner
     fd->ir.DModule = gIR->dmodule;