New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue 10985 - Compiler doesn't attempt to inline non-templated functions from libraries (even having the full source) #2561
Conversation
+1 on removing _d_array_boundsm, _d_assertm, _d_unittestm (should these be removed from druntime too?) -1 on slowing down compilation speed. :-) |
I'm worrying that immediately removing them might break backward compatibility. |
Ok, no problem. We don't yet ship phobos/druntime as a shared library, so I can't imagine how though. |
Great to finally address this issue, thanks a lot Kenji.
Let's remove them after the next release. |
Also +1 on code convergence (gdc has never implemented the toModuleArray methods... should get round to either supporting or removing _d_switch_errorm in the next release merge) |
Did Walter break the testsuite again? |
@9rnsr: If the compiler can now do this analysis, could it also try and error on this code: class C
{
void foo() { }
void foo() { }
}
void main() { } This currently creates a linker error, but this should really be caught in the compiler. |
Currently some issues there.
|
@AndrejMitrovic I agree. It should be fixed in the future. |
I wish the best for fixing them in dmd and I'm looking forward to this. :-) |
} | ||
else | ||
{ | ||
efilename = m->toEfilename(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generating module filename string and using the symbol causes LNK1235: corrupt or invalid COFF symbol table
error on Win64 platform, but I cannot find the reason. (Maybe a bug around coff object file generation?)
@WalterBright Can you help me?
Here is a reduced test case for the std.numeric failure. bool normalize(double[] range, double sum = 1)
{
double s = 0;
// Step 1: Compute sum and length of the range
const length = range.length;
foreach (e; range)
{
s += e;
}
// Step 2: perform normalization
if (s == 0)
{
return false;
}
// The path most traveled
return true;
} This generate wrong code for If I remove the |
Maybe related to http://d.puremagic.com/issues/show_bug.cgi?id=11081. I noticed that function literals sometimes don't have a name, I guess this happens if they are created during speculative template instantiations. |
Oh, I thought this was already merged. What issues still need a fix? |
@dawgfoto Wrong-code bugs in some platforms is not yet fixed. Unfortunately I don't have enough time to debug it now. |
No problem, I put it on my list, but I might not find much time for it either. |
Pardon for nagging. Just a couple of questions:
|
It might trigger a lot of currently hidden inline/codegen bugs. |
The 64bit code gen errors seem to be the same ones triggered by PR #1426 |
I'm glad to hear this, I thought I must have been doing something really wrong but maybe we're both running into some code that accidentally triggers this bug.. |
Fix generation of Ready to merge. |
@@ -520,7 +531,7 @@ void Module::genobjfile(bool multiobj) | |||
elinnum = el_var(sp); | |||
} | |||
|
|||
elem *efilename = el_ptr(toSymbol(this)); | |||
elem *efilename = toEfilename(this); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we keep using the modulename instead of the filename?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found that the issue 846 fix is unnecessary for this PR, so it is remove now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why aren't the missing assert functions a problem?
When I compile a library in release mode but do the inlining for a debug build, who is emitting the assert functions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you compile the release library with -lib
switch, compiler will generate and store the assert functions in the library file. In other cases, you should link debug builded library for a debug build of your application.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a note, now I'm separating issue 846 fix to #3552.
LGTM. |
This is important due to avoid out-of-memory error with `-unittest -inline`. Currently front-end inlining requires running semantic3 for all imported modules to analyze expanded function body code. By this change, we can remove the Phobos unittest analyzing cost in user application compilation.
…nctions from libraries (even having the full source)
Updated commits. Now this PR only fixes issue 10985. |
Auto-merge toggled on |
Issue 10985 - Compiler doesn't attempt to inline non-templated functions from libraries (even having the full source)
@MartinNowak I reported your bug report as https://issues.dlang.org/show_bug.cgi?id=12852 |
|
This appears to have caused regression https://issues.dlang.org/show_bug.cgi?id=13193 |
http://d.puremagic.com/issues/show_bug.cgi?id=10985
This PR requires druntime fix: https://github.com/dlang/druntime/pull/608- Stop using ModuleInfo for assertion and array bounds check.
- Relax the condition for inlining, due to fix bug 10985.
Today, implicitly generated code for assertions/array-bounds-check uses ModuleInfo object.
However
ModuleInfo
object won't be generated if the module is not in root - even though the code in module could be directly used by template instantiation and/or inlining.To fix the issues:
During the work, I found a wrong-code [bug 11049](http://d.puremagic.com/issues/show_bug.cgi?id=11049), and this PR also fixes it.