Mercurial > projects > ldc
comparison gen/llvmhelpers.cpp @ 948:780530d1cad3
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.
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Sun, 08 Feb 2009 21:44:46 +0100 |
parents | 9a10fa839dc5 |
children | ae710cba0884 |
comparison
equal
deleted
inserted
replaced
947:9a10fa839dc5 | 948:780530d1cad3 |
---|---|
1555 | 1555 |
1556 ////////////////////////////////////////////////////////////////////////////////////////// | 1556 ////////////////////////////////////////////////////////////////////////////////////////// |
1557 | 1557 |
1558 bool mustDefineSymbol(Dsymbol* s) | 1558 bool mustDefineSymbol(Dsymbol* s) |
1559 { | 1559 { |
1560 #if 0 | 1560 #if 1 |
1561 return s->getModule() == gIR->dmodule || DtoIsTemplateInstance(s) != NULL; | 1561 return s->getModule() == gIR->dmodule || DtoIsTemplateInstance(s) != NULL; |
1562 #else | 1562 #else |
1563 Module* M = DtoIsTemplateInstance(s); | 1563 Module* M = DtoIsTemplateInstance(s); |
1564 // if it's a template instance, check the instantiating module | 1564 // if it's a template instance, check the instantiating module |
1565 // not the module that defines the template | 1565 // not the module that defines the template |
1566 if (M) { | 1566 if (M) { |
1567 //Logger::println("TINST %s from %s cur %s", s->toPrettyChars(), M->toChars(), gIR->dmodule->toChars()); | |
1567 return M == gIR->dmodule; | 1568 return M == gIR->dmodule; |
1568 } | 1569 } |
1569 return s->getCompilationModule() == gIR->dmodule; | 1570 return s->getCompilationModule() == gIR->dmodule; |
1570 #endif | 1571 #endif |
1571 } | 1572 } |
1572 | 1573 |
1573 ////////////////////////////////////////////////////////////////////////////////////////// | 1574 ////////////////////////////////////////////////////////////////////////////////////////// |
1574 | 1575 |
1575 bool needsTemplateLinkage(Dsymbol* s) | 1576 bool needsTemplateLinkage(Dsymbol* s) |
1576 { | 1577 { |
1577 #if 0 | 1578 #if 1 |
1578 return DtoIsTemplateInstance(s) != NULL; | 1579 return DtoIsTemplateInstance(s) != NULL; |
1579 #else | 1580 #else |
1580 Module* M = DtoIsTemplateInstance(s); | 1581 Module* M = DtoIsTemplateInstance(s); |
1581 // only return true if the symbol is a template instances | 1582 // only return true if the symbol is a template instances |
1582 // and if this instance originated in the current module | 1583 // and if this instance originated in the current module |