@@ -525,45 +525,30 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
525525 }
526526
527527 // Rust allocation
528- name if name == this . mangle_internal_symbol ( "__rust_alloc" ) || name == "miri_alloc" => {
528+ "miri_alloc" => {
529529 let default = |ecx : & mut MiriInterpCx < ' tcx > | {
530530 // Only call `check_shim` when `#[global_allocator]` isn't used. When that
531531 // macro is used, we act like no shim exists, so that the exported function can run.
532532 let [ size, align] = ecx. check_shim ( abi, CanonAbi :: Rust , link_name, args) ?;
533533 let size = ecx. read_target_usize ( size) ?;
534534 let align = ecx. read_target_usize ( align) ?;
535535
536- ecx. check_rustc_alloc_request ( size, align) ?;
537-
538- let memory_kind = match link_name. as_str ( ) {
539- "miri_alloc" => MiriMemoryKind :: Miri ,
540- _ => MiriMemoryKind :: Rust ,
541- } ;
536+ this. check_rustc_alloc_request ( size, align) ?;
542537
543538 let ptr = ecx. allocate_ptr (
544539 Size :: from_bytes ( size) ,
545540 Align :: from_bytes ( align) . unwrap ( ) ,
546- memory_kind . into ( ) ,
541+ MiriMemoryKind :: Miri . into ( ) ,
547542 AllocInit :: Uninit ,
548543 ) ?;
549544
550545 ecx. write_pointer ( ptr, dest)
551546 } ;
552547
553- match link_name. as_str ( ) {
554- "miri_alloc" => {
555- default ( this) ?;
556- return interp_ok ( EmulateItemResult :: NeedsReturn ) ;
557- }
558- _ => return this. emulate_allocator ( ) ,
559- }
560- }
561- name if name == this. mangle_internal_symbol ( "__rust_alloc_zeroed" ) => {
562- return this. emulate_allocator ( ) ;
548+ default ( this) ?;
549+ return interp_ok ( EmulateItemResult :: NeedsReturn ) ;
563550 }
564- name if name == this. mangle_internal_symbol ( "__rust_dealloc" )
565- || name == "miri_dealloc" =>
566- {
551+ "miri_dealloc" => {
567552 let default = |ecx : & mut MiriInterpCx < ' tcx > | {
568553 // See the comment for `__rust_alloc` why `check_shim` is only called in the
569554 // default case.
@@ -573,29 +558,16 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
573558 let old_size = ecx. read_target_usize ( old_size) ?;
574559 let align = ecx. read_target_usize ( align) ?;
575560
576- let memory_kind = match link_name. as_str ( ) {
577- "miri_dealloc" => MiriMemoryKind :: Miri ,
578- _ => MiriMemoryKind :: Rust ,
579- } ;
580-
581561 // No need to check old_size/align; we anyway check that they match the allocation.
582562 ecx. deallocate_ptr (
583563 ptr,
584564 Some ( ( Size :: from_bytes ( old_size) , Align :: from_bytes ( align) . unwrap ( ) ) ) ,
585- memory_kind . into ( ) ,
565+ MiriMemoryKind :: Miri . into ( ) ,
586566 )
587567 } ;
588568
589- match link_name. as_str ( ) {
590- "miri_dealloc" => {
591- default ( this) ?;
592- return interp_ok ( EmulateItemResult :: NeedsReturn ) ;
593- }
594- _ => return this. emulate_allocator ( ) ,
595- }
596- }
597- name if name == this. mangle_internal_symbol ( "__rust_realloc" ) => {
598- return this. emulate_allocator ( ) ;
569+ default ( this) ?;
570+ return interp_ok ( EmulateItemResult :: NeedsReturn ) ;
599571 }
600572
601573 // C memory handling functions
0 commit comments