digitalmars.D - Frustrated with dmd codegen bug
- H. S. Teoh (20/20) Apr 24 2018 Yesterday afternoon I ran into a performance issue in one of my D
- jmh530 (26/27) Apr 24 2018 That's definitely weird. Problem seems to go away with a static
- Basile B. (4/12) Apr 24 2018 In the report you forgot to mention that the bug is only visible
- H. S. Teoh (10/24) Apr 24 2018 Really?! That's weird... Originally the problem appeared with -O
- Basile B. (4/28) Apr 24 2018 I'm sorry to bring confusion but i've tested on linux x86_64.
- jmh530 (2/6) Apr 24 2018 I ran the test case on run.dlang.org with -O and it happens.
- ag0aep6g (8/18) Apr 24 2018 Another one for my collection of bugs related to the bt instruction [1]....
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."
Apr 24 2018
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; } }
Apr 24 2018
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=18794In the report you forgot to mention that the bug is only visible with -O -profile. With just -O the provided test case works fine.
Apr 24 2018
On Tue, Apr 24, 2018 at 08:18:55PM +0000, Basile B. via Digitalmars-d wrote:On Tuesday, 24 April 2018 at 18:53:02 UTC, H. S. Teoh wrote:Really?! That's weird... Originally the problem appeared with -O -profile, but after reduction, I could reproduce the problem even without -profile. (Just tested it again: the segfault happens without -profile.) Possibly it's affected by the OS/architecture? Or perhaps it's just very sensitive to the exact combination of flags + environmental factors. T -- I'm still trying to find a pun for "punishment"...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=18794In the report you forgot to mention that the bug is only visible with -O -profile. With just -O the provided test case works fine.
Apr 24 2018
On Tuesday, 24 April 2018 at 20:44:12 UTC, H. S. Teoh wrote:On Tue, Apr 24, 2018 at 08:18:55PM +0000, Basile B. via Digitalmars-d wrote:I'm sorry to bring confusion but i've tested on linux x86_64. With dmd 2.079.1 and ~master (just updated it right now). Here for some reason -profile is always required to get the error :/On Tuesday, 24 April 2018 at 18:53:02 UTC, H. S. Teoh wrote:Really?! That's weird... Originally the problem appeared with -O -profile, but after reduction, I could reproduce the problem even without -profile. (Just tested it again: the segfault happens without -profile.) Possibly it's affected by the OS/architecture? Or perhaps it's just very sensitive to the exact combination of flags + environmental factors. TYesterday 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=18794In the report you forgot to mention that the bug is only visible with -O -profile. With just -O the provided test case works fine.
Apr 24 2018
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.
Apr 24 2018
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=18794Another 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
Apr 24 2018