@@ -946,16 +946,48 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> {
946
946
ecx. machine . validation == ValidationMode :: Deep
947
947
}
948
948
949
- #[ inline( always) ]
950
- fn enforce_abi ( _ecx : & MiriInterpCx < ' tcx > ) -> bool {
951
- true
952
- }
953
-
954
949
#[ inline( always) ]
955
950
fn ignore_optional_overflow_checks ( ecx : & MiriInterpCx < ' tcx > ) -> bool {
956
951
!ecx. tcx . sess . overflow_checks ( )
957
952
}
958
953
954
+ fn check_fn_target_features (
955
+ ecx : & MiriInterpCx < ' tcx > ,
956
+ instance : ty:: Instance < ' tcx > ,
957
+ ) -> InterpResult < ' tcx > {
958
+ let attrs = ecx. tcx . codegen_fn_attrs ( instance. def_id ( ) ) ;
959
+ if attrs
960
+ . target_features
961
+ . iter ( )
962
+ . any ( |feature| !ecx. tcx . sess . target_features . contains ( & feature. name ) )
963
+ {
964
+ let unavailable = attrs
965
+ . target_features
966
+ . iter ( )
967
+ . filter ( |& feature| {
968
+ !feature. implied && !ecx. tcx . sess . target_features . contains ( & feature. name )
969
+ } )
970
+ . fold ( String :: new ( ) , |mut s, feature| {
971
+ if !s. is_empty ( ) {
972
+ s. push_str ( ", " ) ;
973
+ }
974
+ s. push_str ( feature. name . as_str ( ) ) ;
975
+ s
976
+ } ) ;
977
+ let msg = format ! (
978
+ "calling a function that requires unavailable target features: {unavailable}"
979
+ ) ;
980
+ // On WASM, this is not UB, but instead gets rejected during validation of the module
981
+ // (see #84988).
982
+ if ecx. tcx . sess . target . is_like_wasm {
983
+ throw_machine_stop ! ( TerminationInfo :: Abort ( msg) ) ;
984
+ } else {
985
+ throw_ub_format ! ( "{msg}" ) ;
986
+ }
987
+ }
988
+ Ok ( ( ) )
989
+ }
990
+
959
991
#[ inline( always) ]
960
992
fn find_mir_or_eval_fn (
961
993
ecx : & mut MiriInterpCx < ' tcx > ,
@@ -1060,6 +1092,10 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> {
1060
1092
ecx. generate_nan ( inputs)
1061
1093
}
1062
1094
1095
+ fn ub_checks ( ecx : & InterpCx < ' tcx , Self > ) -> InterpResult < ' tcx , bool > {
1096
+ Ok ( ecx. tcx . sess . ub_checks ( ) )
1097
+ }
1098
+
1063
1099
fn thread_local_static_pointer (
1064
1100
ecx : & mut MiriInterpCx < ' tcx > ,
1065
1101
def_id : DefId ,
0 commit comments