[LLVMdev] llvm.atomic.barrier implementation

Chris Lattner sabre at nondot.org
Fri Feb 15 15:02:33 PST 2008


On Feb 15, 2008, at 2:29 PM, Andrew Lenharth wrote:

> On 2/15/08, Andrew Lenharth <andrewl at lenharth.org> wrote:
>> I'll take a hack at the front end support for
>>  __sync_synchronize after this goes in.
>
> This is the gcc side of the patch.

GCC 4.2 compiles this to a no-op on x86:

void foo() {
   __sync_synchronize();
}

Are you seeing different behavior?  What am I missing here?

-Chris


>
>
> Index: gcc/llvm-convert.cpp
> ===================================================================
> --- gcc/llvm-convert.cpp        (revision 46956)
> +++ gcc/llvm-convert.cpp        (working copy)
> @@ -4260,6 +4260,15 @@
>     EmitBlock(new BasicBlock(""));
>     return true;
>
> +  case BUILT_IN_SYNCHRONIZE: {
> +    Value* C[4];
> +    C[0] = C[1] = C[2] = C[3] = ConstantInt::get(Type::Int1Ty, 1);
> +
> +    Builder.CreateCall(Intrinsic::getDeclaration(TheModule,
> Intrinsic::atomic_membarrier),
> +                       C, C + 4);
> +    return true;
> +  }
> +
> #if 1  // FIXME: Should handle these GCC extensions eventually.
>     case BUILT_IN_APPLY_ARGS:
>     case BUILT_IN_APPLY:
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev




More information about the llvm-dev mailing list