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

Unified Diff: test/Transforms/NaCl/remove-asm-memory.ll

Issue 22474008: Add the new @llvm.nacl.atomic.fence.all intrinsic (Closed) Base URL: http://git.chromium.org/native_client/pnacl-llvm.git@master
Patch Set: Add note suggested by jvoung. Created 7 years, 4 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/atomics.ll ('k') | test/Transforms/NaCl/resolve-pnacl-intrinsics.ll » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/Transforms/NaCl/remove-asm-memory.ll
diff --git a/test/Transforms/NaCl/rewrite-asm-memory.ll b/test/Transforms/NaCl/remove-asm-memory.ll
similarity index 53%
rename from test/Transforms/NaCl/rewrite-asm-memory.ll
rename to test/Transforms/NaCl/remove-asm-memory.ll
index 8481c831eefaa80874289412e4c47d591c317daf..ae799a74597c8c152e3ddd5d50e63ec842552ea1 100644
--- a/test/Transforms/NaCl/rewrite-asm-memory.ll
+++ b/test/Transforms/NaCl/remove-asm-memory.ll
@@ -1,24 +1,37 @@
-; RUN: opt < %s -rewrite-asm-directives -S | FileCheck %s
-; RUN: opt < %s -O3 -rewrite-asm-directives -S | FileCheck %s
-; RUN: opt < %s -O3 -rewrite-asm-directives -S | FileCheck %s -check-prefix=ELIM
-; RUN: opt < %s -rewrite-asm-directives -S | FileCheck %s -check-prefix=CLEANED
+; RUN: opt < %s -nacl-rewrite-atomics -remove-asm-memory -S | \
+; RUN: FileCheck %s
+; RUN: opt < %s -O3 -nacl-rewrite-atomics -remove-asm-memory -S | \
+; RUN: FileCheck %s
+; RUN: opt < %s -O3 -nacl-rewrite-atomics -remove-asm-memory -S | \
+; RUN: FileCheck %s -check-prefix=ELIM
+; RUN: opt < %s -nacl-rewrite-atomics -remove-asm-memory -S | \
+; RUN: FileCheck %s -check-prefix=CLEANED
-; Test that asm("":::"memory"), a compiler barrier, gets rewritten to a
-; sequentially-consistent fence. The test is also run at O3 to make sure
-; that loads and stores don't get unexpectedly eliminated.
+; ``asm("":::"memory")`` is used as a compiler barrier and the GCC-style
+; builtin ``__sync_synchronize`` is intended as a barrier for all memory
+; that could be observed by external threads. They both get rewritten
+; for NaCl by Clang to a sequentially-consistent fence surrounded by
+; ``call void asm sideeffect "", "~{memory}"``.
+;
+; The test is also run at O3 to make sure that non-volatile and
+; non-atomic loads and stores to escaping objects (i.e. loads and stores
+; which could be observed by other threads) don't get unexpectedly
+; eliminated.
; CLEANED-NOT: asm
+target datalayout = "p:32:32:32"
+
@a = external global i32
@b = external global i32
-; Different triples encode "touch everything" constraints differently.
+; Different triples encode ``asm("":::"memory")``'s "touch everything"
+; constraints differently. They should get detected and removed.
define void @memory_assembly_encoding_test() {
; CHECK: @memory_assembly_encoding_test()
call void asm sideeffect "", "~{memory}"()
call void asm sideeffect "", "~{memory},~{dirflag},~{fpsr},~{flags}"()
- ; CHECK-NEXT: fence seq_cst
- ; CHECK-NEXT: fence seq_cst
+ call void asm sideeffect "", "~{foo},~{memory},~{bar}"()
ret void
; CHECK-NEXT: ret void
@@ -29,9 +42,11 @@ define void @memory_assembly_ordering_test() {
%1 = load i32* @a, align 4
store i32 %1, i32* @b, align 4
call void asm sideeffect "", "~{memory}"()
+ fence seq_cst
+ call void asm sideeffect "", "~{memory}"()
; CHECK-NEXT: %1 = load i32* @a, align 4
; CHECK-NEXT: store i32 %1, i32* @b, align 4
- ; CHECK-NEXT: fence seq_cst
+ ; CHECK-NEXT: call void @llvm.nacl.atomic.fence.all()
; Redundant load from the previous location, and store to the same
; location (making the previous one dead). Shouldn't get eliminated
@@ -39,9 +54,11 @@ define void @memory_assembly_ordering_test() {
%2 = load i32* @a, align 4
store i32 %2, i32* @b, align 4
call void asm sideeffect "", "~{memory}"()
+ fence seq_cst
+ call void asm sideeffect "", "~{memory}"()
; CHECK-NEXT: %2 = load i32* @a, align 4
; CHECK-NEXT: store i32 %2, i32* @b, align 4
- ; CHECK-NEXT: fence seq_cst
+ ; CHECK-NEXT: call void @llvm.nacl.atomic.fence.all()
; Same here.
%3 = load i32* @a, align 4
« no previous file with comments | « test/Transforms/NaCl/atomics.ll ('k') | test/Transforms/NaCl/resolve-pnacl-intrinsics.ll » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698