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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 ; RUN: opt < %s -rewrite-asm-directives -S | FileCheck %s 1 ; RUN: opt < %s -nacl-rewrite-atomics -remove-asm-memory -S | \
2 ; RUN: opt < %s -O3 -rewrite-asm-directives -S | FileCheck %s 2 ; RUN: FileCheck %s
3 ; RUN: opt < %s -O3 -rewrite-asm-directives -S | FileCheck %s -check-prefix=ELIM 3 ; RUN: opt < %s -O3 -nacl-rewrite-atomics -remove-asm-memory -S | \
4 ; RUN: opt < %s -rewrite-asm-directives -S | FileCheck %s -check-prefix=CLEANED 4 ; RUN: FileCheck %s
5 ; RUN: opt < %s -O3 -nacl-rewrite-atomics -remove-asm-memory -S | \
6 ; RUN: FileCheck %s -check-prefix=ELIM
7 ; RUN: opt < %s -nacl-rewrite-atomics -remove-asm-memory -S | \
8 ; RUN: FileCheck %s -check-prefix=CLEANED
5 9
6 ; Test that asm("":::"memory"), a compiler barrier, gets rewritten to a 10 ; ``asm("":::"memory")`` is used as a compiler barrier and the GCC-style
7 ; sequentially-consistent fence. The test is also run at O3 to make sure 11 ; builtin ``__sync_synchronize`` is intended as a barrier for all memory
8 ; that loads and stores don't get unexpectedly eliminated. 12 ; that could be observed by external threads. They both get rewritten
13 ; for NaCl by Clang to a sequentially-consistent fence surrounded by
14 ; ``call void asm sideeffect "", "~{memory}"``.
15 ;
16 ; The test is also run at O3 to make sure that non-volatile and
17 ; non-atomic loads and stores to escaping objects (i.e. loads and stores
18 ; which could be observed by other threads) don't get unexpectedly
19 ; eliminated.
9 20
10 ; CLEANED-NOT: asm 21 ; CLEANED-NOT: asm
11 22
23 target datalayout = "p:32:32:32"
24
12 @a = external global i32 25 @a = external global i32
13 @b = external global i32 26 @b = external global i32
14 27
15 ; Different triples encode "touch everything" constraints differently. 28 ; Different triples encode ``asm("":::"memory")``'s "touch everything"
29 ; constraints differently. They should get detected and removed.
16 define void @memory_assembly_encoding_test() { 30 define void @memory_assembly_encoding_test() {
17 ; CHECK: @memory_assembly_encoding_test() 31 ; CHECK: @memory_assembly_encoding_test()
18 call void asm sideeffect "", "~{memory}"() 32 call void asm sideeffect "", "~{memory}"()
19 call void asm sideeffect "", "~{memory},~{dirflag},~{fpsr},~{flags}"() 33 call void asm sideeffect "", "~{memory},~{dirflag},~{fpsr},~{flags}"()
20 ; CHECK-NEXT: fence seq_cst 34 call void asm sideeffect "", "~{foo},~{memory},~{bar}"()
21 ; CHECK-NEXT: fence seq_cst
22 35
23 ret void 36 ret void
24 ; CHECK-NEXT: ret void 37 ; CHECK-NEXT: ret void
25 } 38 }
26 39
27 define void @memory_assembly_ordering_test() { 40 define void @memory_assembly_ordering_test() {
28 ; CHECK: @memory_assembly_ordering_test() 41 ; CHECK: @memory_assembly_ordering_test()
29 %1 = load i32* @a, align 4 42 %1 = load i32* @a, align 4
30 store i32 %1, i32* @b, align 4 43 store i32 %1, i32* @b, align 4
31 call void asm sideeffect "", "~{memory}"() 44 call void asm sideeffect "", "~{memory}"()
45 fence seq_cst
46 call void asm sideeffect "", "~{memory}"()
32 ; CHECK-NEXT: %1 = load i32* @a, align 4 47 ; CHECK-NEXT: %1 = load i32* @a, align 4
33 ; CHECK-NEXT: store i32 %1, i32* @b, align 4 48 ; CHECK-NEXT: store i32 %1, i32* @b, align 4
34 ; CHECK-NEXT: fence seq_cst 49 ; CHECK-NEXT: call void @llvm.nacl.atomic.fence.all()
35 50
36 ; Redundant load from the previous location, and store to the same 51 ; Redundant load from the previous location, and store to the same
37 ; location (making the previous one dead). Shouldn't get eliminated 52 ; location (making the previous one dead). Shouldn't get eliminated
38 ; because of the fence. 53 ; because of the fence.
39 %2 = load i32* @a, align 4 54 %2 = load i32* @a, align 4
40 store i32 %2, i32* @b, align 4 55 store i32 %2, i32* @b, align 4
41 call void asm sideeffect "", "~{memory}"() 56 call void asm sideeffect "", "~{memory}"()
57 fence seq_cst
58 call void asm sideeffect "", "~{memory}"()
42 ; CHECK-NEXT: %2 = load i32* @a, align 4 59 ; CHECK-NEXT: %2 = load i32* @a, align 4
43 ; CHECK-NEXT: store i32 %2, i32* @b, align 4 60 ; CHECK-NEXT: store i32 %2, i32* @b, align 4
44 ; CHECK-NEXT: fence seq_cst 61 ; CHECK-NEXT: call void @llvm.nacl.atomic.fence.all()
45 62
46 ; Same here. 63 ; Same here.
47 %3 = load i32* @a, align 4 64 %3 = load i32* @a, align 4
48 store i32 %3, i32* @b, align 4 65 store i32 %3, i32* @b, align 4
49 ; CHECK-NEXT: %3 = load i32* @a, align 4 66 ; CHECK-NEXT: %3 = load i32* @a, align 4
50 ; CHECK-NEXT: store i32 %3, i32* @b, align 4 67 ; CHECK-NEXT: store i32 %3, i32* @b, align 4
51 68
52 ret void 69 ret void
53 ; CHECK-NEXT: ret void 70 ; CHECK-NEXT: ret void
54 } 71 }
55 72
56 ; Same function as above, but without the barriers. At O3 some loads and 73 ; Same function as above, but without the barriers. At O3 some loads and
57 ; stores should get eliminated. 74 ; stores should get eliminated.
58 define void @memory_ordering_test() { 75 define void @memory_ordering_test() {
59 ; ELIM: @memory_ordering_test() 76 ; ELIM: @memory_ordering_test()
60 %1 = load i32* @a, align 4 77 %1 = load i32* @a, align 4
61 store i32 %1, i32* @b, align 4 78 store i32 %1, i32* @b, align 4
62 %2 = load i32* @a, align 4 79 %2 = load i32* @a, align 4
63 store i32 %2, i32* @b, align 4 80 store i32 %2, i32* @b, align 4
64 %3 = load i32* @a, align 4 81 %3 = load i32* @a, align 4
65 store i32 %3, i32* @b, align 4 82 store i32 %3, i32* @b, align 4
66 ; ELIM-NEXT: %1 = load i32* @a, align 4 83 ; ELIM-NEXT: %1 = load i32* @a, align 4
67 ; ELIM-NEXT: store i32 %1, i32* @b, align 4 84 ; ELIM-NEXT: store i32 %1, i32* @b, align 4
68 85
69 ret void 86 ret void
70 ; ELIM-NEXT: ret void 87 ; ELIM-NEXT: ret void
71 } 88 }
OLDNEW
« 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