1
- use rustc:: ty;
2
1
use rustc:: ty:: layout:: { Align , LayoutOf , Size } ;
3
2
use rustc:: hir:: def_id:: DefId ;
4
3
use rustc:: mir;
@@ -11,46 +10,6 @@ use crate::*;
11
10
12
11
impl < ' mir , ' tcx > EvalContextExt < ' mir , ' tcx > for crate :: MiriEvalContext < ' mir , ' tcx > { }
13
12
pub trait EvalContextExt < ' mir , ' tcx : ' mir > : crate :: MiriEvalContextExt < ' mir , ' tcx > {
14
- fn find_fn (
15
- & mut self ,
16
- instance : ty:: Instance < ' tcx > ,
17
- args : & [ OpTy < ' tcx , Tag > ] ,
18
- dest : Option < PlaceTy < ' tcx , Tag > > ,
19
- ret : Option < mir:: BasicBlock > ,
20
- ) -> InterpResult < ' tcx , Option < & ' mir mir:: Body < ' tcx > > > {
21
- let this = self . eval_context_mut ( ) ;
22
- trace ! ( "eval_fn_call: {:#?}, {:?}" , instance, dest. map( |place| * place) ) ;
23
-
24
- // First, run the common hooks also supported by CTFE.
25
- if this. hook_fn ( instance, args, dest) ? {
26
- this. goto_block ( ret) ?;
27
- return Ok ( None ) ;
28
- }
29
- // There are some more lang items we want to hook that CTFE does not hook (yet).
30
- if this. tcx . lang_items ( ) . align_offset_fn ( ) == Some ( instance. def . def_id ( ) ) {
31
- // FIXME: return a real value in case the target allocation has an
32
- // alignment bigger than the one requested.
33
- let n = u128:: max_value ( ) ;
34
- let dest = dest. unwrap ( ) ;
35
- let n = this. truncate ( n, dest. layout ) ;
36
- this. write_scalar ( Scalar :: from_uint ( n, dest. layout . size ) , dest) ?;
37
- this. goto_block ( ret) ?;
38
- return Ok ( None ) ;
39
- }
40
-
41
- // Try to see if we can do something about foreign items.
42
- if this. tcx . is_foreign_item ( instance. def_id ( ) ) {
43
- // An external function that we cannot find MIR for, but we can still run enough
44
- // of them to make miri viable.
45
- this. emulate_foreign_item ( instance. def_id ( ) , args, dest, ret) ?;
46
- // `goto_block` already handled.
47
- return Ok ( None ) ;
48
- }
49
-
50
- // Otherwise, load the MIR.
51
- Ok ( Some ( this. load_mir ( instance. def ) ?) )
52
- }
53
-
54
13
/// Returns the minimum alignment for the target architecture.
55
14
fn min_align ( & self ) -> Align {
56
15
let this = self . eval_context_ref ( ) ;
0 commit comments