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

Side by Side Diff: test/NaCl/Bitcode/inttoptr-elide.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 unified diff | Download patch
OLDNEW
(Empty)
1 ; Test how we handle eliding inttoptr instructions.
2
3 ; RUN: llvm-as < %s | pnacl-freeze \
4 ; RUN: | pnacl-bcanalyzer -dump-records \
5 ; RUN: | FileCheck %s -check-prefix=PF2
6
7 ; RUN: llvm-as < %s | pnacl-freeze -allow-local-symbol-tables \
8 ; RUN: | pnacl-thaw -allow-local-symbol-tables \
9 ; RUN: | llvm-dis - | FileCheck %s -check-prefix=TD2
10
11 ; ------------------------------------------------------
12
13 ; Test that we elide the simple case of inttoptr of a load.
14 define void @SimpleLoad(i32 %i) {
15 %1 = inttoptr i32 %i to i32*
16 %2 = load i32* %1, align 4
17 ret void
18 }
19
20 ; TD2: define void @SimpleLoad(i32 %i) {
21 ; TD2-NEXT: %1 = inttoptr i32 %i to i32*
22 ; TD2-NEXT: %2 = load i32* %1, align 4
23 ; TD2-NEXT: ret void
24 ; TD2-NEXT: }
25
26 ; PF2: <FUNCTION_BLOCK>
27 ; PF2-NEXT: <DECLAREBLOCKS op0=1/>
28 ; PF2-NEXT: <INST_LOAD op0=1 op1=3 op2=0/>
29 ; PF2-NEXT: <INST_RET/>
30 ; PF2-NEXT: </FUNCTION_BLOCK>
31
32 ; ------------------------------------------------------
33
34 ; Test that we can handle multiple inttoptr of loads.
35 define i32 @TwoLoads(i32 %i) {
36 %1 = inttoptr i32 %i to i32*
37 %2 = load i32* %1, align 4
38 %3 = inttoptr i32 %i to i32*
39 %4 = load i32* %3, align 4
40 %5 = add i32 %2, %4
41 ret i32 %5
42 }
43
44 ; TD2: define i32 @TwoLoads(i32 %i) {
45 ; TD2-NEXT: %1 = inttoptr i32 %i to i32*
46 ; TD2-NEXT: %2 = load i32* %1, align 4
47 ; TD2-NEXT: %3 = load i32* %1, align 4
48 ; TD2-NEXT: %4 = add i32 %2, %3
49 ; TD2-NEXT: ret i32 %4
50 ; TD2-NEXT: }
51
52 ; PF2: <FUNCTION_BLOCK>
53 ; PF2-NEXT: <DECLAREBLOCKS op0=1/>
54 ; PF2-NEXT: <INST_LOAD op0=1 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/>
57 ; PF2-NEXT: <INST_RET op0=1/>
58 ; PF2-NEXT: </FUNCTION_BLOCK>
59
60 ; ------------------------------------------------------
61
62 ; Test how we handle inttoptrs, if optimized in the input file. This
63 ; case tests within a single block.
64 define i32 @TwoLoadOptOneBlock(i32 %i) {
65 %1 = inttoptr i32 %i to i32*
66 %2 = load i32* %1, align 4
67 %3 = load i32* %1, align 4
68 %4 = add i32 %2, %3
69 ret i32 %4
70 }
71
72 ; TD2: define i32 @TwoLoadOptOneBlock(i32 %i) {
73 ; TD2-NEXT: %1 = inttoptr i32 %i to i32*
74 ; TD2-NEXT: %2 = load i32* %1, align 4
75 ; TD2-NEXT: %3 = load i32* %1, align 4
76 ; TD2-NEXT: %4 = add i32 %2, %3
77 ; TD2-NEXT: ret i32 %4
78 ; TD2-NEXT: }
79
80 ; PF2: <FUNCTION_BLOCK>
81 ; PF2-NEXT: <DECLAREBLOCKS op0=1/>
82 ; PF2-NEXT: <INST_LOAD op0=1 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/>
85 ; PF2-NEXT: <INST_RET op0=1/>
86 ; PF2-NEXT: </FUNCTION_BLOCK>
87
88 ; ------------------------------------------------------
89
90 ; Test how we handle inttoptrs if optimized in the input file. This
91 ; case tests accross blocks.
92 define i32 @TwoLoadOptTwoBlocks(i32 %i) {
93 %1 = inttoptr i32 %i to i32*
94 %2 = load i32* %1, align 4
95 %3 = load i32* %1, align 4
96 %4 = add i32 %2, %3
97 br label %BB
98
99 BB:
100 %5 = load i32* %1, align 4
101 %6 = load i32* %1, align 4
102 %7 = add i32 %5, %6
103 ret i32 %7
104 }
105
106 ; TD2: define i32 @TwoLoadOptTwoBlocks(i32 %i) {
107 ; TD2-NEXT: %1 = inttoptr i32 %i to i32*
108 ; TD2-NEXT: %2 = load i32* %1, align 4
109 ; TD2-NEXT: %3 = load i32* %1, align 4
110 ; TD2-NEXT: %4 = add i32 %2, %3
111 ; TD2-NEXT: br label %BB
112 ; TD2: BB:
113 ; TD2-NEXT: %5 = inttoptr i32 %i to i32*
114 ; TD2-NEXT: %6 = load i32* %5, align 4
115 ; TD2-NEXT: %7 = load i32* %5, align 4
116 ; TD2-NEXT: %8 = add i32 %6, %7
117 ; TD2-NEXT: ret i32 %8
118 ; TD2-NEXT: }
119
120 ; PF2: <FUNCTION_BLOCK>
121 ; PF2-NEXT: <DECLAREBLOCKS op0=2/>
122 ; PF2-NEXT: <INST_LOAD op0=1 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/>
125 ; PF2-NEXT: <INST_BR op0=1/>
126 ; PF2-NEXT: <INST_LOAD op0=4 op1=3 op2=0/>
127 ; PF2-NEXT: <INST_LOAD op0=5 op1=3 op2=0/>
128 ; PF2-NEXT: <INST_BINOP op0=2 op1=1 op2=0/>
129 ; PF2-NEXT: <INST_RET op0=1/>
130 ; PF2-NEXT: </FUNCTION_BLOCK>
131
132 ; ------------------------------------------------------
133
134 ; Test that we elide the simple case of inttoptr for a store.
135 define void @SimpleStore(i32 %i) {
136 %1 = inttoptr i32 %i to i32*
137 store i32 %i, i32* %1, align 4
138 ret void
139 }
140
141 ; TD2: define void @SimpleStore(i32 %i) {
142 ; TD2-NEXT: %1 = inttoptr i32 %i to i32*
143 ; TD2-NEXT: store i32 %i, i32* %1, align 4
144 ; TD2-NEXT: ret void
145 ; TD2-NEXT: }
146
147 ; PF2: <FUNCTION_BLOCK>
148 ; PF2-NEXT: <DECLAREBLOCKS op0=1/>
149 ; PF2-NEXT: <INST_STORE op0=1 op1=1 op2=3/>
150 ; PF2-NEXT: <INST_RET/>
151 ; PF2-NEXT: </FUNCTION_BLOCK>
OLDNEW
« no previous file with comments | « test/NaCl/Bitcode/intrinsic-pointer-args.ll ('k') | test/NaCl/Bitcode/inttoptr-of-ptrtoint-elide.ll » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698