@@ -9,6 +9,7 @@ use rustc_abi::{BackendRepr, HasDataLayout, WrappingRange};
99use rustc_codegen_ssa:: base:: wants_msvc_seh;
1010use rustc_codegen_ssa:: common:: IntPredicate ;
1111use rustc_codegen_ssa:: errors:: InvalidMonomorphization ;
12+ use rustc_codegen_ssa:: mir:: IntrinsicResult ;
1213use rustc_codegen_ssa:: mir:: operand:: { OperandRef , OperandValue } ;
1314use rustc_codegen_ssa:: mir:: place:: { PlaceRef , PlaceValue } ;
1415#[ cfg( feature = "master" ) ]
@@ -194,11 +195,14 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tc
194195 & mut self ,
195196 instance : Instance < ' tcx > ,
196197 args : & [ OperandRef < ' tcx , RValue < ' gcc > > ] ,
197- result : PlaceRef < ' tcx , RValue < ' gcc > > ,
198+ result_layout : ty:: layout:: TyAndLayout < ' tcx > ,
199+ result_place : Option < PlaceValue < RValue < ' gcc > > > ,
198200 span : Span ,
199- ) -> Result < ( ) , Instance < ' tcx > > {
201+ ) -> IntrinsicResult < ' tcx , RValue < ' gcc > > {
200202 let tcx = self . tcx ;
201203
204+ let result = PlaceRef { val : result_place. unwrap ( ) , layout : result_layout } ;
205+
202206 let name = tcx. item_name ( instance. def_id ( ) ) ;
203207 let name_str = name. as_str ( ) ;
204208 let fn_args = instance. args ;
@@ -353,7 +357,7 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tc
353357 args[ 2 ] . immediate ( ) ,
354358 result,
355359 ) ;
356- return Ok ( ( ) ) ;
360+ return IntrinsicResult :: WroteIntoPlace ;
357361 }
358362 sym:: breakpoint => {
359363 unimplemented ! ( ) ;
@@ -375,12 +379,12 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tc
375379 sym:: volatile_store => {
376380 let dst = args[ 0 ] . deref ( self . cx ( ) ) ;
377381 args[ 1 ] . val . volatile_store ( self , dst) ;
378- return Ok ( ( ) ) ;
382+ return IntrinsicResult :: WroteIntoPlace ;
379383 }
380384 sym:: unaligned_volatile_store => {
381385 let dst = args[ 0 ] . deref ( self . cx ( ) ) ;
382386 args[ 1 ] . val . unaligned_volatile_store ( self , dst) ;
383- return Ok ( ( ) ) ;
387+ return IntrinsicResult :: WroteIntoPlace ;
384388 }
385389 sym:: prefetch_read_data
386390 | sym:: prefetch_write_data
@@ -448,12 +452,12 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tc
448452 _ => bug ! ( ) ,
449453 } ,
450454 None => {
451- tcx. dcx ( ) . emit_err ( InvalidMonomorphization :: BasicIntegerType {
455+ let err = tcx. dcx ( ) . emit_err ( InvalidMonomorphization :: BasicIntegerType {
452456 span,
453457 name,
454458 ty : args[ 0 ] . layout . ty ,
455459 } ) ;
456- return Ok ( ( ) ) ;
460+ return IntrinsicResult :: Err ( err ) ;
457461 }
458462 }
459463 }
@@ -544,7 +548,7 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tc
544548 extended_asm. set_volatile_flag ( true ) ;
545549
546550 // We have copied the value to `result` already.
547- return Ok ( ( ) ) ;
551+ return IntrinsicResult :: WroteIntoPlace ;
548552 }
549553
550554 sym:: ptr_mask => {
@@ -569,12 +573,15 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tc
569573 span,
570574 ) {
571575 Ok ( value) => value,
572- Err ( ( ) ) => return Ok ( ( ) ) ,
576+ Err ( err ) => return IntrinsicResult :: Err ( err ) ,
573577 }
574578 }
575579
576580 // Fall back to default body
577- _ => return Err ( Instance :: new_raw ( instance. def_id ( ) , instance. args ) ) ,
581+ _ => {
582+ let fallback = Instance :: new_raw ( instance. def_id ( ) , instance. args ) ;
583+ return IntrinsicResult :: Fallback ( fallback) ;
584+ }
578585 } ;
579586
580587 if result. layout . ty . is_bool ( ) {
@@ -583,7 +590,7 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tc
583590 } else if !result. layout . ty . is_unit ( ) {
584591 self . store_to_place ( value, result. val ) ;
585592 }
586- Ok ( ( ) )
593+ IntrinsicResult :: WroteIntoPlace
587594 }
588595
589596 fn codegen_llvm_intrinsic_call (
@@ -694,13 +701,12 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tc
694701 self . context . new_rvalue_from_int ( self . int_type , 0 )
695702 }
696703
697- fn va_start ( & mut self , _va_list : RValue < ' gcc > ) -> RValue < ' gcc > {
704+ fn va_start ( & mut self , _va_list : RValue < ' gcc > ) {
698705 unimplemented ! ( ) ;
699706 }
700707
701- fn va_end ( & mut self , _va_list : RValue < ' gcc > ) -> RValue < ' gcc > {
708+ fn va_end ( & mut self , _va_list : RValue < ' gcc > ) {
702709 // FIXME(antoyo): implement.
703- self . context . new_rvalue_from_int ( self . int_type , 0 )
704710 }
705711
706712 fn retag_reg ( & mut self , _ptr : Self :: Value , _info : & RetagInfo < Self :: Value > ) -> Self :: Value {
0 commit comments