Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit a7443a6

Browse files
committed
Move some code into codegen_fn_content
1 parent fa6480e commit a7443a6

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

src/base.rs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -82,27 +82,7 @@ pub(crate) fn codegen_fn<'tcx>(
8282
next_ssa_var: 0,
8383
};
8484

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));
10686

10787
// Recover all necessary data from fx, before accessing func will prevent future access to it.
10888
let instance = fx.instance;
@@ -269,7 +249,27 @@ pub(crate) fn verify_func(
269249
});
270250
}
271251

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+
273273
for (bb, bb_data) in fx.mir.basic_blocks().iter_enumerated() {
274274
let block = fx.get_block(bb);
275275
fx.bcx.switch_to_block(block);

0 commit comments

Comments
 (0)