@@ -39,12 +39,15 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> {
3939 } => {
4040 let discr_val = self . eval_operand ( discr) ?;
4141 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 ) ?;
4245
4346 // Branch to the `otherwise` case by default, if no match is found.
4447 let mut target_block = targets[ targets. len ( ) - 1 ] ;
4548
4649 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 {
4851 target_block = targets[ index] ;
4952 break ;
5053 }
@@ -288,10 +291,10 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> {
288291 // and need to pack arguments
289292 Abi :: Rust => {
290293 trace ! (
291- "arg_locals: {:?}" ,
294+ "arg_locals: {:# ?}" ,
292295 self . frame( ) . mir. args_iter( ) . collect:: <Vec <_>>( )
293296 ) ;
294- trace ! ( "args: {:?}" , args) ;
297+ trace ! ( "args: {:# ?}" , args) ;
295298 let local = arg_locals. nth ( 1 ) . unwrap ( ) ;
296299 for ( i, & valty) in args. into_iter ( ) . enumerate ( ) {
297300 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> {
318321 let mut arg_locals = self . frame ( ) . mir . args_iter ( ) ;
319322 trace ! ( "ABI: {:?}" , sig. abi) ;
320323 trace ! (
321- "arg_locals: {:?}" ,
324+ "arg_locals: {:# ?}" ,
322325 self . frame( ) . mir. args_iter( ) . collect:: <Vec <_>>( )
323326 ) ;
324- trace ! ( "args: {:?}" , args) ;
327+ trace ! ( "args: {:# ?}" , args) ;
325328 match sig. abi {
326329 Abi :: RustCall => {
327330 assert_eq ! ( args. len( ) , 2 ) ;
@@ -373,14 +376,26 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> {
373376 }
374377 break ;
375378 }
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( ) ) ;
384399 }
385400 }
386401 } else {
0 commit comments