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

Side by Side Diff: test/NaCl/Bitcode/inttoptr-elide.ll

Issue 1151093004: Changes from 3.7 merge to files not in upstream (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-llvm.git@master
Patch Set: Created 5 years, 7 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
OLDNEW
1 ; Test how we handle eliding inttoptr instructions. 1 ; Test how we handle eliding inttoptr instructions.
2 2
3 ; RUN: llvm-as < %s | pnacl-freeze \ 3 ; RUN: llvm-as < %s | pnacl-freeze \
4 ; RUN: | pnacl-bcanalyzer -dump-records \ 4 ; RUN: | pnacl-bcanalyzer -dump-records \
5 ; RUN: | FileCheck %s -check-prefix=PF2 5 ; RUN: | FileCheck %s -check-prefix=PF2
6 6
7 ; RUN: llvm-as < %s | pnacl-freeze -allow-local-symbol-tables \ 7 ; RUN: llvm-as < %s | pnacl-freeze -allow-local-symbol-tables \
8 ; RUN: | pnacl-thaw -allow-local-symbol-tables \ 8 ; RUN: | pnacl-thaw -allow-local-symbol-tables \
9 ; RUN: | llvm-dis - | FileCheck %s -check-prefix=TD2 9 ; RUN: | llvm-dis - | FileCheck %s -check-prefix=TD2
10 10
11 ; ------------------------------------------------------ 11 ; ------------------------------------------------------
12 12
13 ; Test that we elide the simple case of inttoptr of a load. 13 ; Test that we elide the simple case of inttoptr of a load.
14 define void @SimpleLoad(i32 %i) { 14 define void @SimpleLoad(i32 %i) {
15 %1 = inttoptr i32 %i to i32* 15 %1 = inttoptr i32 %i to i32*
16 %2 = load i32* %1, align 4 16 %2 = load i32, i32* %1, align 4
17 ret void 17 ret void
18 } 18 }
19 19
20 ; TD2: define void @SimpleLoad(i32 %i) { 20 ; TD2: define void @SimpleLoad(i32 %i) {
21 ; TD2-NEXT: %1 = inttoptr i32 %i to i32* 21 ; TD2-NEXT: %1 = inttoptr i32 %i to i32*
22 ; TD2-NEXT: %2 = load i32* %1, align 4 22 ; TD2-NEXT: %2 = load i32, i32* %1, align 4
23 ; TD2-NEXT: ret void 23 ; TD2-NEXT: ret void
24 ; TD2-NEXT: } 24 ; TD2-NEXT: }
25 25
26 ; PF2: <FUNCTION_BLOCK> 26 ; PF2: <FUNCTION_BLOCK>
27 ; PF2-NEXT: <DECLAREBLOCKS op0=1/> 27 ; PF2-NEXT: <DECLAREBLOCKS op0=1/>
28 ; PF2-NEXT: <INST_LOAD op0=1 op1=3 op2=0/> 28 ; PF2-NEXT: <INST_LOAD op0=1 op1=3 op2=0/>
29 ; PF2-NEXT: <INST_RET/> 29 ; PF2-NEXT: <INST_RET/>
30 ; PF2-NEXT: </FUNCTION_BLOCK> 30 ; PF2-NEXT: </FUNCTION_BLOCK>
31 31
32 ; ------------------------------------------------------ 32 ; ------------------------------------------------------
33 33
34 ; Test that we can handle multiple inttoptr of loads. 34 ; Test that we can handle multiple inttoptr of loads.
35 define i32 @TwoLoads(i32 %i) { 35 define i32 @TwoLoads(i32 %i) {
36 %1 = inttoptr i32 %i to i32* 36 %1 = inttoptr i32 %i to i32*
37 %2 = load i32* %1, align 4 37 %2 = load i32, i32* %1, align 4
38 %3 = inttoptr i32 %i to i32* 38 %3 = inttoptr i32 %i to i32*
39 %4 = load i32* %3, align 4 39 %4 = load i32, i32* %3, align 4
40 %5 = add i32 %2, %4 40 %5 = add i32 %2, %4
41 ret i32 %5 41 ret i32 %5
42 } 42 }
43 43
44 ; TD2: define i32 @TwoLoads(i32 %i) { 44 ; TD2: define i32 @TwoLoads(i32 %i) {
45 ; TD2-NEXT: %1 = inttoptr i32 %i to i32* 45 ; TD2-NEXT: %1 = inttoptr i32 %i to i32*
46 ; TD2-NEXT: %2 = load i32* %1, align 4 46 ; TD2-NEXT: %2 = load i32, i32* %1, align 4
47 ; TD2-NEXT: %3 = load i32* %1, align 4 47 ; TD2-NEXT: %3 = load i32, i32* %1, align 4
48 ; TD2-NEXT: %4 = add i32 %2, %3 48 ; TD2-NEXT: %4 = add i32 %2, %3
49 ; TD2-NEXT: ret i32 %4 49 ; TD2-NEXT: ret i32 %4
50 ; TD2-NEXT: } 50 ; TD2-NEXT: }
51 51
52 ; PF2: <FUNCTION_BLOCK> 52 ; PF2: <FUNCTION_BLOCK>
53 ; PF2-NEXT: <DECLAREBLOCKS op0=1/> 53 ; PF2-NEXT: <DECLAREBLOCKS op0=1/>
54 ; PF2-NEXT: <INST_LOAD op0=1 op1=3 op2=0/> 54 ; PF2-NEXT: <INST_LOAD op0=1 op1=3 op2=0/>
55 ; PF2-NEXT: <INST_LOAD op0=2 op1=3 op2=0/> 55 ; PF2-NEXT: <INST_LOAD op0=2 op1=3 op2=0/>
56 ; PF2-NEXT: <INST_BINOP op0=2 op1=1 op2=0/> 56 ; PF2-NEXT: <INST_BINOP op0=2 op1=1 op2=0/>
57 ; PF2-NEXT: <INST_RET op0=1/> 57 ; PF2-NEXT: <INST_RET op0=1/>
58 ; PF2-NEXT: </FUNCTION_BLOCK> 58 ; PF2-NEXT: </FUNCTION_BLOCK>
59 59
60 ; ------------------------------------------------------ 60 ; ------------------------------------------------------
61 61
62 ; Test how we handle inttoptrs, if optimized in the input file. This 62 ; Test how we handle inttoptrs, if optimized in the input file. This
63 ; case tests within a single block. 63 ; case tests within a single block.
64 define i32 @TwoLoadOptOneBlock(i32 %i) { 64 define i32 @TwoLoadOptOneBlock(i32 %i) {
65 %1 = inttoptr i32 %i to i32* 65 %1 = inttoptr i32 %i to i32*
66 %2 = load i32* %1, align 4 66 %2 = load i32, i32* %1, align 4
67 %3 = load i32* %1, align 4 67 %3 = load i32, i32* %1, align 4
68 %4 = add i32 %2, %3 68 %4 = add i32 %2, %3
69 ret i32 %4 69 ret i32 %4
70 } 70 }
71 71
72 ; TD2: define i32 @TwoLoadOptOneBlock(i32 %i) { 72 ; TD2: define i32 @TwoLoadOptOneBlock(i32 %i) {
73 ; TD2-NEXT: %1 = inttoptr i32 %i to i32* 73 ; TD2-NEXT: %1 = inttoptr i32 %i to i32*
74 ; TD2-NEXT: %2 = load i32* %1, align 4 74 ; TD2-NEXT: %2 = load i32, i32* %1, align 4
75 ; TD2-NEXT: %3 = load i32* %1, align 4 75 ; TD2-NEXT: %3 = load i32, i32* %1, align 4
76 ; TD2-NEXT: %4 = add i32 %2, %3 76 ; TD2-NEXT: %4 = add i32 %2, %3
77 ; TD2-NEXT: ret i32 %4 77 ; TD2-NEXT: ret i32 %4
78 ; TD2-NEXT: } 78 ; TD2-NEXT: }
79 79
80 ; PF2: <FUNCTION_BLOCK> 80 ; PF2: <FUNCTION_BLOCK>
81 ; PF2-NEXT: <DECLAREBLOCKS op0=1/> 81 ; PF2-NEXT: <DECLAREBLOCKS op0=1/>
82 ; PF2-NEXT: <INST_LOAD op0=1 op1=3 op2=0/> 82 ; PF2-NEXT: <INST_LOAD op0=1 op1=3 op2=0/>
83 ; PF2-NEXT: <INST_LOAD op0=2 op1=3 op2=0/> 83 ; PF2-NEXT: <INST_LOAD op0=2 op1=3 op2=0/>
84 ; PF2-NEXT: <INST_BINOP op0=2 op1=1 op2=0/> 84 ; PF2-NEXT: <INST_BINOP op0=2 op1=1 op2=0/>
85 ; PF2-NEXT: <INST_RET op0=1/> 85 ; PF2-NEXT: <INST_RET op0=1/>
86 ; PF2-NEXT: </FUNCTION_BLOCK> 86 ; PF2-NEXT: </FUNCTION_BLOCK>
87 87
88 ; ------------------------------------------------------ 88 ; ------------------------------------------------------
89 89
90 ; Test how we handle inttoptrs if optimized in the input file. This 90 ; Test how we handle inttoptrs if optimized in the input file. This
91 ; case tests accross blocks. 91 ; case tests accross blocks.
92 define i32 @TwoLoadOptTwoBlocks(i32 %i) { 92 define i32 @TwoLoadOptTwoBlocks(i32 %i) {
93 %1 = inttoptr i32 %i to i32* 93 %1 = inttoptr i32 %i to i32*
94 %2 = load i32* %1, align 4 94 %2 = load i32, i32* %1, align 4
95 %3 = load i32* %1, align 4 95 %3 = load i32, i32* %1, align 4
96 %4 = add i32 %2, %3 96 %4 = add i32 %2, %3
97 br label %BB 97 br label %BB
98 98
99 BB: 99 BB:
100 %5 = load i32* %1, align 4 100 %5 = load i32, i32* %1, align 4
101 %6 = load i32* %1, align 4 101 %6 = load i32, i32* %1, align 4
102 %7 = add i32 %5, %6 102 %7 = add i32 %5, %6
103 ret i32 %7 103 ret i32 %7
104 } 104 }
105 105
106 ; TD2: define i32 @TwoLoadOptTwoBlocks(i32 %i) { 106 ; TD2: define i32 @TwoLoadOptTwoBlocks(i32 %i) {
107 ; TD2-NEXT: %1 = inttoptr i32 %i to i32* 107 ; TD2-NEXT: %1 = inttoptr i32 %i to i32*
108 ; TD2-NEXT: %2 = load i32* %1, align 4 108 ; TD2-NEXT: %2 = load i32, i32* %1, align 4
109 ; TD2-NEXT: %3 = load i32* %1, align 4 109 ; TD2-NEXT: %3 = load i32, i32* %1, align 4
110 ; TD2-NEXT: %4 = add i32 %2, %3 110 ; TD2-NEXT: %4 = add i32 %2, %3
111 ; TD2-NEXT: br label %BB 111 ; TD2-NEXT: br label %BB
112 ; TD2: BB: 112 ; TD2: BB:
113 ; TD2-NEXT: %5 = inttoptr i32 %i to i32* 113 ; TD2-NEXT: %5 = inttoptr i32 %i to i32*
114 ; TD2-NEXT: %6 = load i32* %5, align 4 114 ; TD2-NEXT: %6 = load i32, i32* %5, align 4
115 ; TD2-NEXT: %7 = load i32* %5, align 4 115 ; TD2-NEXT: %7 = load i32, i32* %5, align 4
116 ; TD2-NEXT: %8 = add i32 %6, %7 116 ; TD2-NEXT: %8 = add i32 %6, %7
117 ; TD2-NEXT: ret i32 %8 117 ; TD2-NEXT: ret i32 %8
118 ; TD2-NEXT: } 118 ; TD2-NEXT: }
119 119
120 ; PF2: <FUNCTION_BLOCK> 120 ; PF2: <FUNCTION_BLOCK>
121 ; PF2-NEXT: <DECLAREBLOCKS op0=2/> 121 ; PF2-NEXT: <DECLAREBLOCKS op0=2/>
122 ; PF2-NEXT: <INST_LOAD op0=1 op1=3 op2=0/> 122 ; PF2-NEXT: <INST_LOAD op0=1 op1=3 op2=0/>
123 ; PF2-NEXT: <INST_LOAD op0=2 op1=3 op2=0/> 123 ; PF2-NEXT: <INST_LOAD op0=2 op1=3 op2=0/>
124 ; PF2-NEXT: <INST_BINOP op0=2 op1=1 op2=0/> 124 ; PF2-NEXT: <INST_BINOP op0=2 op1=1 op2=0/>
125 ; PF2-NEXT: <INST_BR op0=1/> 125 ; PF2-NEXT: <INST_BR op0=1/>
(...skipping 16 matching lines...) Expand all
142 ; TD2-NEXT: %1 = inttoptr i32 %i to i32* 142 ; TD2-NEXT: %1 = inttoptr i32 %i to i32*
143 ; TD2-NEXT: store i32 %i, i32* %1, align 4 143 ; TD2-NEXT: store i32 %i, i32* %1, align 4
144 ; TD2-NEXT: ret void 144 ; TD2-NEXT: ret void
145 ; TD2-NEXT: } 145 ; TD2-NEXT: }
146 146
147 ; PF2: <FUNCTION_BLOCK> 147 ; PF2: <FUNCTION_BLOCK>
148 ; PF2-NEXT: <DECLAREBLOCKS op0=1/> 148 ; PF2-NEXT: <DECLAREBLOCKS op0=1/>
149 ; PF2-NEXT: <INST_STORE op0=1 op1=1 op2=3/> 149 ; PF2-NEXT: <INST_STORE op0=1 op1=1 op2=3/>
150 ; PF2-NEXT: <INST_RET/> 150 ; PF2-NEXT: <INST_RET/>
151 ; PF2-NEXT: </FUNCTION_BLOCK> 151 ; PF2-NEXT: </FUNCTION_BLOCK>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698