diff --git a/README.md b/README.md index d15d4b8..89c2ab1 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ compiler writers generate better code and documents the complexity of x86. * strength-reduce AND with immediate to movzbl * suboptimal no-ops - multiple `90` instead of a single `60 90`, etc. -* suboptimal zero register +* ~~suboptimal zero register~~, see [#7](https://github.com/gaul/x86lint/issues/7) - MOV EAX, 0 instead of XOR EAX, EAX * unnecessary REX prefix - XOR RAX, RAX instead of XOR EAX, EAX diff --git a/x86lint.c b/x86lint.c index 7085a2e..cc648ed 100644 --- a/x86lint.c +++ b/x86lint.c @@ -565,6 +565,8 @@ int check_instructions(const uint8_t *inst, size_t len) ++errors; } + // TODO: Disabled due to false positives from CMOV sequences. See #7. + /* result = check_mov_zero(&xedd); if (!result) { printf("suboptimal zero register at offset: %zu\n", offset); @@ -573,6 +575,7 @@ int check_instructions(const uint8_t *inst, size_t len) printf("\n"); ++errors; } + */ result = check_implicit_register(&xedd); if (!result) { diff --git a/x86lint_test.c b/x86lint_test.c index e2b7f5f..437bb61 100644 --- a/x86lint_test.c +++ b/x86lint_test.c @@ -271,7 +271,10 @@ int main(int argc, char *argv[]) 0x48, 0xB8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // mov rax, 0 0x05, 0x80, 0x00, 0x00, 0x00, // add eax, 0x80 0x40, 0xc9, // leave + // TODO: Disabled due to false positives from CMOV sequences. See #7. + /* 0xB8, 0x00, 0x00, 0x00, 0x00, // mov eax, 0 + */ 0x81, 0xC0, 0x00, 0x01, 0x00, 0x00, // add eax, 0x100 0x05, 0x01, 0x00, 0x00, 0x00, // add eax, 1 0xc1, 0xd0, 0x01, // rcl eax, 1 @@ -279,7 +282,7 @@ int main(int argc, char *argv[]) 0x67, 0x0f, 0xc1, 0x18, // xadd [eax], ebx 0xf0, 0x87, 0x07, // lock xchg [eax], ebx }; - int expected = 11; + int expected = 10; int actual = check_instructions(inst, sizeof(inst)); if (actual != expected) { printf("Expected %d errors, actual: %d\n", expected, actual);