Skip to content

Commit 75fdc42

Browse files
committed
---
yaml --- r: 5185 b: refs/heads/master c: 9fb3ec9 h: refs/heads/master i: 5183: 656a8d1 v: v3
1 parent 9f04b0e commit 75fdc42

File tree

3 files changed

+12
-22
lines changed

3 files changed

+12
-22
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 139b1d1b314edce0584646a4032e6a6e66167b71
2+
refs/heads/master: 9fb3ec95e049f7af53e0ae280d966c469307bf92

trunk/src/comp/middle/trans.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1629,12 +1629,6 @@ fn store_inbounds(cx: &@block_ctxt, v: ValueRef, p: ValueRef,
16291629
Store(cx, v, InBoundsGEP(cx, p, idxs));
16301630
}
16311631

1632-
// This uses store and inboundsGEP, but it only doing so superficially; it's
1633-
// really storing an incremented pointer to another pointer.
1634-
fn incr_ptr(cx: &@block_ctxt, p: ValueRef, incr: ValueRef, pp: ValueRef) {
1635-
Store(cx, InBoundsGEP(cx, p, [incr]), pp);
1636-
}
1637-
16381632
// Iterates through the elements of a structural type.
16391633
fn iter_structural_ty(cx: @block_ctxt, av: ValueRef, t: ty::t,
16401634
f: &val_and_ty_fn) -> @block_ctxt {

trunk/src/comp/middle/trans_vec.rs

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import syntax::ast;
44
import lib::llvm::llvm::{ValueRef, TypeRef};
55
import back::abi;
66
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,
88
llderivedtydescs_block_ctxt, lazily_emit_tydesc_glue,
99
get_tydesc, load_inbounds, move_val_if_temp, trans_lval,
1010
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,
185185
copy_val(bcx, INIT, write_ptr,
186186
load_if_immediate(bcx, addr, unit_ty),
187187
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);
194191
ret bcx;
195192
});
196193
ret rslt(bcx, C_nil());
@@ -249,10 +246,10 @@ fn trans_add(bcx: &@block_ctxt, vec_ty: ty::t, lhsptr: ValueRef,
249246
let bcx =
250247
copy_val(bcx, INIT, write_ptr,
251248
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);
256253
ret bcx;
257254
}(_, _, _, write_ptr_ptr, unit_ty, llunitsz);
258255

@@ -277,12 +274,11 @@ fn iter_vec_raw(bcx: &@block_ctxt, vptrptr: ValueRef, vec_ty: ty::t,
277274
// TODO: Optimize this when the size of the unit type is statically
278275
// known to not use pointer casts, which tend to confuse LLVM.
279276
let data_end_ptr = pointer_add(bcx, data_ptr, fill);
280-
let data_ptr_ptr = do_spill_noroot(bcx, data_ptr);
281277

282278
// Now perform the iteration.
283279
let header_cx = new_sub_block_ctxt(bcx, "iter_vec_loop_header");
284280
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]);
286282
let not_yet_at_end =
287283
ICmp(header_cx, lib::llvm::LLVMIntULT, data_ptr, data_end_ptr);
288284
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,
293289
if ty::type_has_dynamic_size(bcx_tcx(bcx), unit_ty) {
294290
unit_sz
295291
} 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]);
297294
Br(body_cx, header_cx.llbb);
298-
299295
ret next_cx;
300296
}
301297

0 commit comments

Comments
 (0)