@@ -2541,27 +2541,6 @@ fn get_dest_addr(dest: dest) -> ValueRef {
2541
2541
alt dest { save_in( a) { a } }
2542
2542
}
2543
2543
2544
- // Wrapper through which legacy non-DPS code can use DPS functions
2545
- fn dps_to_result ( bcx : @block_ctxt ,
2546
- work : block ( @block_ctxt , dest ) -> @block_ctxt ,
2547
- ty : ty:: t ) -> result {
2548
- let tcx = bcx_tcx ( bcx) ;
2549
- if ty:: type_is_nil ( tcx, ty) || ty:: type_is_bot ( tcx, ty) {
2550
- ret rslt ( work ( bcx, ignore) , C_nil ( ) ) ;
2551
- } else if type_is_immediate ( bcx_ccx ( bcx) , ty) {
2552
- let cell = empty_dest_cell ( ) ;
2553
- bcx = work ( bcx, by_val ( cell) ) ;
2554
- add_clean_temp ( bcx, * cell, ty) ;
2555
- ret rslt( bcx, * cell) ;
2556
- } else {
2557
- let { bcx, val: alloca } = alloc_ty ( bcx, ty) ;
2558
- bcx = zero_alloca ( bcx, alloca, ty) ;
2559
- bcx = work ( bcx, save_in ( alloca) ) ;
2560
- add_clean_temp ( bcx, alloca, ty) ;
2561
- ret rslt( bcx, alloca) ;
2562
- }
2563
- }
2564
-
2565
2544
fn trans_if ( cx : @block_ctxt , cond : @ast:: expr , thn : ast:: blk ,
2566
2545
els : option:: t < @ast:: expr > , dest : dest )
2567
2546
-> @block_ctxt {
@@ -3244,7 +3223,7 @@ fn trans_callee(bcx: @block_ctxt, e: @ast::expr) -> lval_maybe_callee {
3244
3223
alt e. node {
3245
3224
ast:: expr_path ( p) { ret trans_path ( bcx, p, e. id ) ; }
3246
3225
ast:: expr_field ( base, ident) {
3247
- // Lval means record field, so not a method
3226
+ // Lval means this is a record field, so not a method
3248
3227
if !expr_is_lval ( bcx_tcx ( bcx) , e) {
3249
3228
let of = trans_object_field ( bcx, base, ident) ;
3250
3229
ret { bcx : of. bcx , val : of. mthptr , is_mem : true ,
@@ -3262,7 +3241,7 @@ fn trans_callee(bcx: @block_ctxt, e: @ast::expr) -> lval_maybe_callee {
3262
3241
}
3263
3242
_ { }
3264
3243
}
3265
- let lv = trans_lval ( bcx, e) ;
3244
+ let lv = trans_temp_lval ( bcx, e) ;
3266
3245
ret lval_no_env ( lv. bcx , lv. val , lv. is_mem ) ;
3267
3246
}
3268
3247
@@ -3288,7 +3267,6 @@ fn expr_is_lval(tcx: ty::ctxt, e: @ast::expr) -> bool {
3288
3267
// The additional bool returned indicates whether it's mem (that is
3289
3268
// represented as an alloca or heap, hence needs a 'load' to be used as an
3290
3269
// immediate).
3291
- // FIXME[DPS] only allow this to be called on actual lvals
3292
3270
fn trans_lval ( cx : @block_ctxt , e : @ast:: expr ) -> lval_result {
3293
3271
alt e. node {
3294
3272
ast:: expr_path ( p) {
@@ -3327,25 +3305,13 @@ fn trans_lval(cx: @block_ctxt, e: @ast::expr) -> lval_result {
3327
3305
} ;
3328
3306
ret lval_mem( sub. bcx , val) ;
3329
3307
}
3308
+ // This is a by-ref returning call. Regular calls are not lval
3330
3309
ast:: expr_call ( f, args) {
3331
- // A by-ref returning function
3332
- if expr_is_lval ( bcx_tcx ( cx) , e) {
3333
- let cell = empty_dest_cell ( ) ;
3334
- let bcx = trans_call ( cx, f, none, args, e. id , by_val ( cell) ) ;
3335
- ret lval_mem( bcx, * cell) ;
3336
- } else { // By-value return
3337
- // FIXME[DPS] this will disappear when trans_lval only handles
3338
- // lvals
3339
- let { bcx, val} = dps_to_result ( cx, { |bcx, dest|
3340
- trans_call ( bcx, f, none, args, e. id , dest) } ,
3341
- ty:: expr_ty ( bcx_tcx ( cx) , e) ) ;
3342
- ret lval_val( bcx, val) ;
3343
- }
3344
- }
3345
- _ {
3346
- let res = trans_temp_expr ( cx, e) ;
3347
- ret lval_val( res. bcx , res. val ) ;
3310
+ let cell = empty_dest_cell ( ) ;
3311
+ let bcx = trans_call ( cx, f, none, args, e. id , by_val ( cell) ) ;
3312
+ ret lval_mem( bcx, * cell) ;
3348
3313
}
3314
+ _ { bcx_ccx( cx) . sess . span_bug ( e. span , "non-lval in trans_lval" ) ; }
3349
3315
}
3350
3316
}
3351
3317
@@ -3736,7 +3702,7 @@ fn trans_arg_expr(cx: @block_ctxt, arg: ty::arg, lldestty0: TypeRef,
3736
3702
let ccx = bcx_ccx ( cx) ;
3737
3703
let e_ty = ty:: expr_ty ( ccx. tcx , e) ;
3738
3704
let is_bot = ty:: type_is_bot ( ccx. tcx , e_ty) ;
3739
- let lv = trans_lval ( cx, e) ;
3705
+ let lv = trans_temp_lval ( cx, e) ;
3740
3706
let bcx = lv. bcx ;
3741
3707
let val = lv. val ;
3742
3708
if is_bot {
@@ -5331,27 +5297,18 @@ fn trans_closure(cx: @local_ctxt, sp: span, f: ast::_fn, llfndecl: ValueRef,
5331
5297
finish_fn ( fcx, lltop) ;
5332
5298
}
5333
5299
5334
- fn trans_fn_inner ( cx : @local_ctxt , sp : span , f : ast:: _fn , llfndecl : ValueRef ,
5335
- ty_self : option:: t < ty:: t > , ty_params : [ ast:: ty_param ] ,
5336
- id : ast:: node_id ) {
5337
- trans_closure ( cx, sp, f, llfndecl, ty_self, ty_params, id, { |_fcx|} ) ;
5338
- }
5339
-
5340
-
5341
5300
// trans_fn: creates an LLVM function corresponding to a source language
5342
5301
// function.
5343
5302
fn trans_fn ( cx : @local_ctxt , sp : span , f : ast:: _fn , llfndecl : ValueRef ,
5344
5303
ty_self : option:: t < ty:: t > , ty_params : [ ast:: ty_param ] ,
5345
5304
id : ast:: node_id ) {
5346
- if !cx. ccx . sess . get_opts ( ) . stats {
5347
- trans_fn_inner ( cx, sp, f, llfndecl, ty_self, ty_params, id) ;
5348
- ret;
5305
+ let do_time = cx. ccx . sess . get_opts ( ) . stats ;
5306
+ let start = do_time ? time:: get_time ( ) : { sec: 0u32 , usec: 0u32 } ;
5307
+ trans_closure ( cx, sp, f, llfndecl, ty_self, ty_params, id, { |_fcx|} ) ;
5308
+ if do_time {
5309
+ let end = time:: get_time ( ) ;
5310
+ log_fn_time ( cx. ccx , str:: connect ( cx. path , "::" ) , start, end) ;
5349
5311
}
5350
-
5351
- let start = time:: get_time ( ) ;
5352
- trans_fn_inner ( cx, sp, f, llfndecl, ty_self, ty_params, id) ;
5353
- let end = time:: get_time ( ) ;
5354
- log_fn_time ( cx. ccx , str:: connect ( cx. path , "::" ) , start, end) ;
5355
5312
}
5356
5313
5357
5314
fn trans_res_ctor ( cx: @local_ctxt, sp: span, dtor: ast:: _fn,
0 commit comments