StanfordPL / x64asm

x86-64 assembler library
Apache License 2.0
465 stars 60 forks source link

Wrong read/write set for xchgl #211

Closed stefanheule closed 8 years ago

stefanheule commented 8 years ago
xchgl %ebx, %ecx

  maybe read:      { %ecx %ebx }
  must read:       { %ecx %ebx }
  maybe write:     { %ecx %ebx }
  must write:      { %ecx %ebx }
  maybe undef:     { }
  must undef:      { }

This is wrong, it writes all 64 bits of both registers, and it also reads all 64 bits if the two registers are eax (because it leaves them unmodified, or rather, it doesn't read or write anything). @bchurchill, could you advise how to fix this? You hacked Codegen.hs to not have it use the property WRITE_SX (presumably because of the eax/eax case?). It seems the table cannot be use to get a fully accurate read/write set, because it depends on whether we are looking at eax/eax or not. Maybe just always saying all 64 bits are read and written?

@bchurchill, could you advise what the best fix is? I'm happy to implement it afterwards.

stefanheule commented 8 years ago

We decided that xchgl_r32_eax should have a maybe_read_set of r32, and a maybe_write_set of rax. Every other variant of xchgl does the normal zero-extend.