@@ -4206,19 +4206,13 @@ fn trans_eager_binop(&@block_ctxt cx, ast::binop op, &ty::t intype,
4206
4206
}
4207
4207
}
4208
4208
4209
- fn autoderef_lval( & @block_ctxt cx, ValueRef v, & ty:: t t, bool is_lval)
4210
- -> result_t {
4209
+ fn autoderef( & @block_ctxt cx, ValueRef v, & ty:: t t) -> result_t {
4211
4210
let ValueRef v1 = v;
4212
4211
let ty:: t t1 = t;
4213
4212
auto ccx = cx. fcx. lcx. ccx;
4214
4213
while ( true) {
4215
4214
alt ( ty:: struct ( ccx. tcx, t1) ) {
4216
4215
case ( ty:: ty_box( ?mt) ) {
4217
- // If we are working with an lval, we want to
4218
- // unconditionally load at the top of the loop
4219
- // to get rid of the extra indirection
4220
- if ( is_lval) { v1 = cx. build. Load ( v1) ; }
4221
-
4222
4216
auto body =
4223
4217
cx. build. GEP ( v1,
4224
4218
~[ C_int ( 0 ) , C_int ( abi:: box_rc_field_body) ] ) ;
@@ -4233,7 +4227,6 @@ fn autoderef_lval(&@block_ctxt cx, ValueRef v, &ty::t t, bool is_lval)
4233
4227
} else { v1 = body; }
4234
4228
}
4235
4229
case ( ty:: ty_res( ?did, ?inner, ?tps) ) {
4236
- if ( is_lval) { v1 = cx. build. Load ( v1) ; }
4237
4230
t1 = ty:: substitute_type_params( ccx. tcx, tps, inner) ;
4238
4231
v1 = cx. build. GEP ( v1, ~[ C_int ( 0 ) , C_int ( 1 ) ] ) ;
4239
4232
}
@@ -4243,7 +4236,6 @@ fn autoderef_lval(&@block_ctxt cx, ValueRef v, &ty::t t, bool is_lval)
4243
4236
std:: ivec:: len( variants. ( 0 ) . args) != 1 u) {
4244
4237
break ;
4245
4238
}
4246
- if ( is_lval) { v1 = cx. build. Load ( v1) ; }
4247
4239
t1 = ty:: substitute_type_params
4248
4240
( ccx. tcx, tps, variants. ( 0 ) . args. ( 0 ) ) ;
4249
4241
if ( !ty:: type_has_dynamic_size( ccx. tcx, t1) ) {
@@ -4253,18 +4245,11 @@ fn autoderef_lval(&@block_ctxt cx, ValueRef v, &ty::t t, bool is_lval)
4253
4245
}
4254
4246
case ( _) { break ; }
4255
4247
}
4256
- // But if we aren't working with an lval, we get rid of
4257
- // a layer of indirection at the bottom of the loop so
4258
- // that it is gone when we return...
4259
- if ( !is_lval) { v1 = load_if_immediate( cx, v1, t1) ; }
4248
+ v1 = load_if_immediate( cx, v1, t1) ;
4260
4249
}
4261
4250
ret rec( bcx=cx, val=v1, ty=t1) ;
4262
4251
}
4263
4252
4264
- fn autoderef( & @block_ctxt cx, ValueRef v, & ty:: t t) -> result_t {
4265
- ret autoderef_lval( cx, v, t, false) ;
4266
- }
4267
-
4268
4253
fn trans_binary( & @block_ctxt cx, ast:: binop op, & @ast:: expr a, & @ast:: expr b)
4269
4254
-> result {
4270
4255
@@ -5956,7 +5941,8 @@ fn trans_call(&@block_ctxt cx, &@ast::expr f, &option::t[ValueRef] lliterbody,
5956
5941
}
5957
5942
case ( none) {
5958
5943
// It's a closure. We have to autoderef.
5959
- auto res = autoderef_lval( bcx, f_res. res. val, fn_ty, true) ;
5944
+ if ( f_res. is_mem) { faddr = load_if_immediate( bcx, faddr, fn_ty) ; }
5945
+ auto res = autoderef( bcx, faddr, fn_ty) ;
5960
5946
bcx = res. bcx;
5961
5947
fn_ty = res. ty;
5962
5948
0 commit comments