Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
April 24, 2018 Frustrated with dmd codegen bug | ||||
---|---|---|---|---|
| ||||
Yesterday afternoon I ran into a performance issue in one of my D projects, and thought, "well, it's simple, just compile with -profile, identify the hotspot, optimize". Unfortunately, doing that triggered a latent codegen bug in -O that randomly causes runtime segfaults, basically halting all progress. I spent all morning today to reduce the code in order to identify the codegen bug: https://issues.dlang.org/show_bug.cgi?id=18794 The only workaround I know of currently is to compile without -O. But that also means it's meaningless to compile with -profile, since it would give misleading information (e.g., identify hotspots that aren't really hotspots once the compiler actually optimizes the code). The next best thing is to use LDC for better (and more reliable!) codegen. However, since this project was developed using dmd git master (I know, I know), some non-trivial changes are needed to make it compilable by LDC. At this point, I'm *seriously* tempted to stop following dmd development completely and just stick with LDC releases for my D projects. :-( T -- "The number you have dialed is imaginary. Please rotate your phone 90 degrees and try again." |
April 24, 2018 Re: Frustrated with dmd codegen bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to H. S. Teoh | On Tuesday, 24 April 2018 at 18:53:02 UTC, H. S. Teoh wrote:
> [snip]
That's definitely weird. Problem seems to go away with a static array. Seems somehow related to impl[0]. Re-writing that as *impl.ptr and breaking apart some of the logic might help narrow down the issue.
bool method(int v)
{
int wordIdx = v >> 6;
int bitIdx = v & 0b00111111;
func();
if (impl.length < wordIdx)
{
import std.stdio : writeln;
auto temp1 = (1UL << bitIdx);
writeln(1UL << bitIdx); //testing with v=200, prints 256
writeln(*impl.ptr & 256); //prints 0
auto temp2 = (*impl.ptr & temp1); //program killed
//writeln(*impl.ptr & 256); //if uncommented, program not killed
return temp2 != 0;
}
else
{
return false;
}
}
|
April 24, 2018 Re: Frustrated with dmd codegen bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to H. S. Teoh | On Tuesday, 24 April 2018 at 18:53:02 UTC, H. S. Teoh wrote:
> Yesterday afternoon I ran into a performance issue in one of my D projects, and thought, "well, it's simple, just compile with -profile, identify the hotspot, optimize". Unfortunately, doing that triggered a latent codegen bug in -O that randomly causes runtime segfaults, basically halting all progress. I spent all morning today to reduce the code in order to identify the codegen bug:
>
> https://issues.dlang.org/show_bug.cgi?id=18794
In the report you forgot to mention that the bug is only visible with -O -profile.
With just -O the provided test case works fine.
|
April 24, 2018 Re: Frustrated with dmd codegen bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to H. S. Teoh | On 04/24/2018 08:53 PM, H. S. Teoh wrote: > Yesterday afternoon I ran into a performance issue in one of my D > projects, and thought, "well, it's simple, just compile with -profile, > identify the hotspot, optimize". Unfortunately, doing that triggered a > latent codegen bug in -O that randomly causes runtime segfaults, > basically halting all progress. I spent all morning today to reduce the > code in order to identify the codegen bug: > > https://issues.dlang.org/show_bug.cgi?id=18794 Another one for my collection of bugs related to the bt instruction [1]. I have an open PR to fix one of those [2], but maybe the whole optimization should just be disabled until the issues are fixed. [...] > At this point, I'm *seriously* tempted to stop following dmd development > completely and just stick with LDC releases for my D projects. :-( Very understandable. DMD has too damn many wrong-code bugs. [1] https://issues.dlang.org/show_bug.cgi?id=18750 [2] https://github.com/dlang/dmd/pull/8142 |
April 24, 2018 Re: Frustrated with dmd codegen bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to Basile B. | On Tuesday, 24 April 2018 at 20:18:55 UTC, Basile B. wrote:
> [snip]
>
> In the report you forgot to mention that the bug is only visible with -O -profile.
> With just -O the provided test case works fine.
I ran the test case on run.dlang.org with -O and it happens.
|
Copyright © 1999-2021 by the D Language Foundation