Skip to content

Commit 770bf24

Browse files
committed
rustc: Use in-bounds GEPs for fetching length and data of interior vectors
1 parent 4375329 commit 770bf24

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/comp/middle/trans.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2658,9 +2658,9 @@ fn get_ivec_len_and_data(&@block_ctxt bcx, ValueRef v, ty::t unit_ty) ->
26582658
tup(ValueRef, ValueRef, @block_ctxt) {
26592659
auto llunitty = type_of_or_i8(bcx, unit_ty);
26602660

2661-
auto stack_len = bcx.build.Load(bcx.build.GEP(v,
2661+
auto stack_len = bcx.build.Load(bcx.build.InBoundsGEP(v,
26622662
[C_int(0), C_uint(abi::ivec_elt_len)]));
2663-
auto stack_elem = bcx.build.GEP(v, [C_int(0),
2663+
auto stack_elem = bcx.build.InBoundsGEP(v, [C_int(0),
26642664
C_uint(abi::ivec_elt_elems)]);
26652665
stack_elem = bcx.build.PointerCast(stack_elem,
26662666
T_ptr(T_array(llunitty, 0u)));
@@ -2673,7 +2673,7 @@ fn get_ivec_len_and_data(&@block_ctxt bcx, ValueRef v, ty::t unit_ty) ->
26732673

26742674
auto heap_stub = on_heap_cx.build.PointerCast(v,
26752675
T_ptr(T_ivec_heap(llunitty)));
2676-
auto heap_ptr = on_heap_cx.build.Load(on_heap_cx.build.GEP(
2676+
auto heap_ptr = on_heap_cx.build.Load(on_heap_cx.build.InBoundsGEP(
26772677
heap_stub, [C_int(0), C_uint(abi::ivec_heap_stub_elt_ptr)]));
26782678

26792679
// Check whether the heap pointer is null. If it is, the vector length is
@@ -2695,9 +2695,10 @@ fn get_ivec_len_and_data(&@block_ctxt bcx, ValueRef v, ty::t unit_ty) ->
26952695
zero_len_cx.build.Br(next_cx.llbb);
26962696

26972697
// If we're here, then we actually have a heapified vector.
2698-
auto heap_len = nonzero_len_cx.build.Load(nonzero_len_cx.build.GEP(
2699-
heap_ptr, [C_int(0), C_uint(abi::ivec_heap_elt_len)]));
2700-
auto heap_elem = nonzero_len_cx.build.GEP(heap_ptr,
2698+
auto heap_len = nonzero_len_cx.build.Load(
2699+
nonzero_len_cx.build.InBoundsGEP(heap_ptr,
2700+
[C_int(0), C_uint(abi::ivec_heap_elt_len)]));
2701+
auto heap_elem = nonzero_len_cx.build.InBoundsGEP(heap_ptr,
27012702
[C_int(0), C_uint(abi::ivec_heap_elt_elems)]);
27022703
nonzero_len_cx.build.Br(next_cx.llbb);
27032704

0 commit comments

Comments
 (0)