Bug 12051 – Wrong code with ?: resulting in char on x86-64

Status
RESOLVED
Resolution
FIXED
Severity
critical
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
All
Creation time
2014-01-31T15:44:00Z
Last change time
2015-06-09T05:11:53Z
Keywords
pull, wrong-code
Assigned to
yebblies
Creator
yazan.dabain

Comments

Comment #0 by yazan.dabain — 2014-01-31T15:44:51Z
A wrong code issue was found in DCD project commit e7f3952. The code where the compiler fails to produce correct code is in astconverter.d:558 foreach (i, s; importInfo.importParts) { immutable kind = i + 1 < importInfo.importParts.length ? CompletionKind.packageName : CompletionKind.moduleName; // Begin compiler bug workaround (this is part of the next commit, not e7f3952) if (kind == 'L') std.stdio.writeln("ERROR ", kind); ... } CompletionKind is a char enum (located in messages.d), CompletionKind.packageName = 'P', CompletionKind.moduleName = 'M' -------------------------------------------------- The assembly produced for this part of the code: lea 0x1(%rbx),%rcx cmp -0x1c0(%rbp),%rcx sbb %rsi,%rsi and $0x3,%dh <---------- wrong register, should be sil, not dh add $0x4d,%sil This code is the same on commit e7f3952 in an optimized build and on commit 2745763 in a non-optimized build. However it is different in an optimized for commit 2745763. The optimized code is: lea 0x1(%r12),%rcx cmp -0xa0(%rbp),%rcx sbb %r13,%r13 and $0x3,%r13b add $0x4d,%r13b The code in the optimized build doesn't have the issue. And it runs as expected. -------------------------------------------------- Original discussion https://github.com/Hackerpilot/DCD/issues/92
Comment #1 by yazan.dabain — 2014-01-31T15:58:08Z
BTW, inline and possibly other flags are not required to reproduce the issue. And removing it from the build script will speed up the compilation greatly.
Comment #2 by yebblies — 2014-02-01T00:13:20Z
Slowly, slowly reducing with dustmite.
Comment #3 by yebblies — 2014-02-01T03:20:09Z
Comment #4 by github-bugzilla — 2014-02-12T16:43:51Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/558ff1217863936fbb3df9d01cb0bc4f8a11cd14 Fix Issue 12051 - Wrong code with ?: resulting in char on x86-64 https://github.com/D-Programming-Language/dmd/commit/1fdd3c6ace7ea0c5985d7c3041d4641b05b098df Merge pull request #3182 from yebblies/issue12051 Issue 12051 - Wrong code with ?: resulting in char on x86-64
Comment #5 by github-bugzilla — 2014-02-12T16:45:17Z
Commit pushed to dmd-1.x at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/e39e0707f590fff45deebde81e5b34846ecdffed Merge pull request #3182 from yebblies/issue12051 Issue 12051 - Wrong code with ?: resulting in char on x86-64
Comment #6 by github-bugzilla — 2014-02-15T19:23:10Z
Commit pushed to 2.065 at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/b1ba7340cf028a3fd9857de2980b6eb611c0caef Merge pull request #3182 from yebblies/issue12051 Issue 12051 - Wrong code with ?: resulting in char on x86-64