Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(610)

Unified Diff: test/Transforms/NaCl/atomic/sync_synchronize.ll

Issue 939073008: Rebased PNaCl localmods in LLVM to 223109 (Closed)
Patch Set: undo localmod Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/Transforms/NaCl/atomic/lock_.ll ('k') | test/Transforms/NaCl/atomic/val_compare_and_swap.ll » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/Transforms/NaCl/atomic/sync_synchronize.ll
diff --git a/test/Transforms/NaCl/atomic/sync_synchronize.ll b/test/Transforms/NaCl/atomic/sync_synchronize.ll
new file mode 100644
index 0000000000000000000000000000000000000000..c9ef9029d3f6635855b06b3ceb30ef6522270efd
--- /dev/null
+++ b/test/Transforms/NaCl/atomic/sync_synchronize.ll
@@ -0,0 +1,51 @@
+; RUN: opt -nacl-rewrite-atomics -remove-asm-memory -S < %s | FileCheck %s
+
+; Each of these tests validates that the corresponding legacy GCC-style builtins
+; are properly rewritten to NaCl atomic builtins. Only the GCC-style builtins
+; that have corresponding primitives in C11/C++11 and which emit different code
+; are tested. These legacy GCC-builtins only support sequential-consistency
+; (enum value 6).
+;
+; test_* tests the corresponding __sync_* builtin. See:
+; http://gcc.gnu.org/onlinedocs/gcc-4.8.1/gcc/_005f_005fsync-Builtins.html
+
+target datalayout = "p:32:32:32"
+
+; This patterns gets emitted by C11/C++11 atomic thread fences.
+;
+; CHECK-LABEL: @test_c11_fence
+define void @test_c11_fence() {
+ ; CHECK-NEXT: call void @llvm.nacl.atomic.fence(i32 6)
+ fence seq_cst
+ ret void ; CHECK-NEXT: ret void
+}
+
+; This pattern gets emitted for ``__sync_synchronize`` and
+; ``asm("":::"memory")`` when Clang is configured for NaCl.
+;
+; CHECK-LABEL: @test_synchronize
+define void @test_synchronize() {
+ ; CHECK-NEXT: call void @llvm.nacl.atomic.fence.all()
+ call void asm sideeffect "", "~{memory}"()
+ fence seq_cst
+ call void asm sideeffect "", "~{memory}"()
+ ret void ; CHECK-NEXT: ret void
+}
+
+; Make sure the above pattern is respected and not partially-matched.
+;
+; CHECK-LABEL: @test_synchronize_bad1
+define void @test_synchronize_bad1() {
+ ; CHECK-NOT: call void @llvm.nacl.atomic.fence.all()
+ call void asm sideeffect "", "~{memory}"()
+ fence seq_cst
+ ret void
+}
+
+; CHECK-LABEL: @test_synchronize_bad2
+define void @test_synchronize_bad2() {
+ ; CHECK-NOT: call void @llvm.nacl.atomic.fence.all()
+ fence seq_cst
+ call void asm sideeffect "", "~{memory}"()
+ ret void
+}
« no previous file with comments | « test/Transforms/NaCl/atomic/lock_.ll ('k') | test/Transforms/NaCl/atomic/val_compare_and_swap.ll » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698