r176420 - Improve C11 atomics support:

Dmitri Gribenko gribozavr at gmail.com
Sun Mar 3 08:36:10 PST 2013


On Sun, Mar 3, 2013 at 6:02 PM, David Chisnall <csdavec at swan.ac.uk> wrote:
> Added: cfe/trunk/test/CodeGen/c11atomics.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/c11atomics.c?rev=176420&view=auto
> ==============================================================================
> --- cfe/trunk/test/CodeGen/c11atomics.c (added)
> +++ cfe/trunk/test/CodeGen/c11atomics.c Sun Mar  3 10:02:42 2013
> @@ -0,0 +1,139 @@
> +// RUN: %clang_cc1 %s -emit-llvm -o - -triple=armv7-unknown-freebsd -std=c11 | FileCheck %s
> +
> +// Test that we are generating atomicrmw instructions, rather than
> +// compare-exchange loops for common atomic ops.  This makes a big difference
> +// on RISC platforms, where the compare-exchange loop becomes a ll/sc pair for
> +// the load and then another ll/sc in the loop, expanding to about 30
> +// instructions when it should be only 4.  It has a smaller, but still
> +// noticeable, impact on platforms like x86 and RISC-V, where there are atomic
> +// RMW instructions.
> +//
> +// We currently emit cmpxchg loops for most operations on _Bools, because
> +// they're sufficiently rare that it's not worth making sure that the semantics
> +// are correct.
> +
> +typedef int __attribute__((vector_size(16))) vector;
> +
> +_Atomic(_Bool) b;
> +_Atomic(int) i;
> +_Atomic(long long) l;
> +_Atomic(short) s;
> +_Atomic(char*) p;
> +_Atomic(float) f;
> +_Atomic(vector) v;
> +
> +// CHECK-NOT: cmpxchg

Hi David,

I assume you want to check that the output does not contain cmpxchg at
all.  If so, unfortunately, this is not how CHECK-NOT works.  You need
to do a second FileCheck pass over the output to check that (with a
different prefix, of course).

Dmitri

-- 
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/



More information about the cfe-commits mailing list