Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions dmd/dtemplate.d
Original file line number Diff line number Diff line change
Expand Up @@ -4136,6 +4136,13 @@ extern (C++) class TemplateInstance : ScopeDsymbol
version (IN_LLVM)
{
assert(global.params.linkonceTemplates != LinkonceTemplates.aggressive);

static uint callDepth;
callDepth++;
scope(exit) callDepth--;

if (global.params.templateCodegenDepth && (callDepth > global.params.templateCodegenDepth))
return false;
}

//printf("needsCodegen() %s\n", toChars());
Expand Down
1 change: 1 addition & 0 deletions dmd/globals.d
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ version (IN_LLVM)
bool outputSourceLocations; // if true, output line tables.

LinkonceTemplates linkonceTemplates; // -linkonce-templates
uint templateCodegenDepth; // -template-codegen-depth

// Windows-specific:
bool dllexport; // dllexport ~all defined symbols?
Expand Down
1 change: 1 addition & 0 deletions dmd/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ struct Param
bool outputSourceLocations; // if true, output line tables.

LinkonceTemplates linkonceTemplates; // -linkonce-templates
uint32_t templateCodegenDepth; // -template-codegen-depth

// Windows-specific:
bool dllexport; // dllexport ~all defined symbols?
Expand Down
5 changes: 5 additions & 0 deletions driver/cl_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,11 @@ static cl::opt<LinkonceTemplates, true> linkonceTemplates(
"linkonce-templates-aggressive",
"Experimental, more aggressive variant")));

static cl::opt<uint32_t, true>
templateCodegenDepth("template-codegen-depth",
cl::desc("Don't codegen templates beyond this instantiation depth (0 = off)."),
cl::location(global.params.templateCodegenDepth), cl::init(0));

cl::opt<bool> disableLinkerStripDead(
"disable-linker-strip-dead", cl::ZeroOrMore,
cl::desc("Do not try to remove unused symbols during linking"),
Expand Down