@@ -39,12 +39,15 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> {
39
39
} => {
40
40
let discr_val = self . eval_operand ( discr) ?;
41
41
let discr_prim = self . value_to_scalar ( discr_val) ?;
42
+ let discr_layout = self . layout_of ( discr_val. ty ) . unwrap ( ) ;
43
+ trace ! ( "SwitchInt({:?}, {:#?})" , discr_prim, discr_layout) ;
44
+ let discr_prim = discr_prim. to_bits ( discr_layout. size ) ?;
42
45
43
46
// Branch to the `otherwise` case by default, if no match is found.
44
47
let mut target_block = targets[ targets. len ( ) - 1 ] ;
45
48
46
49
for ( index, & const_int) in values. iter ( ) . enumerate ( ) {
47
- if discr_prim. to_bits ( self . layout_of ( discr_val . ty ) . unwrap ( ) . size ) ? == const_int {
50
+ if discr_prim == const_int {
48
51
target_block = targets[ index] ;
49
52
break ;
50
53
}
@@ -288,10 +291,10 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> {
288
291
// and need to pack arguments
289
292
Abi :: Rust => {
290
293
trace ! (
291
- "arg_locals: {:?}" ,
294
+ "arg_locals: {:# ?}" ,
292
295
self . frame( ) . mir. args_iter( ) . collect:: <Vec <_>>( )
293
296
) ;
294
- trace ! ( "args: {:?}" , args) ;
297
+ trace ! ( "args: {:# ?}" , args) ;
295
298
let local = arg_locals. nth ( 1 ) . unwrap ( ) ;
296
299
for ( i, & valty) in args. into_iter ( ) . enumerate ( ) {
297
300
let dest = self . eval_place ( & mir:: Place :: Local ( local) . field (
@@ -318,10 +321,10 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> {
318
321
let mut arg_locals = self . frame ( ) . mir . args_iter ( ) ;
319
322
trace ! ( "ABI: {:?}" , sig. abi) ;
320
323
trace ! (
321
- "arg_locals: {:?}" ,
324
+ "arg_locals: {:# ?}" ,
322
325
self . frame( ) . mir. args_iter( ) . collect:: <Vec <_>>( )
323
326
) ;
324
- trace ! ( "args: {:?}" , args) ;
327
+ trace ! ( "args: {:# ?}" , args) ;
325
328
match sig. abi {
326
329
Abi :: RustCall => {
327
330
assert_eq ! ( args. len( ) , 2 ) ;
@@ -373,14 +376,26 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> {
373
376
}
374
377
break ;
375
378
}
376
- let dest = self . eval_place ( & mir:: Place :: Local (
377
- arg_locals. next ( ) . unwrap ( ) ,
378
- ) ) ?;
379
- let valty = ValTy {
380
- value : other,
381
- ty : layout. ty ,
382
- } ;
383
- self . write_value ( valty, dest) ?;
379
+ {
380
+ let mut write_next = |value| {
381
+ let dest = self . eval_place ( & mir:: Place :: Local (
382
+ arg_locals. next ( ) . unwrap ( ) ,
383
+ ) ) ?;
384
+ let valty = ValTy {
385
+ value : Value :: Scalar ( value) ,
386
+ ty : layout. ty ,
387
+ } ;
388
+ self . write_value ( valty, dest)
389
+ } ;
390
+ match other {
391
+ Value :: Scalar ( value) | Value :: ScalarPair ( value, _) => write_next ( value) ?,
392
+ _ => unreachable ! ( ) ,
393
+ }
394
+ if let Value :: ScalarPair ( _, value) = other {
395
+ write_next ( value) ?;
396
+ }
397
+ }
398
+ assert ! ( arg_locals. next( ) . is_none( ) ) ;
384
399
}
385
400
}
386
401
} else {
0 commit comments