[vlc-devel] [PATCH] Add "ebx" to a clobber list

Måns Rullgård mans at mansr.com
Tue Oct 25 00:33:50 CEST 2011


KO Myung-Hun <komh78 at gmail.com> writes:

> Rafaël Carré wrote:
>> Le Sun, 23 Oct 2011 19:29:47 +0900,
>> KO Myung-Hun <komh78 at gmail.com> a écrit :
>> 
>>> Hi/2.
>>>
>>> This patch fixes the problem that "ebx" is corrupted on the some
>>> compiler such as gcc 4.4.5.
>> 
>> Doesn't push/pop do this already?
>> 
>> If the compiler is buggy can you paste corresponding assembler output? (replace -c by -S in compiler command)
>> 
>
> Of course. ^^
>
> #       define cpuid( reg )                    \
>             asm __volatile__ ( "push %%ebx\n\t"    \
>                            "cpuid\n\t"         \
>                            "movl %%ebx,%1\n\t" \
>                            "pop %%ebx\n\t"     \
>                          : "=a" ( i_eax ),     \
>                            "=r" ( i_ebx ),     \
>                            "=c" ( i_ecx ),     \
>                            "=d" ( i_edx )      \
>                          : "a"  ( reg )        \
>                          : "cc");
>
> #APP
> # 19 "cpuid.c" 1
> 	push %ebx
> 	cpuid
> 	movl %ebx,%ebx
> 	pop %ebx
> 	
> # 0 "" 2
> #NO_APP

Here the compiler allocated ebx for the i_ebx output, resulting in the
(perfectly valid) code above.  Adding ebx to the clobber list prevents
it being used for any operand.  The reason for the weird code probably
has to do with some gcc versions rejecting any use of the b constraint
in some configurations (PIC enabled IIRC).  Either these same versions
accept (or ignore) ebx in the clobber list, or this was added later to
fix the breakage seen above when some later version started allocating
ebx for this parameter and perhaps never tested with the old versions.

-- 
Måns Rullgård
mans at mansr.com




More information about the vlc-devel mailing list