@@ -217,35 +217,42 @@ pub(crate) fn codegen_intrinsic_call<'tcx>(
217
217
fx : & mut FunctionCx < ' _ , ' _ , ' tcx > ,
218
218
instance : Instance < ' tcx > ,
219
219
args : & [ mir:: Operand < ' tcx > ] ,
220
- destination : Option < ( CPlace < ' tcx > , BasicBlock ) > ,
220
+ destination : CPlace < ' tcx > ,
221
+ target : Option < BasicBlock > ,
221
222
source_info : mir:: SourceInfo ,
222
223
) {
223
224
let intrinsic = fx. tcx . item_name ( instance. def_id ( ) ) ;
224
225
let substs = instance. substs ;
225
226
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 ) ) ;
238
234
}
239
- return ;
235
+ sym:: transmute => {
236
+ crate :: base:: codegen_panic ( fx, "Transmuting to uninhabited type." , source_info) ;
237
+ }
238
+ _ => unimplemented ! ( "unsupported instrinsic {}" , intrinsic) ,
240
239
}
240
+ return ;
241
241
} ;
242
242
243
243
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) ;
246
253
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 ) ;
249
256
fx. bcx . ins ( ) . jump ( ret_block, & [ ] ) ;
250
257
} else {
251
258
codegen_regular_intrinsic_call (
@@ -254,9 +261,9 @@ pub(crate) fn codegen_intrinsic_call<'tcx>(
254
261
intrinsic,
255
262
substs,
256
263
args,
257
- ret,
258
- source_info,
259
264
destination,
265
+ Some ( target) ,
266
+ source_info,
260
267
) ;
261
268
}
262
269
}
@@ -339,8 +346,8 @@ fn codegen_regular_intrinsic_call<'tcx>(
339
346
substs : SubstsRef < ' tcx > ,
340
347
args : & [ mir:: Operand < ' tcx > ] ,
341
348
ret : CPlace < ' tcx > ,
349
+ destination : Option < BasicBlock > ,
342
350
source_info : mir:: SourceInfo ,
343
- destination : Option < ( CPlace < ' tcx > , BasicBlock ) > ,
344
351
) {
345
352
let usize_layout = fx. layout_of ( fx. tcx . types . usize ) ;
346
353
@@ -761,7 +768,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
761
768
if fx. tcx. is_compiler_builtins( LOCAL_CRATE ) {
762
769
// special case for compiler-builtins to avoid having to patch it
763
770
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( ) ) ;
765
772
fx. bcx. ins( ) . jump( ret_block, & [ ] ) ;
766
773
return ;
767
774
} else {
@@ -789,7 +796,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
789
796
if fx. tcx. is_compiler_builtins( LOCAL_CRATE ) {
790
797
// special case for compiler-builtins to avoid having to patch it
791
798
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( ) ) ;
793
800
fx. bcx. ins( ) . jump( ret_block, & [ ] ) ;
794
801
return ;
795
802
} else {
@@ -1130,6 +1137,6 @@ fn codegen_regular_intrinsic_call<'tcx>(
1130
1137
} ;
1131
1138
}
1132
1139
1133
- let ret_block = fx. get_block ( destination. unwrap ( ) . 1 ) ;
1140
+ let ret_block = fx. get_block ( destination. unwrap ( ) ) ;
1134
1141
fx. bcx . ins ( ) . jump ( ret_block, & [ ] ) ;
1135
1142
}
0 commit comments