@@ -267,10 +267,8 @@ fn bump_ptr(bcx: block, t: ty::t, base: ValueRef, sz: ValueRef) ->
267
267
ValueRef {
268
268
let ccx = bcx. ccx ( ) ;
269
269
let bumped = ptr_offs ( bcx, base, sz) ;
270
- if check type_has_static_size ( ccx, t) {
271
- let typ = T_ptr ( type_of ( ccx, t) ) ;
272
- PointerCast ( bcx, bumped, typ)
273
- } else { bumped }
270
+ let typ = T_ptr ( type_of ( ccx, t) ) ;
271
+ PointerCast ( bcx, bumped, typ)
274
272
}
275
273
276
274
// Replacement for the LLVM 'GEP' instruction when field indexing into a enum.
@@ -310,11 +308,7 @@ fn opaque_box_body(bcx: block,
310
308
let ccx = bcx. ccx ( ) ;
311
309
let boxptr = PointerCast ( bcx, boxptr, T_ptr ( T_box_header ( ccx) ) ) ;
312
310
let bodyptr = GEPi ( bcx, boxptr, [ 1 ] ) ;
313
- if check type_has_static_size ( ccx, body_t) {
314
- PointerCast ( bcx, bodyptr, T_ptr ( type_of ( ccx, body_t) ) )
315
- } else {
316
- PointerCast ( bcx, bodyptr, T_ptr ( T_i8 ( ) ) )
317
- }
311
+ PointerCast ( bcx, bodyptr, T_ptr ( type_of ( ccx, body_t) ) )
318
312
}
319
313
320
314
// trans_malloc_boxed_raw: expects an unboxed type and returns a pointer to
@@ -350,41 +344,13 @@ fn trans_malloc_boxed(bcx: block, t: ty::t) ->
350
344
351
345
// Type descriptor and type glue stuff
352
346
353
- fn trans_stack_local_derived_tydesc ( cx : block , llsz : ValueRef ,
354
- llalign : ValueRef , llroottydesc : ValueRef ,
355
- llfirstparam : ValueRef , n_params : uint )
356
- -> ValueRef {
357
- let llmyroottydesc = alloca ( cx, cx. ccx ( ) . tydesc_type ) ;
358
-
359
- // By convention, desc 0 is the root descriptor.
360
- let llroottydesc = Load ( cx, llroottydesc) ;
361
- Store ( cx, llroottydesc, llmyroottydesc) ;
362
-
363
- // Store a pointer to the rest of the descriptors.
364
- let ccx = cx. ccx ( ) ;
365
- store_inbounds ( cx, llfirstparam, llmyroottydesc,
366
- [ 0 , abi:: tydesc_field_first_param] ) ;
367
- store_inbounds ( cx, C_uint ( ccx, n_params) , llmyroottydesc,
368
- [ 0 , abi:: tydesc_field_n_params] ) ;
369
- store_inbounds ( cx, llsz, llmyroottydesc,
370
- [ 0 , abi:: tydesc_field_size] ) ;
371
- store_inbounds ( cx, llalign, llmyroottydesc,
372
- [ 0 , abi:: tydesc_field_align] ) ;
373
- // FIXME legacy field, can be dropped
374
- store_inbounds ( cx, C_uint ( ccx, 0 u) , llmyroottydesc,
375
- [ 0 , abi:: tydesc_field_obj_params] ) ;
376
- ret llmyroottydesc;
377
- }
378
-
379
347
fn get_tydesc_simple ( bcx : block , t : ty:: t ) -> result {
380
348
let ti = none;
381
349
get_tydesc ( bcx, t, ti)
382
350
}
383
351
384
352
fn get_tydesc ( cx : block , t : ty:: t ,
385
353
& static_ti: option < @tydesc_info > ) -> result {
386
-
387
- // FIXME[mono]
388
354
assert !ty:: type_has_params ( t) ;
389
355
// Otherwise, generate a tydesc if necessary, and return it.
390
356
let info = get_static_tydesc ( cx. ccx ( ) , t) ;
@@ -452,17 +418,9 @@ fn declare_tydesc(ccx: @crate_ctxt, t: ty::t) -> @tydesc_info {
452
418
log ( debug, "+++ declare_tydesc " + ty_to_str ( ccx. tcx , t) ) ;
453
419
let llsize;
454
420
let llalign;
455
- if check type_has_static_size ( ccx, t) {
456
- let llty = type_of ( ccx, t) ;
457
- llsize = llsize_of ( ccx, llty) ;
458
- llalign = llalign_of ( ccx, llty) ;
459
- } else {
460
- // These will be overwritten as the derived tydesc is generated, so
461
- // we create placeholder values.
462
-
463
- llsize = C_int ( ccx, 0 ) ;
464
- llalign = C_int ( ccx, 0 ) ;
465
- }
421
+ let llty = type_of ( ccx, t) ;
422
+ llsize = llsize_of ( ccx, llty) ;
423
+ llalign = llalign_of ( ccx, llty) ;
466
424
let name;
467
425
if ccx. sess . opts . debuginfo {
468
426
name = mangle_internal_name_by_type_only ( ccx, t, "tydesc" ) ;
@@ -508,9 +466,7 @@ fn make_generic_glue_inner(ccx: @crate_ctxt, t: ty::t,
508
466
// the caller has no idea if it's dealing with something that can be
509
467
// passed by value.
510
468
511
- let llty = if check type_has_static_size ( ccx, t) {
512
- T_ptr ( type_of ( ccx, t) )
513
- } else { T_ptr ( T_i8 ( ) ) } ;
469
+ let llty = T_ptr ( type_of ( ccx, t) ) ;
514
470
515
471
let bcx = top_scope_block ( fcx, none) ;
516
472
let lltop = bcx. llbb ;
@@ -1200,17 +1156,12 @@ fn call_memmove(cx: block, dst: ValueRef, src: ValueRef,
1200
1156
fn memmove_ty ( bcx : block , dst : ValueRef , src : ValueRef , t : ty:: t ) ->
1201
1157
block {
1202
1158
let ccx = bcx. ccx ( ) ;
1203
- if check type_has_static_size ( ccx, t) {
1204
- if ty:: type_is_structural ( t) {
1205
- let llsz = llsize_of ( ccx, type_of ( ccx, t) ) ;
1206
- ret call_memmove ( bcx, dst, src, llsz) . bcx ;
1207
- }
1208
- Store ( bcx, Load ( bcx, src) , dst) ;
1209
- ret bcx;
1159
+ if ty:: type_is_structural ( t) {
1160
+ let llsz = llsize_of ( ccx, type_of ( ccx, t) ) ;
1161
+ ret call_memmove ( bcx, dst, src, llsz) . bcx ;
1210
1162
}
1211
-
1212
- let { bcx, val: llsz } = size_of ( bcx, t) ;
1213
- ret call_memmove ( bcx, dst, src, llsz) . bcx ;
1163
+ Store ( bcx, Load ( bcx, src) , dst) ;
1164
+ ret bcx;
1214
1165
}
1215
1166
1216
1167
enum copy_action { INIT , DROP_EXISTING , }
@@ -1372,10 +1323,8 @@ fn trans_unary(bcx: block, op: ast::unop, e: @ast::expr,
1372
1323
// make enums work, since enums have a different LLVM type depending
1373
1324
// on whether they're boxed or not
1374
1325
let ccx = bcx. ccx ( ) ;
1375
- if check type_has_static_size ( ccx, e_ty) {
1376
- let llety = T_ptr ( type_of ( ccx, e_ty) ) ;
1377
- body = PointerCast ( bcx, body, llety) ;
1378
- }
1326
+ let llety = T_ptr ( type_of ( ccx, e_ty) ) ;
1327
+ body = PointerCast ( bcx, body, llety) ;
1379
1328
bcx = trans_expr_save_in ( bcx, e, body) ;
1380
1329
revoke_clean ( bcx, box) ;
1381
1330
ret store_in_dest ( bcx, box, dest) ;
@@ -1583,10 +1532,8 @@ fn autoderef(cx: block, v: ValueRef, t: ty::t) -> result_t {
1583
1532
// to cast this pointer, since statically-sized enum types have
1584
1533
// different types depending on whether they're behind a box
1585
1534
// or not.
1586
- if check type_has_static_size ( ccx, t1) {
1587
- let llty = type_of ( ccx, t1) ;
1588
- v1 = PointerCast ( cx, body, T_ptr ( llty) ) ;
1589
- } else { v1 = body; }
1535
+ let llty = type_of ( ccx, t1) ;
1536
+ v1 = PointerCast ( cx, body, T_ptr ( llty) ) ;
1590
1537
}
1591
1538
ty:: ty_uniq ( _) {
1592
1539
let derefed = uniq:: autoderef ( v1, t1) ;
@@ -1608,9 +1555,7 @@ fn autoderef(cx: block, v: ValueRef, t: ty::t) -> result_t {
1608
1555
}
1609
1556
t1 =
1610
1557
ty:: substitute_type_params ( ccx. tcx , tps, variants[ 0 ] . args [ 0 ] ) ;
1611
- if check type_has_static_size ( ccx, t1) {
1612
- v1 = PointerCast ( cx, v1, T_ptr ( type_of ( ccx, t1) ) ) ;
1613
- } else { } // FIXME: typestate hack
1558
+ v1 = PointerCast ( cx, v1, T_ptr ( type_of ( ccx, t1) ) ) ;
1614
1559
}
1615
1560
_ { break; }
1616
1561
}
@@ -1724,7 +1669,7 @@ fn trans_for(cx: block, local: @ast::local, seq: @ast::expr,
1724
1669
body. span ) ;
1725
1670
Br ( bcx, scope_cx. llbb ) ;
1726
1671
let curr = PointerCast ( bcx, curr,
1727
- T_ptr ( type_of_or_i8 ( bcx. ccx ( ) , t) ) ) ;
1672
+ T_ptr ( type_of ( bcx. ccx ( ) , t) ) ) ;
1728
1673
let bcx = alt:: bind_irrefutable_pat ( scope_cx, local. node . pat ,
1729
1674
curr, false ) ;
1730
1675
bcx = trans_block ( bcx, body, ignore) ;
@@ -2122,7 +2067,7 @@ fn trans_local_var(cx: block, def: ast::def) -> local_var_result {
2122
2067
ast:: def_self ( _) {
2123
2068
let slf = option:: get ( cx. fcx . llself ) ;
2124
2069
let ptr = PointerCast ( cx, slf. v ,
2125
- T_ptr ( type_of_or_i8 ( cx. ccx ( ) , slf. t ) ) ) ;
2070
+ T_ptr ( type_of ( cx. ccx ( ) , slf. t ) ) ) ;
2126
2071
ret { val : ptr, kind : owned} ;
2127
2072
}
2128
2073
_ {
@@ -2236,27 +2181,20 @@ fn trans_index(cx: block, ex: @ast::expr, base: @ast::expr,
2236
2181
} else { ix_val = ix. val ; }
2237
2182
2238
2183
let unit_ty = node_id_type ( cx, ex. id ) ;
2239
- let unit_sz = size_of ( bcx , unit_ty) ;
2240
- bcx = unit_sz . bcx ;
2241
- maybe_name_value ( cx. ccx ( ) , unit_sz. val , "unit_sz" ) ;
2242
- let scaled_ix = Mul ( bcx, ix_val, unit_sz. val ) ;
2184
+ let llunitty = type_of ( ccx , unit_ty) ;
2185
+ let unit_sz = llsize_of ( ccx , llunitty ) ;
2186
+ maybe_name_value ( cx. ccx ( ) , unit_sz, "unit_sz" ) ;
2187
+ let scaled_ix = Mul ( bcx, ix_val, unit_sz) ;
2243
2188
maybe_name_value ( cx. ccx ( ) , scaled_ix, "scaled_ix" ) ;
2244
2189
let lim = tvec:: get_fill ( bcx, v) ;
2245
- let body = tvec:: get_dataptr ( bcx, v, type_of_or_i8 ( ccx, unit_ty) ) ;
2190
+ let body = tvec:: get_dataptr ( bcx, v, type_of ( ccx, unit_ty) ) ;
2246
2191
let bounds_check = ICmp ( bcx, lib:: llvm:: IntUGE , scaled_ix, lim) ;
2247
2192
bcx = with_cond ( bcx, bounds_check) { |bcx|
2248
2193
// fail: bad bounds check.
2249
2194
trans_fail ( bcx, some ( ex. span ) , "bounds check" )
2250
2195
} ;
2251
- let elt = if check type_has_static_size ( ccx, unit_ty) {
2252
- let elt_1 = InBoundsGEP ( bcx, body, [ ix_val] ) ;
2253
- let llunitty = type_of ( ccx, unit_ty) ;
2254
- PointerCast ( bcx, elt_1, T_ptr ( llunitty) )
2255
- } else {
2256
- body = PointerCast ( bcx, body, T_ptr ( T_i8 ( ) ) ) ;
2257
- InBoundsGEP ( bcx, body, [ scaled_ix] )
2258
- } ;
2259
- ret lval_owned( bcx, elt) ;
2196
+ let elt = InBoundsGEP ( bcx, body, [ ix_val] ) ;
2197
+ ret lval_owned( bcx, PointerCast ( bcx, elt, T_ptr ( llunitty) ) ) ;
2260
2198
}
2261
2199
2262
2200
fn expr_is_lval ( bcx : block , e : @ast:: expr ) -> bool {
@@ -2315,9 +2253,7 @@ fn trans_lval(cx: block, e: @ast::expr) -> lval_result {
2315
2253
}
2316
2254
ty:: ty_enum ( _, _) {
2317
2255
let ety = expr_ty ( cx, e) ;
2318
- let ellty = if check type_has_static_size ( ccx, ety) {
2319
- T_ptr ( type_of ( ccx, ety) )
2320
- } else { T_typaram_ptr ( ccx. tn ) } ;
2256
+ let ellty = T_ptr ( type_of ( ccx, ety) ) ;
2321
2257
PointerCast ( sub. bcx , sub. val , ellty)
2322
2258
}
2323
2259
ty:: ty_ptr ( _) | ty:: ty_uniq ( _) | ty:: ty_rptr ( _, _) { sub. val }
@@ -3194,7 +3130,7 @@ fn trans_fail_expr(bcx: block, sp_opt: option<span>,
3194
3130
3195
3131
if ty:: type_is_str ( e_ty) {
3196
3132
let data = tvec:: get_dataptr (
3197
- bcx, expr_res. val , type_of_or_i8 (
3133
+ bcx, expr_res. val , type_of (
3198
3134
ccx, ty:: mk_mach_uint ( tcx, ast:: ty_u8) ) ) ;
3199
3135
ret trans_fail_value ( bcx, sp_opt, data) ;
3200
3136
} else if bcx. unreachable || ty:: type_is_bot ( e_ty) {
@@ -3345,23 +3281,8 @@ fn zero_alloca(cx: block, llptr: ValueRef, t: ty::t)
3345
3281
-> block {
3346
3282
let bcx = cx;
3347
3283
let ccx = cx. ccx ( ) ;
3348
- if check type_has_static_size ( ccx, t) {
3349
- let llty = type_of ( ccx, t) ;
3350
- Store ( bcx, C_null ( llty) , llptr) ;
3351
- } else {
3352
- let key = alt ccx. sess . targ_cfg . arch {
3353
- session:: arch_x86 | session:: arch_arm { "llvm.memset.p0i8.i32" }
3354
- session:: arch_x86_64 { "llvm.memset.p0i8.i64" }
3355
- } ;
3356
- let i = ccx. intrinsics ;
3357
- let memset = i. get ( key) ;
3358
- let dst_ptr = PointerCast ( cx, llptr, T_ptr ( T_i8 ( ) ) ) ;
3359
- let size = size_of ( cx, t) ;
3360
- bcx = size. bcx ;
3361
- let align = C_i32 ( 1i32 ) ; // cannot use computed value here.
3362
- let volatile = C_bool ( false ) ;
3363
- Call ( cx, memset, [ dst_ptr, C_u8 ( 0 u) , size. val , align, volatile] ) ;
3364
- }
3284
+ let llty = type_of ( ccx, t) ;
3285
+ Store ( bcx, C_null ( llty) , llptr) ;
3365
3286
ret bcx;
3366
3287
}
3367
3288
@@ -3580,7 +3501,7 @@ fn block_locals(b: ast::blk, it: fn(@ast::local)) {
3580
3501
fn alloc_ty ( cx : block , t : ty:: t ) -> result {
3581
3502
let bcx = cx, ccx = cx. ccx ( ) ;
3582
3503
let llty = type_of ( ccx, t) ;
3583
- assert type_has_static_size ( ccx , t) ;
3504
+ assert !ty :: type_has_params ( t) ;
3584
3505
let val = alloca ( bcx, llty) ;
3585
3506
3586
3507
// NB: since we've pushed all size calculations in this
@@ -3641,24 +3562,15 @@ fn trans_block(bcx: block, b: ast::blk, dest: dest)
3641
3562
ret bcx;
3642
3563
}
3643
3564
3644
- // Creates the standard quartet of basic blocks: static allocas, copy args,
3645
- // derived tydescs, and dynamic allocas.
3565
+ // Creates the standard set of basic blocks for a function
3646
3566
fn mk_standard_basic_blocks ( llfn : ValueRef ) ->
3647
- { sa : BasicBlockRef ,
3648
- ca : BasicBlockRef ,
3649
- dt : BasicBlockRef ,
3650
- da : BasicBlockRef ,
3651
- rt : BasicBlockRef } {
3652
- ret { sa : str:: as_c_str ( "static_allocas" , { |buf|
3653
- llvm:: LLVMAppendBasicBlock ( llfn, buf) } ) ,
3654
- ca : str:: as_c_str ( "load_env" , { |buf|
3655
- llvm:: LLVMAppendBasicBlock ( llfn, buf) } ) ,
3656
- dt : str:: as_c_str ( "derived_tydescs" , { |buf|
3657
- llvm:: LLVMAppendBasicBlock ( llfn, buf) } ) ,
3658
- da : str:: as_c_str ( "dynamic_allocas" , { |buf|
3659
- llvm:: LLVMAppendBasicBlock ( llfn, buf) } ) ,
3660
- rt : str:: as_c_str ( "return" , { |buf|
3661
- llvm:: LLVMAppendBasicBlock ( llfn, buf) } ) } ;
3567
+ { sa : BasicBlockRef , ca : BasicBlockRef , rt : BasicBlockRef } {
3568
+ { sa: str:: as_c_str ( "static_allocas" , { |buf|
3569
+ llvm:: LLVMAppendBasicBlock ( llfn, buf) } ) ,
3570
+ ca: str:: as_c_str ( "load_env" , { |buf|
3571
+ llvm:: LLVMAppendBasicBlock ( llfn, buf) } ) ,
3572
+ rt: str:: as_c_str ( "return" , { |buf|
3573
+ llvm:: LLVMAppendBasicBlock ( llfn, buf) } ) }
3662
3574
}
3663
3575
3664
3576
@@ -3679,16 +3591,12 @@ fn new_fn_ctxt_w_id(ccx: @crate_ctxt, path: path,
3679
3591
llretptr : llvm:: LLVMGetParam ( llfndecl, 0 u as c_uint ) ,
3680
3592
mutable llstaticallocas : llbbs. sa ,
3681
3593
mutable llloadenv : llbbs. ca ,
3682
- mutable llderivedtydescs_first : llbbs. dt ,
3683
- mutable llderivedtydescs : llbbs. dt ,
3684
- mutable lldynamicallocas : llbbs. da ,
3685
3594
mutable llreturn : llbbs. rt ,
3686
3595
mutable llself: none,
3687
3596
mutable personality : none,
3688
3597
llargs : int_hash :: < local_val > ( ) ,
3689
3598
lllocals : int_hash :: < local_val > ( ) ,
3690
3599
llupvars : int_hash :: < ValueRef > ( ) ,
3691
- derived_tydescs : ty:: new_ty_hash ( ) ,
3692
3600
id : id,
3693
3601
self_id : maybe_self_id,
3694
3602
param_substs : param_substs,
@@ -3776,8 +3684,8 @@ fn copy_args_to_allocas(fcx: fn_ctxt, bcx: block, args: [ast::arg],
3776
3684
ret bcx;
3777
3685
}
3778
3686
3779
- // Ties up the llstaticallocas -> llloadenv -> llderivedtydescs ->
3780
- // lldynamicallocas -> lltop edges, and builds the return block.
3687
+ // Ties up the llstaticallocas -> llloadenv -> lltop edges,
3688
+ // and builds the return block.
3781
3689
fn finish_fn ( fcx : fn_ctxt , lltop : BasicBlockRef ) {
3782
3690
tie_up_header_blocks ( fcx, lltop) ;
3783
3691
let ret_cx = raw_block ( fcx, fcx. llreturn ) ;
@@ -3786,9 +3694,7 @@ fn finish_fn(fcx: fn_ctxt, lltop: BasicBlockRef) {
3786
3694
3787
3695
fn tie_up_header_blocks ( fcx : fn_ctxt , lltop : BasicBlockRef ) {
3788
3696
Br ( raw_block ( fcx, fcx. llstaticallocas ) , fcx. llloadenv ) ;
3789
- Br ( raw_block ( fcx, fcx. llloadenv ) , fcx. llderivedtydescs_first ) ;
3790
- Br ( raw_block ( fcx, fcx. llderivedtydescs ) , fcx. lldynamicallocas ) ;
3791
- Br ( raw_block ( fcx, fcx. lldynamicallocas ) , lltop) ;
3697
+ Br ( raw_block ( fcx, fcx. llloadenv ) , lltop) ;
3792
3698
}
3793
3699
3794
3700
enum self_arg { impl_self( ty:: t ) , no_self, }
@@ -3884,10 +3790,6 @@ fn trans_res_ctor(ccx: @crate_ctxt, path: path, dtor: ast::fn_decl,
3884
3790
in trans_res_ctor") ; }
3885
3791
} ;
3886
3792
let llretptr = fcx. llretptr ;
3887
- if ty:: type_has_dynamic_size ( ccx. tcx , ty:: ty_fn_ret ( fty) ) {
3888
- let llret_t = T_ptr ( T_struct ( [ ccx. int_type , llvm:: LLVMTypeOf ( arg) ] ) ) ;
3889
- llretptr = BitCast ( bcx, llretptr, llret_t) ;
3890
- }
3891
3793
3892
3794
let dst = GEPi ( bcx, llretptr, [ 0 , 1 ] ) ;
3893
3795
bcx = memmove_ty ( bcx, dst, arg, arg_t) ;
@@ -3946,9 +3848,6 @@ fn trans_enum_variant(ccx: @crate_ctxt, enum_id: ast::node_id,
3946
3848
some ( local_mem ( x) ) { x }
3947
3849
} ;
3948
3850
let arg_ty = arg_tys[ i] . ty ;
3949
- if ty:: type_has_params ( arg_ty) {
3950
- lldestptr = PointerCast ( bcx, lldestptr, val_ty ( llarg) ) ;
3951
- }
3952
3851
bcx = memmove_ty ( bcx, lldestptr, llarg, arg_ty) ;
3953
3852
i += 1 u;
3954
3853
}
@@ -4718,7 +4617,6 @@ fn trans_crate(sess: session::session, crate: @ast::crate, tcx: ty::ctxt,
4718
4617
maps: maps,
4719
4618
stats :
4720
4619
{ mutable n_static_tydescs : 0 u,
4721
- mutable n_derived_tydescs : 0 u,
4722
4620
mutable n_glues_created : 0 u,
4723
4621
mutable n_null_glues : 0 u,
4724
4622
mutable n_real_glues : 0 u,
@@ -4748,7 +4646,6 @@ fn trans_crate(sess: session::session, crate: @ast::crate, tcx: ty::ctxt,
4748
4646
if ccx. sess . opts . stats {
4749
4647
#error ( "--- trans stats ---" ) ;
4750
4648
#error ( "n_static_tydescs: %u" , ccx. stats . n_static_tydescs ) ;
4751
- #error ( "n_derived_tydescs: %u" , ccx. stats . n_derived_tydescs ) ;
4752
4649
#error ( "n_glues_created: %u" , ccx. stats . n_glues_created ) ;
4753
4650
#error ( "n_null_glues: %u" , ccx. stats . n_null_glues ) ;
4754
4651
#error ( "n_real_glues: %u" , ccx. stats . n_real_glues ) ;
0 commit comments