diff options
author | JF Bastien <jfb@chromium.org> | 2013-08-07 15:50:44 -0700 |
---|---|---|
committer | JF Bastien <jfb@chromium.org> | 2013-08-07 15:50:44 -0700 |
commit | 3b1ef29c338890ce55a1990389d8e63f6be7da2c (patch) | |
tree | 6a12c31173392c21830fdcd251e67907770dcede /test | |
parent | e801395572ecfeb5ba913c4064944ed7fac3e806 (diff) |
Treat __sync_synchronize and asm("":::"memory") as stronger fences.
This is a companion patch to:
https://codereview.chromium.org/22240002/
https://codereview.chromium.org/22474008/
and deals with the Clang-side of things.
The above patch will handle the fallouts of this Clang patch, including
some changes to un-duplicate work that RewriteAsmDirectives.cpp
does. The goal of this patch is to force some extra ordering on
non-atomics for le32 which LLVM doesn't necessarily provide.
R=eliben@chromium.org
TEST= ninja check-all
BUG= https://code.google.com/p/nativeclient/issues/detail?id=3475
BUG= https://code.google.com/p/nativeclient/issues/detail?id=3611
Review URL: https://codereview.chromium.org/22294002
Diffstat (limited to 'test')
-rw-r--r-- | test/CodeGen/NaCl/atomics.c | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/test/CodeGen/NaCl/atomics.c b/test/CodeGen/NaCl/atomics.c new file mode 100644 index 0000000000..9922e93630 --- /dev/null +++ b/test/CodeGen/NaCl/atomics.c @@ -0,0 +1,64 @@ +// Test frontend handling of synchronization builtins which NaCl handles +// differently. +// Modified from test/CodeGen/Atomics.c +// RUN: %clang_cc1 -triple le32-unknown-nacl -emit-llvm %s -o - | FileCheck %s + +// CHECK: define void @test_sync_synchronize() +// CHECK-NEXT: entry: +void test_sync_synchronize (void) +{ + __sync_synchronize (); + // CHECK-NEXT: call void asm sideeffect "", "~{memory}"() + // CHECK-NEXT: fence seq_cst + // CHECK-NEXT: call void asm sideeffect "", "~{memory}"() + + // CHECK-NEXT: ret void +} + +// CHECK: define void @test_asm_memory_1() +// CHECK-NEXT: entry: +void test_asm_memory_1 (void) +{ + asm ("":::"memory"); + // CHECK-NEXT: call void asm sideeffect "", "~{memory}"() + // CHECK-NEXT: fence seq_cst + // CHECK-NEXT: call void asm sideeffect "", "~{memory}"() + + // CHECK-NEXT: ret void +} + +// CHECK: define void @test_asm_memory_2() +// CHECK-NEXT: entry: +void test_asm_memory_2 (void) +{ + asm volatile ("":::"memory"); + // CHECK-NEXT: call void asm sideeffect "", "~{memory}"() + // CHECK-NEXT: fence seq_cst + // CHECK-NEXT: call void asm sideeffect "", "~{memory}"() + + // CHECK-NEXT: ret void +} + +// CHECK: define void @test_asm_memory_3() +// CHECK-NEXT: entry: +void test_asm_memory_3 (void) +{ + __asm__ ("":::"memory"); + // CHECK-NEXT: call void asm sideeffect "", "~{memory}"() + // CHECK-NEXT: fence seq_cst + // CHECK-NEXT: call void asm sideeffect "", "~{memory}"() + + // CHECK-NEXT: ret void +} + +// CHECK: define void @test_asm_memory_4() +// CHECK-NEXT: entry: +void test_asm_memory_4 (void) +{ + __asm__ __volatile__ ("":::"memory"); + // CHECK-NEXT: call void asm sideeffect "", "~{memory}"() + // CHECK-NEXT: fence seq_cst + // CHECK-NEXT: call void asm sideeffect "", "~{memory}"() + + // CHECK-NEXT: ret void +} |