On Wed, May 11, 2011 at 6:14 PM, saeed bishara <saeed.bish...@gmail.com> wrote:
> On Sat, May 7, 2011 at 12:39 AM, Nicolas Pitre <nicolas.pi...@linaro.org> 
> wrote:
>> On Fri, 6 May 2011, Ramana Radhakrishnan wrote:
>>
>>> On 6 May 2011 16:06, Ken Werner <ken.wer...@linaro.org> wrote:
>>> >
>>> > Currently the GCC ARM backend doesn't provide a pattern to inline 64bit
>>> > __sync_* functions but the compiler emits __sync_*_8 function calls [1]. 
>>> > The
>>> > libgcc does not provide these symbols via the usual thin wrapper around 
>>> > the
>>> > kernel helper [2] because the ARM Linux __kernel_cmpxchg supports 32bit 
>>> > only.
>>> > My understanding is that for ARMv7 the GCC backend could be enhanced to 
>>> > inline
>>> > the __sync_* functions by using the LDREXD and STREXD instructions. But 
>>> > for
>>> > ARMv5 we would still rely on a new kernel helper.
>>>
>>> It's a bit tricky with when you want to use the kernel helper for v5t,
>>> so we've got to find a way of turning this on only with special knobs
>>> and not by default and that's a bit tricky.
>>
>> What is the problem with v5t?
> Hi, when I run the following on my jaunty (for armv5), I get the following
>
>
> echo "void f(){__sync_synchronize();}" | gcc -O2 -x c -Wall -dA -S - -o -
>        .arch armv6
>        .eabi_attribute 27, 3
>        .fpu vfp
>        .eabi_attribute 20, 1
>        .eabi_attribute 21, 1
>        .eabi_attribute 23, 3
>        .eabi_attribute 24, 1
>        .eabi_attribute 25, 1
>        .eabi_attribute 26, 2
>        .eabi_attribute 30, 2
>        .eabi_attribute 18, 4
>        .file   ""
>        .text
>        .align  2
>        .global f
>        .type   f, %function
> f:
>        @ args = 0, pretend = 0, frame = 0
>        @ frame_needed = 0, uses_anonymous_args = 0
>        @ link register save eliminated.
>        @ basic block 2
>        bx      lr
>        .size   f, .-f
>        .ident  "GCC: (Ubuntu 4.4.1-4ubuntu9) 4.4.1"
>        .section        .note.GNU-stack,"",%progbits
>
> but I can see (with debugger) that the kernel helper functions are
> reached. any idea how?

There was a compiler bug some time ago which mistakenly generated no
code for __sync_synchronize():
https://bugs.launchpad.net/ubuntu/+source/gcc-4.4/+bug/491872

I suspect your Jaunty-era compiler may be affected by this -- you
probably need to upgrade it.

If you're observing calls to the helpers, they may be coming from
glibc etc. instead of your function.


You _should_ be seeing code something like this:

$ echo 'void f(void) { __sync_synchronize(); }' |
arm-linux-gnueabi-gcc -march=armv7-a -O2 -S -o - -x c -
[...]
f:
        @ args = 0, pretend = 0, frame = 0
        @ frame_needed = 0, uses_anonymous_args = 0
        @ link register save eliminated.
        dmb     sy
        bx      lr
[...]

(If -march is set high enough, the dmb is explicit and inline.)

$ echo 'void f(void) { __sync_synchronize(); }' |
arm-linux-gnueabi-gcc -march=armv5t -O2 -S -o - -x c -
[...]
f:
        push    {r3, lr}
        bl      __sync_synchronize
        @ sp needed for prologue
        pop     {r3, pc}

(-march=armv5t indicates an architecture which doesn't have the
barrier instructions, so the kuser helper is needed instead)

Cheers
---Dave

_______________________________________________
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev

Reply via email to