@@ -426,44 +426,26 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'mir, 'tcx> {
426
426
Ok ( ( ) )
427
427
}
428
428
429
- fn thread_local_alloc_id (
429
+ fn thread_local_static_alloc_id (
430
430
ecx : & mut InterpCx < ' mir , ' tcx , Self > ,
431
431
def_id : DefId ,
432
432
) -> InterpResult < ' tcx , AllocId > {
433
433
ecx. get_or_create_thread_local_alloc_id ( def_id)
434
434
}
435
435
436
- fn adjust_global_const (
437
- ecx : & InterpCx < ' mir , ' tcx , Self > ,
438
- mut val : mir:: interpret:: ConstValue < ' tcx > ,
439
- ) -> InterpResult < ' tcx , mir:: interpret:: ConstValue < ' tcx > > {
440
- // FIXME: Remove this, do The Right Thing in `thread_local_alloc_id` instead.
441
- ecx. remap_thread_local_alloc_ids ( & mut val) ?;
442
- Ok ( val)
443
- }
444
-
445
- fn canonical_alloc_id ( mem : & Memory < ' mir , ' tcx , Self > , id : AllocId ) -> AllocId {
446
- let tcx = mem. tcx ;
447
- // Figure out if this is an extern static, and if yes, which one.
448
- let def_id = match tcx. get_global_alloc ( id) {
449
- Some ( GlobalAlloc :: Static ( def_id) ) if tcx. is_foreign_item ( def_id) => def_id,
450
- _ => {
451
- // No need to canonicalize anything.
452
- return id;
453
- }
454
- } ;
455
- let attrs = tcx. get_attrs ( def_id) ;
436
+ fn extern_static_alloc_id (
437
+ memory : & Memory < ' mir , ' tcx , Self > ,
438
+ def_id : DefId ,
439
+ ) -> InterpResult < ' tcx , AllocId > {
440
+ let attrs = memory. tcx . get_attrs ( def_id) ;
456
441
let link_name = match attr:: first_attr_value_str_by_name ( & attrs, sym:: link_name) {
457
442
Some ( name) => name,
458
- None => tcx. item_name ( def_id) ,
443
+ None => memory . tcx . item_name ( def_id) ,
459
444
} ;
460
- // Check if we know this one.
461
- if let Some ( canonical_id) = mem. extra . extern_statics . get ( & link_name) {
462
- trace ! ( "canonical_alloc_id: {:?} ({}) -> {:?}" , id, link_name, canonical_id) ;
463
- * canonical_id
445
+ if let Some ( & id) = memory. extra . extern_statics . get ( & link_name) {
446
+ Ok ( id)
464
447
} else {
465
- // Return original id; `Memory::get_static_alloc` will throw an error.
466
- id
448
+ throw_unsup_format ! ( "`extern` static {:?} is not supported by Miri" , def_id)
467
449
}
468
450
}
469
451
0 commit comments