mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-09 04:15:58 +03:00
-linkonce-templates: Cull 'discardable' template instances (#3899)
Such instances are guaranteed not to need codegen (e.g., CTFE only).
This commit is contained in:
parent
c100c15ae0
commit
423a1d8270
2 changed files with 8 additions and 2 deletions
|
@ -288,6 +288,7 @@ public:
|
||||||
Identifier *getIdent();
|
Identifier *getIdent();
|
||||||
hash_t toHash();
|
hash_t toHash();
|
||||||
|
|
||||||
|
bool isDiscardable();
|
||||||
bool needsCodegen();
|
bool needsCodegen();
|
||||||
|
|
||||||
TemplateInstance *isTemplateInstance() { return this; }
|
TemplateInstance *isTemplateInstance() { return this; }
|
||||||
|
|
|
@ -318,8 +318,13 @@ public:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: This is #673 all over again.
|
// With -linkonce-templates, only non-speculative instances make it to
|
||||||
if (!global.params.linkonceTemplates && !decl->needsCodegen()) {
|
// module members (see `TemplateInstance.appendToModuleMember()`), and we
|
||||||
|
// don't need full needsCodegen() culling in that case; isDiscardable() is
|
||||||
|
// sufficient. Speculative ones are lazily emitted if actually referenced
|
||||||
|
// during codegen - per IR module.
|
||||||
|
if ((global.params.linkonceTemplates && decl->isDiscardable()) ||
|
||||||
|
(!global.params.linkonceTemplates && !decl->needsCodegen())) {
|
||||||
Logger::println("Does not need codegen, skipping.");
|
Logger::println("Does not need codegen, skipping.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue