@@ -1228,7 +1228,7 @@ fn dynamic_size_of(@block_ctxt cx, ty.t t) -> result {
1228
1228
auto elt_size = size_of( bcx, e) ;
1229
1229
bcx = elt_size. bcx;
1230
1230
auto aligned_off = align_to( bcx, off, elt_align. val) ;
1231
- off = cx . build. Add ( aligned_off, elt_size. val) ;
1231
+ off = bcx . build. Add ( aligned_off, elt_size. val) ;
1232
1232
max_align = umax( bcx, max_align, elt_align. val) ;
1233
1233
}
1234
1234
off = align_to( bcx, off, max_align) ;
@@ -1488,7 +1488,7 @@ fn trans_raw_malloc(@block_ctxt cx, TypeRef llptr_ty, ValueRef llsize)
1488
1488
// FIXME: need a table to collect tydesc globals.
1489
1489
auto tydesc = C_int ( 0 ) ;
1490
1490
auto rslt = trans_upcall( cx, "upcall_malloc" , vec( llsize, tydesc) ) ;
1491
- rslt = res( rslt. bcx, vi2p( cx , rslt. val, llptr_ty) ) ;
1491
+ rslt = res( rslt. bcx, vi2p( rslt . bcx , rslt. val, llptr_ty) ) ;
1492
1492
ret rslt;
1493
1493
}
1494
1494
@@ -1949,6 +1949,8 @@ fn make_drop_glue(@block_ctxt cx, ValueRef v0, ty.t t) {
1949
1949
ty. type_is_native ( cx. fcx . lcx . ccx . tcx , t) ||
1950
1950
ty. type_is_nil ( cx. fcx . lcx . ccx . tcx , t) ) {
1951
1951
rslt = res ( cx, C_nil ( ) ) ;
1952
+ } else {
1953
+ rslt = res ( cx, C_nil ( ) ) ;
1952
1954
}
1953
1955
}
1954
1956
}
@@ -2356,7 +2358,7 @@ fn iter_structural_ty_full(@block_ctxt cx,
2356
2358
2357
2359
auto r = f ( inner_cx, box_a_ptr, box_b_ptr, tbox) ;
2358
2360
r. bcx . build . Br ( next_cx. llbb ) ;
2359
- ret res ( next_cx, r . val ) ;
2361
+ ret res ( next_cx, C_nil ( ) ) ;
2360
2362
}
2361
2363
2362
2364
alt ( ty. struct ( cx. fcx . lcx . ccx . tcx , t) ) {
@@ -2626,7 +2628,7 @@ fn iter_sequence(@block_ctxt cx,
2626
2628
auto p1 = vi2p( bcx, bcx. build. Add ( vp2i( bcx, p0) , len) ,
2627
2629
T_ptr ( llunit_ty) ) ;
2628
2630
2629
- ret iter_sequence_inner( cx , p0, p1, elt_ty, f) ;
2631
+ ret iter_sequence_inner( bcx , p0, p1, elt_ty, f) ;
2630
2632
}
2631
2633
2632
2634
alt ( ty. struct ( cx. fcx. lcx. ccx. tcx, t) ) {
@@ -2660,11 +2662,13 @@ fn call_tydesc_glue_full(@block_ctxt cx, ValueRef v,
2660
2662
llrawptr) ) ;
2661
2663
}
2662
2664
2663
- fn call_tydesc_glue( @block_ctxt cx, ValueRef v, ty. t t, int field) {
2665
+ fn call_tydesc_glue( @block_ctxt cx, ValueRef v,
2666
+ ty. t t, int field) -> result {
2664
2667
auto td = get_tydesc( cx, t) ;
2665
2668
call_tydesc_glue_full( td. bcx,
2666
2669
spill_if_immediate( td. bcx, v, t) ,
2667
2670
td. val, field) ;
2671
+ ret res( td. bcx, C_nil ( ) ) ;
2668
2672
}
2669
2673
2670
2674
fn call_cmp_glue( @block_ctxt cx, ValueRef lhs, ValueRef rhs, ty. t t,
@@ -2705,7 +2709,7 @@ fn call_cmp_glue(@block_ctxt cx, ValueRef lhs, ValueRef rhs, ty.t t,
2705
2709
2706
2710
fn take_ty( @block_ctxt cx, ValueRef v, ty. t t) -> result {
2707
2711
if ( !ty. type_is_scalar( cx. fcx. lcx. ccx. tcx, t) ) {
2708
- call_tydesc_glue( cx, v, t, abi. tydesc_field_take_glue) ;
2712
+ ret call_tydesc_glue( cx, v, t, abi. tydesc_field_take_glue) ;
2709
2713
}
2710
2714
ret res( cx, C_nil ( ) ) ;
2711
2715
}
@@ -2727,7 +2731,7 @@ fn drop_ty(@block_ctxt cx,
2727
2731
ty. t t) -> result {
2728
2732
2729
2733
if ( !ty. type_is_scalar( cx. fcx. lcx. ccx. tcx, t) ) {
2730
- call_tydesc_glue( cx, v, t, abi. tydesc_field_drop_glue) ;
2734
+ ret call_tydesc_glue( cx, v, t, abi. tydesc_field_drop_glue) ;
2731
2735
}
2732
2736
ret res( cx, C_nil ( ) ) ;
2733
2737
}
@@ -3529,7 +3533,7 @@ fn trans_for_each(@block_ctxt cx,
3529
3533
auto lltydescsptr = cx. build. GEP ( llenvptr,
3530
3534
vec( C_int ( 0 ) ,
3531
3535
C_int ( abi. box_rc_field_body) ,
3532
- C_int ( 3 ) ) ) ;
3536
+ C_int ( abi . closure_elt_ty_params ) ) ) ;
3533
3537
auto i = 0 u;
3534
3538
while ( i < tydesc_count) {
3535
3539
auto lltydescptr = cx. build. GEP ( lltydescsptr,
@@ -3563,8 +3567,10 @@ fn trans_for_each(@block_ctxt cx,
3563
3567
3564
3568
// Populate the upvars from the environment.
3565
3569
auto llremoteenvptr = bcx. build. PointerCast ( fcx. llenv, llenvptrty) ;
3566
- auto llremotebindingsptrptr = bcx. build. GEP ( llremoteenvptr,
3567
- vec( C_int ( 0 ) , C_int ( abi. box_rc_field_body) , C_int ( 2 ) ) ) ;
3570
+ auto llremotebindingsptrptr =
3571
+ bcx. build. GEP ( llremoteenvptr, vec( C_int ( 0 ) ,
3572
+ C_int ( abi. box_rc_field_body) ,
3573
+ C_int ( abi. closure_elt_bindings) ) ) ;
3568
3574
auto llremotebindingsptr = bcx. build. Load ( llremotebindingsptrptr) ;
3569
3575
3570
3576
i = 0 u;
@@ -3579,10 +3585,11 @@ fn trans_for_each(@block_ctxt cx,
3579
3585
}
3580
3586
3581
3587
// Populate the type parameters from the environment.
3582
- auto llremotetydescsptr = bcx. build. GEP ( llremoteenvptr,
3583
- vec( C_int ( 0 ) ,
3584
- C_int ( abi. box_rc_field_body) ,
3585
- C_int ( 3 ) ) ) ;
3588
+ auto llremotetydescsptr =
3589
+ bcx. build. GEP ( llremoteenvptr,
3590
+ vec( C_int ( 0 ) ,
3591
+ C_int ( abi. box_rc_field_body) ,
3592
+ C_int ( abi. closure_elt_ty_params) ) ) ;
3586
3593
3587
3594
i = 0 u;
3588
3595
while ( i < tydesc_count) {
@@ -3903,7 +3910,7 @@ fn lval_generic_fn(@block_ctxt cx,
3903
3910
}
3904
3911
3905
3912
if ( _vec. len[ ty. t] ( tys) != 0 u) {
3906
- auto bcx = cx ;
3913
+ auto bcx = lv . res . bcx ;
3907
3914
let vec[ ValueRef ] tydescs = vec( ) ;
3908
3915
for ( ty. t t in tys) {
3909
3916
auto td = get_tydesc( bcx, t) ;
@@ -4497,7 +4504,7 @@ fn trans_bind(@block_ctxt cx, @ast.expr f,
4497
4504
for ( ValueRef v in bound_vals) {
4498
4505
auto bound = bcx. build. GEP ( bindings,
4499
4506
vec( C_int ( 0 ) , C_int ( i as int) ) ) ;
4500
- bcx = copy_ty( r . bcx, INIT , bound, v, bound_tys. ( i) ) . bcx;
4507
+ bcx = copy_ty( bcx, INIT , bound, v, bound_tys. ( i) ) . bcx;
4501
4508
i += 1 u;
4502
4509
}
4503
4510
@@ -5324,7 +5331,7 @@ fn trans_break_cont(@block_ctxt cx, bool to_end) -> result {
5324
5331
}
5325
5332
}
5326
5333
}
5327
- ret res( new_sub_block_ctxt ( cx , "unreachable" ) , C_nil ( ) ) ;
5334
+ ret res( bcx , C_nil ( ) ) ;
5328
5335
}
5329
5336
case ( _) {
5330
5337
alt ( cleanup_cx. parent) {
@@ -5333,7 +5340,7 @@ fn trans_break_cont(@block_ctxt cx, bool to_end) -> result {
5333
5340
}
5334
5341
}
5335
5342
}
5336
- ret res ( cx , C_nil ( ) ) ; // Never reached. Won't compile otherwise.
5343
+ fail ;
5337
5344
}
5338
5345
5339
5346
fn trans_break( @block_ctxt cx) -> result {
@@ -5357,7 +5364,11 @@ fn trans_ret(@block_ctxt cx, &option.t[@ast.expr] e) -> result {
5357
5364
val = r. val;
5358
5365
bcx = copy_ty( bcx, INIT , cx. fcx. llretptr, val, t) . bcx;
5359
5366
}
5360
- case ( _) { /* fall through */ }
5367
+ case ( _) {
5368
+ auto t = llvm. LLVMGetElementType ( val_ty( cx. fcx. llretptr) ) ;
5369
+ auto null = lib. llvm. llvm. LLVMConstNull ( t) ;
5370
+ bcx. build. Store ( null, cx. fcx. llretptr) ;
5371
+ }
5361
5372
}
5362
5373
5363
5374
// Run all cleanups and back out.
@@ -6052,7 +6063,7 @@ fn trans_fn(@local_ctxt cx, &ast._fn f, ast.def_id fid,
6052
6063
new_builder( fcx. llallocas) . Br ( lltop) ;
6053
6064
}
6054
6065
6055
- fn trans_vtbl( @local_ctxt cx,
6066
+ fn trans_vtbl( @local_ctxt cx,
6056
6067
TypeRef llself_ty,
6057
6068
ty. t self_ty,
6058
6069
& ast. _obj ob,
@@ -6085,7 +6096,7 @@ fn trans_vtbl(@local_ctxt cx,
6085
6096
cx. ccx. item_ids. insert( m. node. id, llfn) ;
6086
6097
cx. ccx. item_symbols. insert( m. node. id, s) ;
6087
6098
6088
- trans_fn( mcx, m. node. meth, m. node. id,
6099
+ trans_fn( mcx, m. node. meth, m. node. id,
6089
6100
some[ tup( TypeRef , ty. t) ] ( tup( llself_ty, self_ty) ) ,
6090
6101
ty_params, m. node. ann) ;
6091
6102
methods += vec( llfn) ;
@@ -6146,7 +6157,7 @@ fn trans_obj(@local_ctxt cx, &ast._obj ob, ast.def_id oid,
6146
6157
6147
6158
auto fcx = new_fn_ctxt( cx, llctor_decl) ;
6148
6159
create_llargs_for_fn_args( fcx, ast. proto_fn,
6149
- none[ tup( TypeRef , ty. t) ] ,
6160
+ none[ tup( TypeRef , ty. t) ] ,
6150
6161
ret_ty_of_fn( cx. ccx, ann) ,
6151
6162
fn_args, ty_params) ;
6152
6163
@@ -6289,7 +6300,7 @@ fn trans_tag_variant(@local_ctxt cx, ast.def_id tag_id,
6289
6300
auto fcx = new_fn_ctxt( cx, llfndecl) ;
6290
6301
6291
6302
create_llargs_for_fn_args( fcx, ast. proto_fn,
6292
- none[ tup( TypeRef , ty. t) ] ,
6303
+ none[ tup( TypeRef , ty. t) ] ,
6293
6304
ret_ty_of_fn( cx. ccx, variant. node. ann) ,
6294
6305
fn_args, ty_params) ;
6295
6306
@@ -6718,7 +6729,7 @@ fn collect_item_2(@crate_ctxt ccx, @walk_ctxt wcx, @ast.item i) {
6718
6729
fn collect_items ( @crate_ctxt ccx , @ast. crate crate) {
6719
6730
auto wcx = new_walk_ctxt ( ) ;
6720
6731
auto visitor0 = walk. default_visitor ( ) ;
6721
- auto visitor1 = rec ( visit_native_item_pre =
6732
+ auto visitor1 = rec ( visit_native_item_pre =
6722
6733
bind collect_native_item ( ccx, wcx, _) ,
6723
6734
visit_item_pre = bind collect_item_1 ( ccx, wcx, _) ,
6724
6735
visit_item_post = bind leave_item ( wcx, _)
@@ -6760,7 +6771,7 @@ fn collect_tag_ctors(@crate_ctxt ccx, @ast.crate crate) {
6760
6771
6761
6772
fn trans_constant ( @crate_ctxt ccx , @walk_ctxt wcx , @ast. item it ) {
6762
6773
enter_item ( wcx, it) ;
6763
-
6774
+
6764
6775
alt ( it. node ) {
6765
6776
case ( ast. item_tag ( ?ident, ?variants, _, ?tag_id, _) ) {
6766
6777
auto i = 0 u;
0 commit comments