Skip to content

Commit 1eec382

Browse files
committed
---
yaml --- r: 1939 b: refs/heads/master c: 7f3f66d h: refs/heads/master i: 1937: b2105bb 1935: e3bb41c v: v3
1 parent 580337a commit 1eec382

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
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: 607fa14960cbba1a993fa89acc0bcc02e900cecc
2+
refs/heads/master: 7f3f66df7b791ea16a64f5939a5607e8f50f23dc

trunk/src/comp/middle/trans.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3819,10 +3819,13 @@ fn trans_index(@block_ctxt cx, &ast.span sp, @ast.expr base,
38193819
ix_val = ix.val;
38203820
}
38213821

3822-
auto unit_sz = size_of(bcx, node_ann_type(cx.fcx.ccx, ann));
3822+
auto unit_ty = node_ann_type(cx.fcx.ccx, ann);
3823+
auto unit_sz = size_of(bcx, unit_ty);
38233824
bcx = unit_sz.bcx;
3825+
llvm.LLVMSetValueName(unit_sz.val, _str.buf("unit_sz"));
38243826

38253827
auto scaled_ix = bcx.build.Mul(ix_val, unit_sz.val);
3828+
llvm.LLVMSetValueName(scaled_ix, _str.buf("scaled_ix"));
38263829

38273830
auto lim = bcx.build.GEP(v, vec(C_int(0), C_int(abi.vec_elt_fill)));
38283831
lim = bcx.build.Load(lim);
@@ -3839,7 +3842,14 @@ fn trans_index(@block_ctxt cx, &ast.span sp, @ast.expr base,
38393842
fail_res.bcx.build.Br(next_cx.llbb);
38403843

38413844
auto body = next_cx.build.GEP(v, vec(C_int(0), C_int(abi.vec_elt_data)));
3842-
auto elt = next_cx.build.GEP(body, vec(C_int(0), ix_val));
3845+
auto elt;
3846+
if (ty.type_has_dynamic_size(unit_ty)) {
3847+
body = next_cx.build.PointerCast(body, T_ptr(T_array(T_i8(), 0u)));
3848+
elt = next_cx.build.GEP(body, vec(C_int(0), scaled_ix));
3849+
} else {
3850+
elt = next_cx.build.GEP(body, vec(C_int(0), ix_val));
3851+
}
3852+
38433853
ret lval_mem(next_cx, elt);
38443854
}
38453855

0 commit comments

Comments
 (0)