[Issue 3521] New: Optimized code access popped register

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Nov 16 22:53:10 PST 2009


http://d.puremagic.com/issues/show_bug.cgi?id=3521

           Summary: Optimized code access popped register
           Product: D
           Version: 1.051
          Platform: x86
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: lifc0 at yahoo.com.cn


--- Comment #0 from lifc0 at yahoo.com.cn <lifc0 at yahoo.com.cn> 2009-11-16 22:53:09 PST ---
DMD compiler(seems from 1.029) produces bad optimized opcode which access a
popped register.
$cat test.d
class foo {
        uint a, b;
}

void main () {
        foo f = new foo;
        uint c;
        with (f) {
                c = 0;
                b = 0;
                a = 0;
                if (a == b && (a + (c = 66)) <= 66)
                        assert(c == 66);
        }
}

$dmd -O test.d
$./test
Error: AssertError Failure test.d(13)
$objdump -d test.o
  ...
  ...
  25:   53                      push   %ebx
  26:   bb 42 00 00 00          mov    $0x42,%ebx
  2b:   89 d9                   mov    %ebx,%ecx
  2d:   5b                      pop    %ebx        <----------- here
  2e:   8d 14 0b                lea    (%ebx,%ecx,1),%edx
  31:   3b d6                   cmp    %esi,%edx
  33:   77 0f                   ja     44 <_Dmain+0x44>
  35:   83 fb 42                cmp    $0x42,%ebx  <---------- and here
  38:   74 0a                   je     44 <_Dmain+0x44>
  ...
  ...

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list