@@ -218,14 +218,6 @@ pub fn simplified_glue_type(tcx: ty::ctxt, field: uint, t: ty::t) -> ty::t {
218
218
return t;
219
219
}
220
220
221
- pub fn cast_glue ( ccx : @CrateContext , ti : @mut tydesc_info , v : ValueRef )
222
- -> ValueRef {
223
- unsafe {
224
- let llfnty = type_of_glue_fn ( ccx, ti. ty ) ;
225
- llvm:: LLVMConstPointerCast ( v, T_ptr ( llfnty) )
226
- }
227
- }
228
-
229
221
pub fn lazily_emit_simplified_tydesc_glue ( ccx : @CrateContext ,
230
222
field : uint ,
231
223
ti : @mut tydesc_info ) -> bool {
@@ -235,19 +227,14 @@ pub fn lazily_emit_simplified_tydesc_glue(ccx: @CrateContext,
235
227
let simpl_ti = get_tydesc ( ccx, simpl) ;
236
228
lazily_emit_tydesc_glue ( ccx, field, simpl_ti) ;
237
229
{
238
- let simpl_ti = & mut * simpl_ti;
239
230
if field == abi:: tydesc_field_take_glue {
240
- ti. take_glue =
241
- simpl_ti. take_glue . map ( |v| cast_glue ( ccx, ti, * v) ) ;
231
+ ti. take_glue = simpl_ti. take_glue ;
242
232
} else if field == abi:: tydesc_field_drop_glue {
243
- ti. drop_glue =
244
- simpl_ti. drop_glue . map ( |v| cast_glue ( ccx, ti, * v) ) ;
233
+ ti. drop_glue = simpl_ti. drop_glue ;
245
234
} else if field == abi:: tydesc_field_free_glue {
246
- ti. free_glue =
247
- simpl_ti. free_glue . map ( |v| cast_glue ( ccx, ti, * v) ) ;
235
+ ti. free_glue = simpl_ti. free_glue ;
248
236
} else if field == abi:: tydesc_field_visit_glue {
249
- ti. visit_glue =
250
- simpl_ti. visit_glue . map ( |v| cast_glue ( ccx, ti, * v) ) ;
237
+ ti. visit_glue = simpl_ti. visit_glue ;
251
238
}
252
239
}
253
240
return true ;
@@ -260,7 +247,7 @@ pub fn lazily_emit_tydesc_glue(ccx: @CrateContext,
260
247
field : uint ,
261
248
ti : @mut tydesc_info ) {
262
249
let _icx = ccx. insn_ctxt ( "lazily_emit_tydesc_glue" ) ;
263
- let llfnty = type_of_glue_fn ( ccx, ti . ty ) ;
250
+ let llfnty = type_of_glue_fn ( ccx) ;
264
251
265
252
if lazily_emit_simplified_tydesc_glue ( ccx, field, ti) {
266
253
return ;
@@ -353,25 +340,7 @@ pub fn call_tydesc_glue_full(bcx: block,
353
340
}
354
341
} ;
355
342
356
- // When available, use static type info to give glue the right type.
357
- let static_glue_fn = match static_ti {
358
- None => None ,
359
- Some ( sti) => {
360
- match static_glue_fn {
361
- None => None ,
362
- Some ( sgf) => Some (
363
- PointerCast ( bcx, sgf, T_ptr ( type_of_glue_fn ( ccx, sti. ty ) ) ) )
364
- }
365
- }
366
- } ;
367
-
368
- // When static type info is available, avoid casting parameter because the
369
- // function already has the right type. Otherwise cast to generic pointer.
370
- let llrawptr = if static_ti. is_none ( ) || static_glue_fn. is_none ( ) {
371
- PointerCast ( bcx, v, T_ptr ( T_i8 ( ) ) )
372
- } else {
373
- v
374
- } ;
343
+ let llrawptr = PointerCast ( bcx, v, T_ptr ( T_i8 ( ) ) ) ;
375
344
376
345
let llfn = {
377
346
match static_glue_fn {
@@ -736,14 +705,13 @@ pub fn make_generic_glue_inner(ccx: @CrateContext,
736
705
// requirement since in many contexts glue is invoked indirectly and
737
706
// the caller has no idea if it's dealing with something that can be
738
707
// passed by value.
739
- //
740
- // llfn is expected be declared to take a parameter of the appropriate
741
- // type, so we don't need to explicitly cast the function parameter.
742
708
743
709
let bcx = top_scope_block ( fcx, None ) ;
744
710
let lltop = bcx. llbb ;
745
711
let rawptr0_arg = fcx. arg_pos ( 1 u) ;
746
712
let llrawptr0 = unsafe { llvm:: LLVMGetParam ( llfn, rawptr0_arg as c_uint ) } ;
713
+ let llty = type_of ( ccx, t) ;
714
+ let llrawptr0 = PointerCast ( bcx, llrawptr0, T_ptr ( llty) ) ;
747
715
helper ( bcx, llrawptr0, t) ;
748
716
finish_fn ( fcx, lltop) ;
749
717
return llfn;
0 commit comments