@@ -76,20 +76,22 @@ pub(crate) fn maybe_codegen_mul_checked<'tcx>(
76
76
}
77
77
78
78
let is_signed = type_sign ( lhs. layout ( ) . ty ) ;
79
-
80
- let out_ty = Ty :: new_tup ( fx. tcx , & [ lhs. layout ( ) . ty , fx. tcx . types . bool ] ) ;
81
- let out_place = CPlace :: new_stack_slot ( fx, fx. layout_of ( out_ty) ) ;
79
+ let oflow_out_place = CPlace :: new_stack_slot ( fx, fx. layout_of ( fx. tcx . types . i32 ) ) ;
82
80
let param_types = vec ! [
83
- AbiParam :: special( fx. pointer_type, ArgumentPurpose :: StructReturn ) ,
84
81
AbiParam :: new( types:: I128 ) ,
85
82
AbiParam :: new( types:: I128 ) ,
83
+ AbiParam :: special( fx. pointer_type, ArgumentPurpose :: Normal ) ,
86
84
] ;
87
- let args = [ out_place . to_ptr ( ) . get_addr ( fx) , lhs . load_scalar ( fx) , rhs . load_scalar ( fx) ] ;
88
- fx. lib_call (
85
+ let args = [ lhs . load_scalar ( fx) , rhs . load_scalar ( fx) , oflow_out_place . to_ptr ( ) . get_addr ( fx) ] ;
86
+ let ret = fx. lib_call (
89
87
if is_signed { "__rust_i128_mulo" } else { "__rust_u128_mulo" } ,
90
88
param_types,
91
- vec ! [ ] ,
89
+ vec ! [ AbiParam :: new ( types :: I128 ) ] ,
92
90
& args,
93
91
) ;
94
- Some ( out_place. to_cvalue ( fx) )
92
+ let mul = ret[ 0 ] ;
93
+ let oflow = oflow_out_place. to_cvalue ( fx) . load_scalar ( fx) ;
94
+ let oflow = clif_intcast ( fx, oflow, types:: I8 , false ) ;
95
+ let layout = fx. layout_of ( Ty :: new_tup ( fx. tcx , & [ lhs. layout ( ) . ty , fx. tcx . types . bool ] ) ) ;
96
+ Some ( CValue :: by_val_pair ( mul, oflow, layout) )
95
97
}
0 commit comments