[Issue 17940] bool function parameters loaded from struct sometimes miscompiled with -O
https://issues.dlang.org/show_bug.cgi?id=17940 FeepingCreature changed: What|Removed |Added CC||default_357-l...@yahoo.de --- Comment #1 from FeepingCreature --- Simplified a bit: struct Array { long length, ptr; } struct Struct { bool b = true; } void fun1(int) { } void fun2(Array arr, int, int) { assert(!arr.length); } void fn(Struct* str) { Array arr; if (!str) return; if (str) { fun1(str.b); } if (str.b) { fun2(arr, str.b, 0); } } void main() { Struct s; fn(&s); } --
[Issue 17940] bool function parameters loaded from struct sometimes miscompiled with -O
https://issues.dlang.org/show_bug.cgi?id=17940 --- Comment #2 from FeepingCreature --- Hah! It tries to reload the cse into ESI, but since that's a 1-byte operation (since bool), it actually becomes a move to DH. ESI is not even reachable with 1-byte ops, because those register values were used to address high regs. So for reg8 opcodes like 0x8A, code->setReg should assert on reg & 4. How to actually fix this though, no idea. --
[Issue 17940] bool function parameters loaded from struct sometimes miscompiled with -O
https://issues.dlang.org/show_bug.cgi?id=17940 --- Comment #3 from FeepingCreature --- Proposed fix: https://github.com/dlang/dmd/pull/7252 --
[Issue 17940] bool function parameters loaded from struct sometimes miscompiled with -O
https://issues.dlang.org/show_bug.cgi?id=17940 --- Comment #4 from github-bugzi...@puremagic.com --- Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/87cd61e4c4aca33254bacb2af735433193a51039 fix issue 17940 When generating a 1-byte mov cse on x86_64, handle the REX flag after setReg, instead of when the instruction is first created, since that's when we know if we need it. https://github.com/dlang/dmd/commit/89b0af132529d4635717fd4b16ffc300056dd1b9 Merge pull request #7252 from FeepingCreature/master fix issue 17940 - always set REX for 1-byte CSE moves on x86_64 merged-on-behalf-of: Walter Bright --
[Issue 17940] bool function parameters loaded from struct sometimes miscompiled with -O
https://issues.dlang.org/show_bug.cgi?id=17940 github-bugzi...@puremagic.com changed: What|Removed |Added Status|NEW |RESOLVED Resolution|--- |FIXED --
[Issue 17940] bool function parameters loaded from struct sometimes miscompiled with -O
https://issues.dlang.org/show_bug.cgi?id=17940 --- Comment #5 from github-bugzi...@puremagic.com --- Commits pushed to stable at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/87cd61e4c4aca33254bacb2af735433193a51039 fix issue 17940 https://github.com/dlang/dmd/commit/89b0af132529d4635717fd4b16ffc300056dd1b9 Merge pull request #7252 from FeepingCreature/master --