Skip to content

Commit a4eb663

Browse files
committed
rustc: Increment by the dynamically-computed size in ivec::trans_append. Uncomment init_fn test in lib-ivec.
1 parent 59c76a3 commit a4eb663

File tree

2 files changed

+22
-10
lines changed

2 files changed

+22
-10
lines changed

src/comp/middle/trans.rs

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3473,14 +3473,18 @@ mod ivec {
34733473
}
34743474
}
34753475

3476+
auto rslt = size_of(cx, unit_ty);
3477+
auto bcx = rslt.bcx;
3478+
auto unit_sz = rslt.val;
3479+
34763480
// Gather the various type descriptors we'll need.
34773481

34783482
// FIXME (issue #511): This is needed to prevent a leak.
34793483
auto no_tydesc_info = none;
34803484

3481-
auto rslt = get_tydesc(cx, t, false, no_tydesc_info);
3485+
rslt = get_tydesc(bcx, t, false, no_tydesc_info);
34823486
auto vec_tydesc = rslt.val;
3483-
auto bcx = rslt.bcx;
3487+
bcx = rslt.bcx;
34843488
rslt = get_tydesc(bcx, unit_ty, false, no_tydesc_info);
34853489
auto unit_tydesc = rslt.val;
34863490
bcx = rslt.bcx;
@@ -3526,12 +3530,19 @@ mod ivec {
35263530
auto post_copy_cx = rslt.bcx;
35273531
// Increment both pointers.
35283532

3529-
post_copy_cx.build.Store(post_copy_cx.build.InBoundsGEP(copy_dest_ptr,
3530-
[C_int(1)]),
3531-
dest_ptr);
3532-
post_copy_cx.build.Store(post_copy_cx.build.InBoundsGEP(copy_src_ptr,
3533-
[C_int(1)]),
3534-
src_ptr);
3533+
if (ty::type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, t)) {
3534+
// We have to increment by the dynamically-computed size.
3535+
post_copy_cx.build.Store(post_copy_cx.build.InBoundsGEP(
3536+
copy_dest_ptr, [unit_sz]), dest_ptr);
3537+
post_copy_cx.build.Store(post_copy_cx.build.InBoundsGEP(
3538+
copy_src_ptr, [unit_sz]), src_ptr);
3539+
} else {
3540+
post_copy_cx.build.Store(post_copy_cx.build.InBoundsGEP(
3541+
copy_dest_ptr, [C_int(1)]), dest_ptr);
3542+
post_copy_cx.build.Store(post_copy_cx.build.InBoundsGEP(
3543+
copy_src_ptr, [C_int(1)]), src_ptr);
3544+
}
3545+
35353546
post_copy_cx.build.Br(copy_loop_header_cx.llbb);
35363547
ret res(next_cx, C_nil());
35373548
}
@@ -6656,7 +6667,8 @@ fn new_block_ctxt(&@fn_ctxt cx, &block_parent parent, block_kind kind,
66566667
&str name) -> @block_ctxt {
66576668
let vec[cleanup] cleanups = [];
66586669
auto s = str::buf("");
6659-
if (cx.lcx.ccx.sess.get_opts().save_temps) {
6670+
if (cx.lcx.ccx.sess.get_opts().save_temps ||
6671+
cx.lcx.ccx.sess.get_opts().debuginfo) {
66606672
s = str::buf(cx.lcx.ccx.names.next(name));
66616673
}
66626674
let BasicBlockRef llbb = llvm::LLVMAppendBasicBlock(cx.llfn, s);

src/test/run-pass/lib-ivec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,6 @@ fn test_init_fn() {
5757
fn main() {
5858
test_reserve_and_on_heap();
5959
test_unsafe_ptrs();
60-
//test_init_fn();
60+
test_init_fn();
6161
}
6262

0 commit comments

Comments
 (0)