Skip to content

Commit

Permalink
fix Issue 13873 - 2.066.1 Compiling with -debug -inline generates hug…
Browse files Browse the repository at this point in the history
…e files
  • Loading branch information
9rnsr committed Jan 28, 2015
1 parent dfebd9c commit df11f21
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 29 deletions.
14 changes: 13 additions & 1 deletion src/inline.c
Expand Up @@ -1626,14 +1626,26 @@ bool canInline(FuncDeclaration *fd, int hasthis, int hdrscan, int statementsToo)
if (fd->needThis() && !hasthis)
return false;

if (fd->inlineNest || (fd->semanticRun < PASSsemantic3 && !hdrscan))
if (fd->inlineNest)
{
#if CANINLINE_LOG
printf("\t1: no, inlineNest = %d, semanticRun = %d\n", fd->inlineNest, fd->semanticRun);
#endif
return false;
}

if (fd->semanticRun < PASSsemantic3 && !hdrscan)
{
if (!fd->fbody)
return false;
if (!fd->functionSemantic3())
return false;
Module::runDeferredSemantic3();
if (global.errors)
return false;
assert(fd->semanticRun >= PASSsemantic3done);
}

switch (statementsToo ? fd->inlineStatusStmt : fd->inlineStatusExp)
{
case ILSyes:
Expand Down
40 changes: 12 additions & 28 deletions src/mars.c
Expand Up @@ -1460,28 +1460,28 @@ Language changes listed by -transition=id:\n\
fprintf(global.stdmsg, "semantic3 %s\n", m->toChars());
m->semantic3();
}
Module::runDeferredSemantic3();
if (global.errors)
fatal();

// Scan for functions to inline
if (global.params.useInline)
{
/* Do pass 3 semantic analysis on all imported modules,
* since otherwise functions in them cannot be inlined
* We must do this BEFORE generating the .deps file!
*/
for (size_t i = 0; i < Module::amodules.dim; i++)
for (size_t i = 0; i < modules.dim; i++)
{
Module *m = Module::amodules[i];
Module *m = modules[i];
if (global.params.verbose)
fprintf(global.stdmsg, "semantic3 %s\n", m->toChars());
m->semantic3();
fprintf(global.stdmsg, "inline scan %s\n", m->toChars());
inlineScan(m);
}
if (global.errors)
fatal();
}
Module::runDeferredSemantic3();
if (global.errors)

// Do not attempt to generate output files if errors or warnings occurred
if (global.errors || global.warnings)
fatal();

// inlineScan incrementally run semantic3 of each expanded functions.
// So deps file generation should be moved after the inlinig stage.
if (global.params.moduleDeps)
{
OutBuffer* ob = global.params.moduleDeps;
Expand All @@ -1495,22 +1495,6 @@ Language changes listed by -transition=id:\n\
printf("%.*s", (int)ob->offset, ob->data);
}

// Scan for functions to inline
if (global.params.useInline)
{
for (size_t i = 0; i < modules.dim; i++)
{
Module *m = modules[i];
if (global.params.verbose)
fprintf(global.stdmsg, "inline scan %s\n", m->toChars());
inlineScan(m);
}
}

// Do not attempt to generate output files if errors or warnings occurred
if (global.errors || global.warnings)
fatal();

printCtfePerformanceStats();

Library *library = NULL;
Expand Down

0 comments on commit df11f21

Please sign in to comment.