@@ -217,35 +217,42 @@ pub(crate) fn codegen_intrinsic_call<'tcx>(
217217 fx : & mut FunctionCx < ' _ , ' _ , ' tcx > ,
218218 instance : Instance < ' tcx > ,
219219 args : & [ mir:: Operand < ' tcx > ] ,
220- destination : Option < ( CPlace < ' tcx > , BasicBlock ) > ,
220+ destination : CPlace < ' tcx > ,
221+ target : Option < BasicBlock > ,
221222 source_info : mir:: SourceInfo ,
222223) {
223224 let intrinsic = fx. tcx . item_name ( instance. def_id ( ) ) ;
224225 let substs = instance. substs ;
225226
226- let ret = match destination {
227- Some ( ( place, _) ) => place,
228- None => {
229- // Insert non returning intrinsics here
230- match intrinsic {
231- sym:: abort => {
232- fx. bcx . ins ( ) . trap ( TrapCode :: User ( 0 ) ) ;
233- }
234- sym:: transmute => {
235- crate :: base:: codegen_panic ( fx, "Transmuting to uninhabited type." , source_info) ;
236- }
237- _ => unimplemented ! ( "unsupported instrinsic {}" , intrinsic) ,
227+ let target = if let Some ( target) = target {
228+ target
229+ } else {
230+ // Insert non returning intrinsics here
231+ match intrinsic {
232+ sym:: abort => {
233+ fx. bcx . ins ( ) . trap ( TrapCode :: User ( 0 ) ) ;
238234 }
239- return ;
235+ sym:: transmute => {
236+ crate :: base:: codegen_panic ( fx, "Transmuting to uninhabited type." , source_info) ;
237+ }
238+ _ => unimplemented ! ( "unsupported instrinsic {}" , intrinsic) ,
240239 }
240+ return ;
241241 } ;
242242
243243 if intrinsic. as_str ( ) . starts_with ( "simd_" ) {
244- self :: simd:: codegen_simd_intrinsic_call ( fx, intrinsic, substs, args, ret, source_info. span ) ;
245- let ret_block = fx. get_block ( destination. expect ( "SIMD intrinsics don't diverge" ) . 1 ) ;
244+ self :: simd:: codegen_simd_intrinsic_call (
245+ fx,
246+ intrinsic,
247+ substs,
248+ args,
249+ destination,
250+ source_info. span ,
251+ ) ;
252+ let ret_block = fx. get_block ( target) ;
246253 fx. bcx . ins ( ) . jump ( ret_block, & [ ] ) ;
247- } else if codegen_float_intrinsic_call ( fx, intrinsic, args, ret ) {
248- let ret_block = fx. get_block ( destination . expect ( "Float intrinsics don't diverge" ) . 1 ) ;
254+ } else if codegen_float_intrinsic_call ( fx, intrinsic, args, destination ) {
255+ let ret_block = fx. get_block ( target ) ;
249256 fx. bcx . ins ( ) . jump ( ret_block, & [ ] ) ;
250257 } else {
251258 codegen_regular_intrinsic_call (
@@ -254,9 +261,9 @@ pub(crate) fn codegen_intrinsic_call<'tcx>(
254261 intrinsic,
255262 substs,
256263 args,
257- ret,
258- source_info,
259264 destination,
265+ Some ( target) ,
266+ source_info,
260267 ) ;
261268 }
262269}
@@ -339,8 +346,8 @@ fn codegen_regular_intrinsic_call<'tcx>(
339346 substs : SubstsRef < ' tcx > ,
340347 args : & [ mir:: Operand < ' tcx > ] ,
341348 ret : CPlace < ' tcx > ,
349+ destination : Option < BasicBlock > ,
342350 source_info : mir:: SourceInfo ,
343- destination : Option < ( CPlace < ' tcx > , BasicBlock ) > ,
344351) {
345352 let usize_layout = fx. layout_of ( fx. tcx . types . usize ) ;
346353
@@ -761,7 +768,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
761768 if fx. tcx. is_compiler_builtins( LOCAL_CRATE ) {
762769 // special case for compiler-builtins to avoid having to patch it
763770 crate :: trap:: trap_unimplemented( fx, "128bit atomics not yet supported" ) ;
764- let ret_block = fx. get_block( destination. unwrap( ) . 1 ) ;
771+ let ret_block = fx. get_block( destination. unwrap( ) ) ;
765772 fx. bcx. ins( ) . jump( ret_block, & [ ] ) ;
766773 return ;
767774 } else {
@@ -789,7 +796,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
789796 if fx. tcx. is_compiler_builtins( LOCAL_CRATE ) {
790797 // special case for compiler-builtins to avoid having to patch it
791798 crate :: trap:: trap_unimplemented( fx, "128bit atomics not yet supported" ) ;
792- let ret_block = fx. get_block( destination. unwrap( ) . 1 ) ;
799+ let ret_block = fx. get_block( destination. unwrap( ) ) ;
793800 fx. bcx. ins( ) . jump( ret_block, & [ ] ) ;
794801 return ;
795802 } else {
@@ -1130,6 +1137,6 @@ fn codegen_regular_intrinsic_call<'tcx>(
11301137 } ;
11311138 }
11321139
1133- let ret_block = fx. get_block ( destination. unwrap ( ) . 1 ) ;
1140+ let ret_block = fx. get_block ( destination. unwrap ( ) ) ;
11341141 fx. bcx . ins ( ) . jump ( ret_block, & [ ] ) ;
11351142}
0 commit comments