comparison 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
comparison
equal deleted inserted replaced
939:cac9895be400 940:39519a1ff603
484 484
485 // get TypeFunction* 485 // get TypeFunction*
486 Type* t = fdecl->type->toBasetype(); 486 Type* t = fdecl->type->toBasetype();
487 TypeFunction* f = (TypeFunction*)t; 487 TypeFunction* f = (TypeFunction*)t;
488 488
489 bool declareOnly = false; 489 bool declareOnly = !mustDefineSymbol(fdecl);
490 bool templInst = fdecl->parent && DtoIsTemplateInstance(fdecl->parent); 490
491 if (!templInst && fdecl->getModule() != gIR->dmodule) 491 if (fdecl->llvmInternal == LLVMva_start)
492 {
493 Logger::println("not template instance, and not in this module. declare only!");
494 Logger::println("current module: %s", gIR->dmodule->ident->toChars());
495 if(fdecl->getModule())
496 Logger::println("func module: %s", fdecl->getModule()->ident->toChars());
497 else {
498 Logger::println("func not in a module, is runtime");
499 }
500 declareOnly = true;
501 }
502 else if (fdecl->llvmInternal == LLVMva_start)
503 declareOnly = true; 492 declareOnly = true;
504 493
505 if (!fdecl->ir.irFunc) { 494 if (!fdecl->ir.irFunc) {
506 fdecl->ir.irFunc = new IrFunction(fdecl); 495 fdecl->ir.irFunc = new IrFunction(fdecl);
507 } 496 }
666 assert(f->ir.type); 655 assert(f->ir.type);
667 656
668 llvm::Function* func = fd->ir.irFunc->func; 657 llvm::Function* func = fd->ir.irFunc->func;
669 const llvm::FunctionType* functype = func->getFunctionType(); 658 const llvm::FunctionType* functype = func->getFunctionType();
670 659
671 // only members of the current module or template instances maybe be defined 660 // sanity check
672 if (!(fd->getModule() == gIR->dmodule || DtoIsTemplateInstance(fd->parent))) 661 assert(mustDefineSymbol(fd));
673 return;
674 662
675 // set module owner 663 // set module owner
676 fd->ir.DModule = gIR->dmodule; 664 fd->ir.DModule = gIR->dmodule;
677 665
678 // is there a body? 666 // is there a body?