@@ -4,7 +4,7 @@ import syntax::ast;
4
4
import lib:: llvm:: llvm:: { ValueRef , TypeRef } ;
5
5
import back:: abi;
6
6
import trans:: { call_memmove, trans_shared_malloc, llsize_of, type_of_or_i8,
7
- incr_ptr , INIT , copy_val, load_if_immediate, alloca, size_of,
7
+ INIT , copy_val, load_if_immediate, alloca, size_of,
8
8
llderivedtydescs_block_ctxt, lazily_emit_tydesc_glue,
9
9
get_tydesc, load_inbounds, move_val_if_temp, trans_lval,
10
10
node_id_type, new_sub_block_ctxt, tps_normal, do_spill_noroot,
@@ -185,12 +185,9 @@ fn trans_append(cx: &@block_ctxt, vec_ty: ty::t, lhsptr: ValueRef,
185
185
copy_val ( bcx, INIT , write_ptr,
186
186
load_if_immediate ( bcx, addr, unit_ty) ,
187
187
unit_ty) ;
188
- if dynamic {
189
- incr_ptr ( bcx, write_ptr, unit_sz, write_ptr_ptr) ;
190
- } else {
191
- incr_ptr ( bcx, write_ptr, C_int ( 1 ) ,
192
- write_ptr_ptr) ;
193
- }
188
+ let incr = dynamic ? unit_sz : C_int ( 1 ) ;
189
+ Store ( bcx, InBoundsGEP ( bcx, write_ptr, [ incr] ) ,
190
+ write_ptr_ptr) ;
194
191
ret bcx;
195
192
} ) ;
196
193
ret rslt( bcx, C_nil ( ) ) ;
@@ -249,10 +246,10 @@ fn trans_add(bcx: &@block_ctxt, vec_ty: ty::t, lhsptr: ValueRef,
249
246
let bcx =
250
247
copy_val ( bcx, INIT , write_ptr,
251
248
load_if_immediate ( bcx, addr, unit_ty) , unit_ty) ;
252
- if ty:: type_has_dynamic_size ( bcx_tcx ( bcx) , unit_ty) {
253
- // We have to increment by the dynamically-computed size.
254
- incr_ptr ( bcx, write_ptr, llunitsz , write_ptr_ptr ) ;
255
- } else { incr_ptr ( bcx , write_ptr , C_int ( 1 ) , write_ptr_ptr) ; }
249
+ let incr = ty:: type_has_dynamic_size ( bcx_tcx ( bcx) , unit_ty) ?
250
+ llunitsz : C_int ( 1 ) ;
251
+ Store ( bcx , InBoundsGEP ( bcx, write_ptr, [ incr ] ) ,
252
+ write_ptr_ptr) ;
256
253
ret bcx;
257
254
} ( _, _, _, write_ptr_ptr, unit_ty, llunitsz) ;
258
255
@@ -277,12 +274,11 @@ fn iter_vec_raw(bcx: &@block_ctxt, vptrptr: ValueRef, vec_ty: ty::t,
277
274
// TODO: Optimize this when the size of the unit type is statically
278
275
// known to not use pointer casts, which tend to confuse LLVM.
279
276
let data_end_ptr = pointer_add ( bcx, data_ptr, fill) ;
280
- let data_ptr_ptr = do_spill_noroot ( bcx, data_ptr) ;
281
277
282
278
// Now perform the iteration.
283
279
let header_cx = new_sub_block_ctxt ( bcx, "iter_vec_loop_header" ) ;
284
280
Br ( bcx, header_cx. llbb ) ;
285
- let data_ptr = Load ( header_cx, data_ptr_ptr ) ;
281
+ let data_ptr = Phi ( header_cx, val_ty ( data_ptr ) , [ data_ptr ] , [ bcx . llbb ] ) ;
286
282
let not_yet_at_end =
287
283
ICmp ( header_cx, lib:: llvm:: LLVMIntULT , data_ptr, data_end_ptr) ;
288
284
let body_cx = new_sub_block_ctxt ( bcx, "iter_vec_loop_body" ) ;
@@ -293,9 +289,9 @@ fn iter_vec_raw(bcx: &@block_ctxt, vptrptr: ValueRef, vec_ty: ty::t,
293
289
if ty:: type_has_dynamic_size ( bcx_tcx ( bcx) , unit_ty) {
294
290
unit_sz
295
291
} else { C_int ( 1 ) } ;
296
- incr_ptr ( body_cx, data_ptr, increment, data_ptr_ptr) ;
292
+ AddIncomingToPhi ( data_ptr, [ InBoundsGEP ( body_cx, data_ptr,
293
+ [ increment] ) ] , [ body_cx. llbb ] ) ;
297
294
Br ( body_cx, header_cx. llbb ) ;
298
-
299
295
ret next_cx;
300
296
}
301
297
0 commit comments