@@ -16,7 +16,7 @@ use adt;
16
16
use base;
17
17
use build;
18
18
use callee:: { Callee , CalleeData , Fn , Intrinsic , NamedTupleConstructor , Virtual } ;
19
- use common:: { self , Block , BlockAndBuilder , C_undef } ;
19
+ use common:: { self , type_is_fat_ptr , Block , BlockAndBuilder , C_undef } ;
20
20
use debuginfo:: DebugLoc ;
21
21
use Disr ;
22
22
use machine:: { llalign_of_min, llbitsize_of_real} ;
@@ -169,6 +169,8 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
169
169
_ => bug ! ( "{} is not callable" , callee. ty)
170
170
} ;
171
171
172
+ let sig = bcx. tcx ( ) . erase_late_bound_regions ( sig) ;
173
+
172
174
// Handle intrinsics old trans wants Expr's for, ourselves.
173
175
let intrinsic = match ( & callee. ty . sty , & callee. data ) {
174
176
( & ty:: TyFnDef ( def_id, _, _) , & Intrinsic ) => {
@@ -200,7 +202,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
200
202
return ;
201
203
}
202
204
203
- let extra_args = & args[ sig. 0 . inputs . len ( ) ..] ;
205
+ let extra_args = & args[ sig. inputs . len ( ) ..] ;
204
206
let extra_args = extra_args. iter ( ) . map ( |op_arg| {
205
207
self . mir . operand_ty ( bcx. tcx ( ) , op_arg)
206
208
} ) . collect :: < Vec < _ > > ( ) ;
@@ -263,30 +265,30 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
263
265
} ;
264
266
265
267
bcx. with_block ( |bcx| {
266
- let res = trans_intrinsic_call ( bcx, callee. ty , & fn_ty,
268
+ trans_intrinsic_call ( bcx, callee. ty , & fn_ty,
267
269
ArgVals ( llargs) , dest,
268
270
DebugLoc :: None ) ;
269
- let bcx = res. bcx . build ( ) ;
270
- if let Some ( ( _, target) ) = * destination {
271
- for op in args {
272
- self . set_operand_dropped ( & bcx, op) ;
273
- }
274
- funclet_br ( bcx, self . llblock ( target) ) ;
275
- } else {
276
- // trans_intrinsic_call already used Unreachable.
277
- // bcx.unreachable();
278
- }
279
271
} ) ;
280
272
281
273
if let ReturnDest :: IndirectOperand ( dst, _) = ret_dest {
282
274
// Make a fake operand for store_return
283
275
let op = OperandRef {
284
276
val : OperandValue :: Ref ( dst) ,
285
- ty : sig. 0 . output . unwrap ( )
277
+ ty : sig. output . unwrap ( )
286
278
} ;
287
279
self . store_return ( & bcx, ret_dest, fn_ty. ret , op) ;
288
280
}
289
281
282
+ if let Some ( ( _, target) ) = * destination {
283
+ for op in args {
284
+ self . set_operand_dropped ( & bcx, op) ;
285
+ }
286
+ funclet_br ( bcx, self . llblock ( target) ) ;
287
+ } else {
288
+ // trans_intrinsic_call already used Unreachable.
289
+ // bcx.unreachable();
290
+ }
291
+
290
292
return ;
291
293
}
292
294
Fn ( f) => f,
@@ -318,7 +320,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
318
320
ret_bcx. at_start ( |ret_bcx| {
319
321
let op = OperandRef {
320
322
val : OperandValue :: Immediate ( invokeret) ,
321
- ty : sig. 0 . output . unwrap ( )
323
+ ty : sig. output . unwrap ( )
322
324
} ;
323
325
self . store_return ( & ret_bcx, ret_dest, fn_ty. ret , op) ;
324
326
for op in args {
@@ -332,7 +334,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
332
334
if let Some ( ( _, target) ) = * destination {
333
335
let op = OperandRef {
334
336
val : OperandValue :: Immediate ( llret) ,
335
- ty : sig. 0 . output . unwrap ( )
337
+ ty : sig. output . unwrap ( )
336
338
} ;
337
339
self . store_return ( & bcx, ret_dest, fn_ty. ret , op) ;
338
340
for op in args {
@@ -554,6 +556,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
554
556
let dest = match * dest {
555
557
mir:: Lvalue :: Temp ( idx) => {
556
558
let lvalue_ty = self . mir . lvalue_ty ( bcx. tcx ( ) , dest) ;
559
+ let lvalue_ty = bcx. monomorphize ( & lvalue_ty) ;
557
560
let ret_ty = lvalue_ty. to_ty ( bcx. tcx ( ) ) ;
558
561
match self . temps [ idx as usize ] {
559
562
TempRef :: Lvalue ( dest) => dest,
@@ -633,6 +636,18 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
633
636
self . temps [ idx as usize ] = TempRef :: Operand ( Some ( op) ) ;
634
637
}
635
638
DirectOperand ( idx) => {
639
+ let op = if type_is_fat_ptr ( bcx. tcx ( ) , op. ty ) {
640
+ let llval = op. immediate ( ) ;
641
+ let ptr = bcx. extract_value ( llval, 0 ) ;
642
+ let meta = bcx. extract_value ( llval, 1 ) ;
643
+
644
+ OperandRef {
645
+ val : OperandValue :: FatPtr ( ptr, meta) ,
646
+ ty : op. ty
647
+ }
648
+ } else {
649
+ op
650
+ } ;
636
651
self . temps [ idx as usize ] = TempRef :: Operand ( Some ( op) ) ;
637
652
}
638
653
}
0 commit comments