@@ -268,7 +268,7 @@ pub(crate) fn codegen_intrinsic_call<'tcx>(
268
268
destination : CPlace < ' tcx > ,
269
269
target : Option < BasicBlock > ,
270
270
source_info : mir:: SourceInfo ,
271
- ) {
271
+ ) -> Result < ( ) , Instance < ' tcx > > {
272
272
let intrinsic = fx. tcx . item_name ( instance. def_id ( ) ) ;
273
273
let instance_args = instance. args ;
274
274
@@ -295,8 +295,9 @@ pub(crate) fn codegen_intrinsic_call<'tcx>(
295
295
destination,
296
296
target,
297
297
source_info,
298
- ) ;
298
+ ) ? ;
299
299
}
300
+ Ok ( ( ) )
300
301
}
301
302
302
303
fn codegen_float_intrinsic_call < ' tcx > (
@@ -430,25 +431,20 @@ fn codegen_regular_intrinsic_call<'tcx>(
430
431
ret : CPlace < ' tcx > ,
431
432
destination : Option < BasicBlock > ,
432
433
source_info : mir:: SourceInfo ,
433
- ) {
434
+ ) -> Result < ( ) , Instance < ' tcx > > {
435
+ assert_eq ! ( generic_args, instance. args) ;
434
436
let usize_layout = fx. layout_of ( fx. tcx . types . usize ) ;
435
437
436
438
match intrinsic {
437
439
sym:: abort => {
438
440
fx. bcx . ins ( ) . trap ( TrapCode :: User ( 0 ) ) ;
439
- return ;
441
+ return Ok ( ( ) ) ;
440
442
}
441
443
sym:: likely | sym:: unlikely => {
442
444
intrinsic_args ! ( fx, args => ( a) ; intrinsic) ;
443
445
444
446
ret. write_cvalue ( fx, a) ;
445
447
}
446
- sym:: is_val_statically_known => {
447
- intrinsic_args ! ( fx, args => ( _a) ; intrinsic) ;
448
-
449
- let res = fx. bcx . ins ( ) . iconst ( types:: I8 , 0 ) ;
450
- ret. write_cvalue ( fx, CValue :: by_val ( res, ret. layout ( ) ) ) ;
451
- }
452
448
sym:: breakpoint => {
453
449
intrinsic_args ! ( fx, args => ( ) ; intrinsic) ;
454
450
@@ -697,7 +693,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
697
693
} )
698
694
} ) ;
699
695
crate :: base:: codegen_panic_nounwind ( fx, & msg_str, Some ( source_info. span ) ) ;
700
- return ;
696
+ return Ok ( ( ) ) ;
701
697
}
702
698
}
703
699
}
@@ -792,7 +788,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
792
788
if fx. tcx . is_compiler_builtins ( LOCAL_CRATE ) {
793
789
// special case for compiler-builtins to avoid having to patch it
794
790
crate :: trap:: trap_unimplemented ( fx, "128bit atomics not yet supported" ) ;
795
- return ;
791
+ return Ok ( ( ) ) ;
796
792
} else {
797
793
fx. tcx
798
794
. dcx ( )
@@ -802,7 +798,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
802
798
ty:: Uint ( _) | ty:: Int ( _) | ty:: RawPtr ( ..) => { }
803
799
_ => {
804
800
report_atomic_type_validation_error ( fx, intrinsic, source_info. span , ty) ;
805
- return ;
801
+ return Ok ( ( ) ) ;
806
802
}
807
803
}
808
804
let clif_ty = fx. clif_type ( ty) . unwrap ( ) ;
@@ -823,7 +819,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
823
819
if fx. tcx . is_compiler_builtins ( LOCAL_CRATE ) {
824
820
// special case for compiler-builtins to avoid having to patch it
825
821
crate :: trap:: trap_unimplemented ( fx, "128bit atomics not yet supported" ) ;
826
- return ;
822
+ return Ok ( ( ) ) ;
827
823
} else {
828
824
fx. tcx
829
825
. dcx ( )
@@ -833,7 +829,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
833
829
ty:: Uint ( _) | ty:: Int ( _) | ty:: RawPtr ( ..) => { }
834
830
_ => {
835
831
report_atomic_type_validation_error ( fx, intrinsic, source_info. span , ty) ;
836
- return ;
832
+ return Ok ( ( ) ) ;
837
833
}
838
834
}
839
835
@@ -850,7 +846,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
850
846
ty:: Uint ( _) | ty:: Int ( _) | ty:: RawPtr ( ..) => { }
851
847
_ => {
852
848
report_atomic_type_validation_error ( fx, intrinsic, source_info. span , layout. ty ) ;
853
- return ;
849
+ return Ok ( ( ) ) ;
854
850
}
855
851
}
856
852
let ty = fx. clif_type ( layout. ty ) . unwrap ( ) ;
@@ -872,7 +868,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
872
868
ty:: Uint ( _) | ty:: Int ( _) | ty:: RawPtr ( ..) => { }
873
869
_ => {
874
870
report_atomic_type_validation_error ( fx, intrinsic, source_info. span , layout. ty ) ;
875
- return ;
871
+ return Ok ( ( ) ) ;
876
872
}
877
873
}
878
874
@@ -895,7 +891,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
895
891
ty:: Uint ( _) | ty:: Int ( _) | ty:: RawPtr ( ..) => { }
896
892
_ => {
897
893
report_atomic_type_validation_error ( fx, intrinsic, source_info. span , layout. ty ) ;
898
- return ;
894
+ return Ok ( ( ) ) ;
899
895
}
900
896
}
901
897
let ty = fx. clif_type ( layout. ty ) . unwrap ( ) ;
@@ -917,7 +913,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
917
913
ty:: Uint ( _) | ty:: Int ( _) | ty:: RawPtr ( ..) => { }
918
914
_ => {
919
915
report_atomic_type_validation_error ( fx, intrinsic, source_info. span , layout. ty ) ;
920
- return ;
916
+ return Ok ( ( ) ) ;
921
917
}
922
918
}
923
919
let ty = fx. clif_type ( layout. ty ) . unwrap ( ) ;
@@ -939,7 +935,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
939
935
ty:: Uint ( _) | ty:: Int ( _) | ty:: RawPtr ( ..) => { }
940
936
_ => {
941
937
report_atomic_type_validation_error ( fx, intrinsic, source_info. span , layout. ty ) ;
942
- return ;
938
+ return Ok ( ( ) ) ;
943
939
}
944
940
}
945
941
let ty = fx. clif_type ( layout. ty ) . unwrap ( ) ;
@@ -960,7 +956,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
960
956
ty:: Uint ( _) | ty:: Int ( _) | ty:: RawPtr ( ..) => { }
961
957
_ => {
962
958
report_atomic_type_validation_error ( fx, intrinsic, source_info. span , layout. ty ) ;
963
- return ;
959
+ return Ok ( ( ) ) ;
964
960
}
965
961
}
966
962
let ty = fx. clif_type ( layout. ty ) . unwrap ( ) ;
@@ -981,7 +977,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
981
977
ty:: Uint ( _) | ty:: Int ( _) | ty:: RawPtr ( ..) => { }
982
978
_ => {
983
979
report_atomic_type_validation_error ( fx, intrinsic, source_info. span , layout. ty ) ;
984
- return ;
980
+ return Ok ( ( ) ) ;
985
981
}
986
982
}
987
983
let ty = fx. clif_type ( layout. ty ) . unwrap ( ) ;
@@ -1002,7 +998,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
1002
998
ty:: Uint ( _) | ty:: Int ( _) | ty:: RawPtr ( ..) => { }
1003
999
_ => {
1004
1000
report_atomic_type_validation_error ( fx, intrinsic, source_info. span , layout. ty ) ;
1005
- return ;
1001
+ return Ok ( ( ) ) ;
1006
1002
}
1007
1003
}
1008
1004
let ty = fx. clif_type ( layout. ty ) . unwrap ( ) ;
@@ -1023,7 +1019,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
1023
1019
ty:: Uint ( _) | ty:: Int ( _) | ty:: RawPtr ( ..) => { }
1024
1020
_ => {
1025
1021
report_atomic_type_validation_error ( fx, intrinsic, source_info. span , layout. ty ) ;
1026
- return ;
1022
+ return Ok ( ( ) ) ;
1027
1023
}
1028
1024
}
1029
1025
let ty = fx. clif_type ( layout. ty ) . unwrap ( ) ;
@@ -1044,7 +1040,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
1044
1040
ty:: Uint ( _) | ty:: Int ( _) | ty:: RawPtr ( ..) => { }
1045
1041
_ => {
1046
1042
report_atomic_type_validation_error ( fx, intrinsic, source_info. span , layout. ty ) ;
1047
- return ;
1043
+ return Ok ( ( ) ) ;
1048
1044
}
1049
1045
}
1050
1046
let ty = fx. clif_type ( layout. ty ) . unwrap ( ) ;
@@ -1065,7 +1061,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
1065
1061
ty:: Uint ( _) | ty:: Int ( _) | ty:: RawPtr ( ..) => { }
1066
1062
_ => {
1067
1063
report_atomic_type_validation_error ( fx, intrinsic, source_info. span , layout. ty ) ;
1068
- return ;
1064
+ return Ok ( ( ) ) ;
1069
1065
}
1070
1066
}
1071
1067
let ty = fx. clif_type ( layout. ty ) . unwrap ( ) ;
@@ -1086,7 +1082,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
1086
1082
ty:: Uint ( _) | ty:: Int ( _) | ty:: RawPtr ( ..) => { }
1087
1083
_ => {
1088
1084
report_atomic_type_validation_error ( fx, intrinsic, source_info. span , layout. ty ) ;
1089
- return ;
1085
+ return Ok ( ( ) ) ;
1090
1086
}
1091
1087
}
1092
1088
let ty = fx. clif_type ( layout. ty ) . unwrap ( ) ;
@@ -1233,19 +1229,6 @@ fn codegen_regular_intrinsic_call<'tcx>(
1233
1229
ret. write_cvalue ( fx, CValue :: by_val ( cmp, ret. layout ( ) ) ) ;
1234
1230
}
1235
1231
1236
- sym:: const_allocate => {
1237
- intrinsic_args ! ( fx, args => ( _size, _align) ; intrinsic) ;
1238
-
1239
- // returns a null pointer at runtime.
1240
- let null = fx. bcx . ins ( ) . iconst ( fx. pointer_type , 0 ) ;
1241
- ret. write_cvalue ( fx, CValue :: by_val ( null, ret. layout ( ) ) ) ;
1242
- }
1243
-
1244
- sym:: const_deallocate => {
1245
- intrinsic_args ! ( fx, args => ( _ptr, _size, _align) ; intrinsic) ;
1246
- // nop at runtime.
1247
- }
1248
-
1249
1232
sym:: black_box => {
1250
1233
intrinsic_args ! ( fx, args => ( a) ; intrinsic) ;
1251
1234
@@ -1261,13 +1244,12 @@ fn codegen_regular_intrinsic_call<'tcx>(
1261
1244
) ;
1262
1245
}
1263
1246
1264
- _ => {
1265
- fx. tcx
1266
- . dcx ( )
1267
- . span_fatal ( source_info. span , format ! ( "unsupported intrinsic {}" , intrinsic) ) ;
1268
- }
1247
+ // Unimplemented intrinsics must have a fallback body. The fallback body is obtained
1248
+ // by converting the `InstanceDef::Intrinsic` to an `InstanceDef::Item`.
1249
+ _ => return Err ( Instance :: new ( instance. def_id ( ) , instance. args ) ) ,
1269
1250
}
1270
1251
1271
1252
let ret_block = fx. get_block ( destination. unwrap ( ) ) ;
1272
1253
fx. bcx . ins ( ) . jump ( ret_block, & [ ] ) ;
1254
+ Ok ( ( ) )
1273
1255
}
0 commit comments