@@ -23,7 +23,6 @@ use rustc_middle::{mir, ty};
23
23
use rustc_target:: spec:: abi:: Abi ;
24
24
25
25
use crate :: * ;
26
- use helpers:: check_arg_count;
27
26
28
27
impl < ' mir , ' tcx : ' mir > EvalContextExt < ' mir , ' tcx > for crate :: MiriInterpCx < ' mir , ' tcx > { }
29
28
pub trait EvalContextExt < ' mir , ' tcx : ' mir > : crate :: MiriInterpCxExt < ' mir , ' tcx > {
@@ -39,16 +38,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
39
38
let this = self . eval_context_mut ( ) ;
40
39
trace ! ( "eval_fn_call: {:#?}, {:?}" , instance, dest) ;
41
40
42
- // There are some more lang items we want to hook that CTFE does not hook (yet).
43
- if this. tcx . lang_items ( ) . align_offset_fn ( ) == Some ( instance. def . def_id ( ) ) {
44
- let args = this. copy_fn_args ( args) ?;
45
- let [ ptr, align] = check_arg_count ( & args) ?;
46
- if this. align_offset ( ptr, align, dest, ret, unwind) ? {
47
- return Ok ( None ) ;
48
- }
49
- }
50
-
51
- // Try to see if we can do something about foreign items.
41
+ // For foreign items, try to see if we can emulate them.
52
42
if this. tcx . is_foreign_item ( instance. def_id ( ) ) {
53
43
// An external function call that does not have a MIR body. We either find MIR elsewhere
54
44
// or emulate its effect.
@@ -64,53 +54,4 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
64
54
// Otherwise, load the MIR.
65
55
Ok ( Some ( ( this. load_mir ( instance. def , None ) ?, instance) ) )
66
56
}
67
-
68
- /// Returns `true` if the computation was performed, and `false` if we should just evaluate
69
- /// the actual MIR of `align_offset`.
70
- fn align_offset (
71
- & mut self ,
72
- ptr_op : & OpTy < ' tcx , Provenance > ,
73
- align_op : & OpTy < ' tcx , Provenance > ,
74
- dest : & PlaceTy < ' tcx , Provenance > ,
75
- ret : Option < mir:: BasicBlock > ,
76
- unwind : mir:: UnwindAction ,
77
- ) -> InterpResult < ' tcx , bool > {
78
- let this = self . eval_context_mut ( ) ;
79
- let ret = ret. unwrap ( ) ;
80
-
81
- if this. machine . check_alignment != AlignmentCheck :: Symbolic {
82
- // Just use actual implementation.
83
- return Ok ( false ) ;
84
- }
85
-
86
- let req_align = this. read_target_usize ( align_op) ?;
87
-
88
- // Stop if the alignment is not a power of two.
89
- if !req_align. is_power_of_two ( ) {
90
- this. start_panic ( "align_offset: align is not a power-of-two" , unwind) ?;
91
- return Ok ( true ) ; // nothing left to do
92
- }
93
-
94
- let ptr = this. read_pointer ( ptr_op) ?;
95
- // If this carries no provenance, treat it like an integer.
96
- if ptr. provenance . is_none ( ) {
97
- // Use actual implementation.
98
- return Ok ( false ) ;
99
- }
100
-
101
- if let Ok ( ( alloc_id, _offset, _) ) = this. ptr_try_get_alloc_id ( ptr) {
102
- // Only do anything if we can identify the allocation this goes to.
103
- let ( _size, cur_align, _kind) = this. get_alloc_info ( alloc_id) ;
104
- if cur_align. bytes ( ) >= req_align {
105
- // If the allocation alignment is at least the required alignment we use the
106
- // real implementation.
107
- return Ok ( false ) ;
108
- }
109
- }
110
-
111
- // Return error result (usize::MAX), and jump to caller.
112
- this. write_scalar ( Scalar :: from_target_usize ( this. target_usize_max ( ) , this) , dest) ?;
113
- this. go_to_block ( ret) ;
114
- Ok ( true )
115
- }
116
57
}
0 commit comments