[PATCH] Fix bug in cpuid.h

Akira Hatanaka ahatanak at gmail.com
Mon Jul 21 15:45:38 PDT 2014


The attached patch fixes a bug where the __ebx output is clobbered.
Currently, clang generates the following code when cpuid.c in the test case
is compiled:

$ clang cpuid.c -O3 -S -o -

## InlineAsm Start

pushl  %ebx      # save %ebx before cpuid clobbers it.

cpuid

mov    %ebx,%ebx # move the __ebx output to %ebx.

popl   %ebx      # pop saved %ebx. Clobbers __ebx output.

## InlineAsm End

This happens because register '"ebx" is chosen for operand %1 which has
constraint "=r". The attached patch adds %ebx to the clobber list to
prevent this from happening.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140721/d6b0e632/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cpuid1.patch
Type: application/octet-stream
Size: 1233 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140721/d6b0e632/attachment.obj>


More information about the cfe-commits mailing list