Skip to content

Commit fee1204

Browse files
committed
Stop taking FunctionCx's fn_abi field
1 parent 69363cf commit fee1204

File tree

4 files changed

+11
-26
lines changed

4 files changed

+11
-26
lines changed

src/abi/mod.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -222,17 +222,15 @@ pub(crate) fn codegen_fn_prelude<'tcx>(fx: &mut FunctionCx<'_, '_, 'tcx>, start_
222222
Spread(Vec<Option<CValue<'tcx>>>),
223223
}
224224

225-
let fn_abi = fx.fn_abi.take().unwrap();
226-
227225
// FIXME implement variadics in cranelift
228-
if fn_abi.c_variadic {
226+
if fx.fn_abi.c_variadic {
229227
fx.tcx.dcx().span_fatal(
230228
fx.mir.span,
231229
"Defining variadic functions is not yet supported by Cranelift",
232230
);
233231
}
234232

235-
let mut arg_abis_iter = fn_abi.args.iter();
233+
let mut arg_abis_iter = fx.fn_abi.args.iter();
236234

237235
let func_params = fx
238236
.mir
@@ -279,7 +277,6 @@ pub(crate) fn codegen_fn_prelude<'tcx>(fx: &mut FunctionCx<'_, '_, 'tcx>, start_
279277
}
280278

281279
assert!(arg_abis_iter.next().is_none(), "ArgAbi left behind");
282-
fx.fn_abi = Some(fn_abi);
283280
assert!(block_params_iter.next().is_none(), "arg_value left behind");
284281

285282
self::comments::add_locals_header_comment(fx);

src/abi/returning.rs

+7-19
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,15 @@ pub(super) fn codegen_return_param<'tcx>(
1212
ssa_analyzed: &rustc_index::IndexSlice<Local, crate::analyze::SsaKind>,
1313
block_params_iter: &mut impl Iterator<Item = Value>,
1414
) -> CPlace<'tcx> {
15-
let (ret_place, ret_param): (_, SmallVec<[_; 2]>) = match fx.fn_abi.as_ref().unwrap().ret.mode {
15+
let (ret_place, ret_param): (_, SmallVec<[_; 2]>) = match fx.fn_abi.ret.mode {
1616
PassMode::Ignore | PassMode::Direct(_) | PassMode::Pair(_, _) | PassMode::Cast { .. } => {
17-
let is_ssa =
18-
ssa_analyzed[RETURN_PLACE].is_ssa(fx, fx.fn_abi.as_ref().unwrap().ret.layout.ty);
19-
(
20-
super::make_local_place(
21-
fx,
22-
RETURN_PLACE,
23-
fx.fn_abi.as_ref().unwrap().ret.layout,
24-
is_ssa,
25-
),
26-
smallvec![],
27-
)
17+
let is_ssa = ssa_analyzed[RETURN_PLACE].is_ssa(fx, fx.fn_abi.ret.layout.ty);
18+
(super::make_local_place(fx, RETURN_PLACE, fx.fn_abi.ret.layout, is_ssa), smallvec![])
2819
}
2920
PassMode::Indirect { attrs: _, meta_attrs: None, on_stack: _ } => {
3021
let ret_param = block_params_iter.next().unwrap();
3122
assert_eq!(fx.bcx.func.dfg.value_type(ret_param), fx.pointer_type);
32-
(
33-
CPlace::for_ptr(Pointer::new(ret_param), fx.fn_abi.as_ref().unwrap().ret.layout),
34-
smallvec![ret_param],
35-
)
23+
(CPlace::for_ptr(Pointer::new(ret_param), fx.fn_abi.ret.layout), smallvec![ret_param])
3624
}
3725
PassMode::Indirect { attrs: _, meta_attrs: Some(_), on_stack: _ } => {
3826
unreachable!("unsized return value")
@@ -45,8 +33,8 @@ pub(super) fn codegen_return_param<'tcx>(
4533
Some(RETURN_PLACE),
4634
None,
4735
&ret_param,
48-
&fx.fn_abi.as_ref().unwrap().ret.mode,
49-
fx.fn_abi.as_ref().unwrap().ret.layout,
36+
&fx.fn_abi.ret.mode,
37+
fx.fn_abi.ret.layout,
5038
);
5139

5240
ret_place
@@ -115,7 +103,7 @@ pub(super) fn codegen_with_call_return_arg<'tcx>(
115103

116104
/// Codegen a return instruction with the right return value(s) if any.
117105
pub(crate) fn codegen_return(fx: &mut FunctionCx<'_, '_, '_>) {
118-
match fx.fn_abi.as_ref().unwrap().ret.mode {
106+
match fx.fn_abi.ret.mode {
119107
PassMode::Ignore | PassMode::Indirect { attrs: _, meta_attrs: None, on_stack: _ } => {
120108
fx.bcx.ins().return_(&[]);
121109
}

src/base.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ pub(crate) fn codegen_fn<'tcx>(
8787
instance,
8888
symbol_name,
8989
mir,
90-
fn_abi: Some(RevealAllLayoutCx(tcx).fn_abi_of_instance(instance, ty::List::empty())),
90+
fn_abi: RevealAllLayoutCx(tcx).fn_abi_of_instance(instance, ty::List::empty()),
9191

9292
bcx,
9393
block_map,

src/common.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ pub(crate) struct FunctionCx<'m, 'clif, 'tcx: 'm> {
291291
pub(crate) instance: Instance<'tcx>,
292292
pub(crate) symbol_name: String,
293293
pub(crate) mir: &'tcx Body<'tcx>,
294-
pub(crate) fn_abi: Option<&'tcx FnAbi<'tcx, Ty<'tcx>>>,
294+
pub(crate) fn_abi: &'tcx FnAbi<'tcx, Ty<'tcx>>,
295295

296296
pub(crate) bcx: FunctionBuilder<'clif>,
297297
pub(crate) block_map: IndexVec<BasicBlock, Block>,

0 commit comments

Comments
 (0)