@@ -82,27 +82,7 @@ pub(crate) fn codegen_fn<'tcx>(
82
82
next_ssa_var : 0 ,
83
83
} ;
84
84
85
- let arg_uninhabited = fx
86
- . mir
87
- . args_iter ( )
88
- . any ( |arg| fx. layout_of ( fx. monomorphize ( fx. mir . local_decls [ arg] . ty ) ) . abi . is_uninhabited ( ) ) ;
89
-
90
- if !crate :: constant:: check_constants ( & mut fx) {
91
- fx. bcx . append_block_params_for_function_params ( fx. block_map [ START_BLOCK ] ) ;
92
- fx. bcx . switch_to_block ( fx. block_map [ START_BLOCK ] ) ;
93
- // compilation should have been aborted
94
- fx. bcx . ins ( ) . trap ( TrapCode :: UnreachableCodeReached ) ;
95
- } else if arg_uninhabited {
96
- fx. bcx . append_block_params_for_function_params ( fx. block_map [ START_BLOCK ] ) ;
97
- fx. bcx . switch_to_block ( fx. block_map [ START_BLOCK ] ) ;
98
- fx. bcx . ins ( ) . trap ( TrapCode :: UnreachableCodeReached ) ;
99
- } else {
100
- tcx. sess . time ( "codegen clif ir" , || {
101
- tcx. sess
102
- . time ( "codegen prelude" , || crate :: abi:: codegen_fn_prelude ( & mut fx, start_block) ) ;
103
- codegen_fn_content ( & mut fx) ;
104
- } ) ;
105
- }
85
+ tcx. sess . time ( "codegen clif ir" , || codegen_fn_body ( & mut fx, start_block) ) ;
106
86
107
87
// Recover all necessary data from fx, before accessing func will prevent future access to it.
108
88
let instance = fx. instance ;
@@ -269,7 +249,27 @@ pub(crate) fn verify_func(
269
249
} ) ;
270
250
}
271
251
272
- fn codegen_fn_content ( fx : & mut FunctionCx < ' _ , ' _ , ' _ > ) {
252
+ fn codegen_fn_body ( fx : & mut FunctionCx < ' _ , ' _ , ' _ > , start_block : Block ) {
253
+ if !crate :: constant:: check_constants ( fx) {
254
+ fx. bcx . append_block_params_for_function_params ( fx. block_map [ START_BLOCK ] ) ;
255
+ fx. bcx . switch_to_block ( fx. block_map [ START_BLOCK ] ) ;
256
+ // compilation should have been aborted
257
+ fx. bcx . ins ( ) . trap ( TrapCode :: UnreachableCodeReached ) ;
258
+ return ;
259
+ }
260
+
261
+ let arg_uninhabited = fx
262
+ . mir
263
+ . args_iter ( )
264
+ . any ( |arg| fx. layout_of ( fx. monomorphize ( fx. mir . local_decls [ arg] . ty ) ) . abi . is_uninhabited ( ) ) ;
265
+ if arg_uninhabited {
266
+ fx. bcx . append_block_params_for_function_params ( fx. block_map [ START_BLOCK ] ) ;
267
+ fx. bcx . switch_to_block ( fx. block_map [ START_BLOCK ] ) ;
268
+ fx. bcx . ins ( ) . trap ( TrapCode :: UnreachableCodeReached ) ;
269
+ return ;
270
+ }
271
+ fx. tcx . sess . time ( "codegen prelude" , || crate :: abi:: codegen_fn_prelude ( fx, start_block) ) ;
272
+
273
273
for ( bb, bb_data) in fx. mir . basic_blocks ( ) . iter_enumerated ( ) {
274
274
let block = fx. get_block ( bb) ;
275
275
fx. bcx . switch_to_block ( block) ;
0 commit comments