digitalmars.D.bugs - [Issue 20466] New: Optimizer clobbering msw register when testing it
- d-bugmail puremagic.com (87/87) Dec 25 2019 https://issues.dlang.org/show_bug.cgi?id=20466
https://issues.dlang.org/show_bug.cgi?id=20466 Issue ID: 20466 Summary: Optimizer clobbering msw register when testing it for 0 Product: D Version: D2 Hardware: x86 OS: Linux Status: NEW Severity: critical Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: bugzilla digitalmars.com Compile the following code with -O -m32 -fPIC and then disassemble it: ------------------------- enum STC : long { auto_ = (1L << 8), trusted = (1L << 34), } alias StorageClass = ulong; extern (C++) final class Parameter { StorageClass storageClass; void* type; } extern (C++) final class IfStatement { Parameter prm; } extern (C++) final class Visitor { void visit(IfStatement s) { if (Parameter p = s.prm) { StorageClass stc = p.storageClass; if (!p.type && !stc) stc = STC.auto_; assert(!(stc & STC.trusted)); } } } ---------------- _ZN7Visitor5visitEP11IfStatement: push EBP mov EBP,ESP sub ESP,018h mov -0Ch[EBP],EBX mov -8[EBP],ESI call L11 L11: pop EAX add EAX,offset FLAT:_GLOBAL_OFFSET_TABLE_ GOTPC[2] mov -4[EBP],EAX mov ECX,0Ch[EBP] mov EDX,4[ECX] test EDX,EDX je L4B cmp dword ptr 0Ch[EDX],0 mov ECX,8[EDX] mov EBX,4[EDX] jne L3B or ECX,EBX <=== clobbers ECX jne L3B mov EBX,0100h xor ECX,ECX L3B: mov EAX,EBX mov EDX,ECX <=== using clobbered value here xor EAX,EAX and EDX,4 or EDX,EAX jne L55 L4B: mov EBX,-0Ch[EBP] mov ESI,-8[EBP] mov ESP,EBP pop EBP ret L55: mov dword ptr -014h[EBP],01Dh mov EBX,-4[EBP] lea ESI,_TMP0 GOTOFF[061h][EBX] mov -018h[EBP],ESI mov EBX,-4[EBP] call _d_assertp PLT32 mov EBX,-0Ch[EBP] mov ESI,-8[EBP] mov ESP,EBP pop EBP ret ---------------- See where the register is clobbered. --
Dec 25 2019