Skip to content

Commit 1c79cf4

Browse files
committed
[OPT] Use RETURN_PLACE instead of fn_sig.output() to get return layout
1 parent 86cdd19 commit 1c79cf4

File tree

2 files changed

+7
-16
lines changed

2 files changed

+7
-16
lines changed

src/abi/mod.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -260,17 +260,6 @@ impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> {
260260
_ => unreachable!(),
261261
}
262262
}
263-
264-
fn self_sig(&self) -> FnSig<'tcx> {
265-
self.tcx.normalize_erasing_late_bound_regions(
266-
ParamEnv::reveal_all(),
267-
&fn_sig_for_fn_abi(self.tcx, self.instance),
268-
)
269-
}
270-
271-
fn return_layout(&self) -> TyLayout<'tcx> {
272-
self.layout_of(self.self_sig().output())
273-
}
274263
}
275264

276265
fn local_place<'tcx>(

src/abi/returning.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
use crate::abi::pass_mode::*;
22
use crate::prelude::*;
33

4+
fn return_layout<'a, 'tcx>(fx: &mut FunctionCx<'a, 'tcx, impl Backend>) -> TyLayout<'tcx> {
5+
fx.layout_of(fx.monomorphize(&fx.mir.local_decls[RETURN_PLACE].ty))
6+
}
7+
48
pub fn codegen_return_param(
59
fx: &mut FunctionCx<impl Backend>,
610
ssa_analyzed: &rustc_index::vec::IndexVec<Local, crate::analyze::SsaKind>,
711
start_ebb: Ebb,
812
) {
9-
let ret_layout = fx.return_layout();
10-
let output_pass_mode = get_pass_mode(fx.tcx, fx.return_layout());
11-
12-
let ret_param = match output_pass_mode {
13+
let ret_layout = return_layout(fx);
14+
let ret_param = match get_pass_mode(fx.tcx, ret_layout) {
1315
PassMode::NoPass => {
1416
fx.local_map
1517
.insert(RETURN_PLACE, CPlace::no_place(ret_layout));
@@ -85,7 +87,7 @@ pub fn codegen_with_call_return_arg<'tcx, B: Backend, T>(
8587
}
8688

8789
pub fn codegen_return(fx: &mut FunctionCx<impl Backend>) {
88-
match get_pass_mode(fx.tcx, fx.return_layout()) {
90+
match get_pass_mode(fx.tcx, return_layout(fx)) {
8991
PassMode::NoPass | PassMode::ByRef => {
9092
fx.bcx.ins().return_(&[]);
9193
}

0 commit comments

Comments
 (0)