@@ -6,8 +6,11 @@ use rustc_index::vec::IndexVec;
6
6
use rustc_middle:: ty:: adjustment:: PointerCast ;
7
7
use rustc_middle:: ty:: layout:: FnAbiOf ;
8
8
9
+ use indexmap:: IndexSet ;
10
+
9
11
use crate :: constant:: ConstantCx ;
10
12
use crate :: prelude:: * ;
13
+ use crate :: pretty_clif:: CommentWriter ;
11
14
12
15
pub ( crate ) fn codegen_fn < ' tcx > (
13
16
cx : & mut crate :: CodegenCx < ' tcx > ,
@@ -99,7 +102,7 @@ pub(crate) fn codegen_fn<'tcx>(
99
102
100
103
// Recover all necessary data from fx, before accessing func will prevent future access to it.
101
104
let instance = fx. instance ;
102
- let mut clif_comments = fx. clif_comments ;
105
+ let clif_comments = fx. clif_comments ;
103
106
let source_info_set = fx. source_info_set ;
104
107
let local_map = fx. local_map ;
105
108
@@ -114,13 +117,40 @@ pub(crate) fn codegen_fn<'tcx>(
114
117
& clif_comments,
115
118
) ;
116
119
120
+ // Verify function
121
+ verify_func ( tcx, & clif_comments, & func) ;
122
+
123
+ compile_fn (
124
+ cx,
125
+ module,
126
+ instance,
127
+ symbol_name. name ,
128
+ func_id,
129
+ func,
130
+ clif_comments,
131
+ source_info_set,
132
+ local_map,
133
+ ) ;
134
+ }
135
+
136
+ fn compile_fn < ' tcx > (
137
+ cx : & mut crate :: CodegenCx < ' tcx > ,
138
+ module : & mut dyn Module ,
139
+ instance : Instance < ' tcx > ,
140
+ symbol_name : & str ,
141
+ func_id : FuncId ,
142
+ func : Function ,
143
+ mut clif_comments : CommentWriter ,
144
+ source_info_set : IndexSet < SourceInfo > ,
145
+ local_map : IndexVec < mir:: Local , CPlace < ' tcx > > ,
146
+ ) {
147
+ let tcx = cx. tcx ;
148
+
117
149
// Store function in context
118
150
let context = & mut cx. cached_context ;
151
+ context. clear ( ) ;
119
152
context. func = func;
120
153
121
- // Verify function
122
- verify_func ( tcx, & clif_comments, & context. func ) ;
123
-
124
154
// If the return block is not reachable, then the SSA builder may have inserted an `iconst.i128`
125
155
// instruction, which doesn't have an encoding.
126
156
context. compute_cfg ( ) ;
@@ -177,7 +207,7 @@ pub(crate) fn codegen_fn<'tcx>(
177
207
debug_context. define_function (
178
208
instance,
179
209
func_id,
180
- symbol_name. name ,
210
+ symbol_name,
181
211
isa,
182
212
context,
183
213
& source_info_set,
@@ -186,9 +216,6 @@ pub(crate) fn codegen_fn<'tcx>(
186
216
}
187
217
unwind_context. add_function ( func_id, & context, isa) ;
188
218
} ) ;
189
-
190
- // Clear context to make it usable for the next function
191
- context. clear ( ) ;
192
219
}
193
220
194
221
pub ( crate ) fn verify_func (
0 commit comments