https://bugs.llvm.org/show_bug.cgi?id=36886

            Bug ID: 36886
           Summary: bool parameter is tested as a 32-bit value, should use
                    only the low byte
           Product: new-bugs
           Version: unspecified
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
          Assignee: unassignedb...@nondot.org
          Reporter: dma...@mozilla.com
                CC: llvm-bugs@lists.llvm.org

__declspec(noinline) int fn(bool b) { return b ? 0x42 : 0; }

At -O1 and higher on 64-bit Windows, clang-cl generates code that goes like:

test!fn:
00000001`40001000 85c9            test    ecx,ecx
00000001`40001002 b842000000      mov     eax,42h
00000001`40001007 0f44c1          cmove   eax,ecx
00000001`4000100a c3              ret

where the function tests the full 32-bit value of ecx. This can end up taking
the wrong code path if the caller only filled in the low byte of the register
and the upper bytes are garbage. (For what it's worth, MSVC looks at only the
low byte in this case.)

clang version 7.0.0 (trunk 328367)

Reduced from
https://searchfox.org/mozilla-central/rev/de5c4376b89c3603341d226a65acea12f8851ec5/netwerk/base/nsUDPSocket.cpp#571

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to