@@ -9,9 +9,9 @@ use rspirv::spirv::GLOp;
99use rustc_codegen_ssa:: mir:: operand:: OperandRef ;
1010use rustc_codegen_ssa:: mir:: place:: PlaceRef ;
1111use rustc_codegen_ssa:: traits:: { BuilderMethods , IntrinsicCallMethods } ;
12- use rustc_middle:: bug;
1312use rustc_middle:: ty:: layout:: LayoutOf ;
1413use rustc_middle:: ty:: { FnDef , Instance , ParamEnv , Ty , TyKind } ;
14+ use rustc_middle:: { bug, ty} ;
1515use rustc_span:: sym;
1616use rustc_span:: Span ;
1717use rustc_target:: abi:: call:: { FnAbi , PassMode } ;
@@ -71,7 +71,7 @@ impl<'a, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'tcx> {
7171 args : & [ OperandRef < ' tcx , Self :: Value > ] ,
7272 llresult : Self :: Value ,
7373 _span : Span ,
74- ) {
74+ ) -> Result < ( ) , ty :: Instance < ' tcx > > {
7575 let callee_ty = instance. ty ( self . tcx , ParamEnv :: reveal_all ( ) ) ;
7676
7777 let ( def_id, fn_args) = match * callee_ty. kind ( ) {
@@ -98,7 +98,7 @@ impl<'a, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'tcx> {
9898 sym:: breakpoint => {
9999 self . abort ( ) ;
100100 assert ! ( fn_abi. ret. is_ignore( ) ) ;
101- return ;
101+ return Ok ( ( ) ) ;
102102 }
103103
104104 sym:: volatile_load | sym:: unaligned_volatile_load => {
@@ -108,7 +108,7 @@ impl<'a, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'tcx> {
108108 if !result. layout . is_zst ( ) {
109109 self . store ( load, result. llval , result. align ) ;
110110 }
111- return ;
111+ return Ok ( ( ) ) ;
112112 }
113113
114114 sym:: prefetch_read_data
@@ -117,7 +117,7 @@ impl<'a, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'tcx> {
117117 | sym:: prefetch_write_instruction => {
118118 // ignore
119119 assert ! ( fn_abi. ret. is_ignore( ) ) ;
120- return ;
120+ return Ok ( ( ) ) ;
121121 }
122122
123123 sym:: saturating_add => {
@@ -336,7 +336,10 @@ impl<'a, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'tcx> {
336336 undef
337337 }
338338
339- _ => self . fatal ( format ! ( "TODO: Unknown intrinsic '{name}'" ) ) ,
339+ _ => {
340+ // Call the fallback body instead of generating the intrinsic code
341+ return Err ( ty:: Instance :: new ( instance. def_id ( ) , instance. args ) ) ;
342+ }
340343 } ;
341344
342345 if !fn_abi. ret . is_ignore ( ) {
@@ -345,6 +348,7 @@ impl<'a, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'tcx> {
345348 . val
346349 . store ( self , result) ;
347350 }
351+ Ok ( ( ) )
348352 }
349353
350354 fn abort ( & mut self ) {
0 commit comments