Rollup merge of #151465 - RalfJung:fn-call-vars, r=mati865
codegen: clarify some variable names around function calls I looked at rust-lang/rust#145932 to try to understand how it works, and quickly got lost in the variable names -- what refers to the caller, what to the callee? So here's my attempt at making those more clear. Hopefully the new names are correct.^^ Cc @JamieCunliffe
This commit is contained in:
commit
704eaef9d4
3 changed files with 38 additions and 27 deletions
|
|
@ -199,12 +199,12 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'tcx> {
|
|||
// do an invoke, otherwise do a call.
|
||||
let fn_ty = bx.fn_decl_backend_type(fn_abi);
|
||||
|
||||
let fn_attrs = if bx.tcx().def_kind(fx.instance.def_id()).has_codegen_attrs() {
|
||||
let caller_attrs = if bx.tcx().def_kind(fx.instance.def_id()).has_codegen_attrs() {
|
||||
Some(bx.tcx().codegen_instance_attrs(fx.instance.def))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let fn_attrs = fn_attrs.as_deref();
|
||||
let caller_attrs = caller_attrs.as_deref();
|
||||
|
||||
if !fn_abi.can_unwind {
|
||||
unwind = mir::UnwindAction::Unreachable;
|
||||
|
|
@ -233,7 +233,7 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'tcx> {
|
|||
};
|
||||
|
||||
if kind == CallKind::Tail {
|
||||
bx.tail_call(fn_ty, fn_attrs, fn_abi, fn_ptr, llargs, self.funclet(fx), instance);
|
||||
bx.tail_call(fn_ty, caller_attrs, fn_abi, fn_ptr, llargs, self.funclet(fx), instance);
|
||||
return MergingSucc::False;
|
||||
}
|
||||
|
||||
|
|
@ -245,7 +245,7 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'tcx> {
|
|||
};
|
||||
let invokeret = bx.invoke(
|
||||
fn_ty,
|
||||
fn_attrs,
|
||||
caller_attrs,
|
||||
Some(fn_abi),
|
||||
fn_ptr,
|
||||
llargs,
|
||||
|
|
@ -268,8 +268,15 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'tcx> {
|
|||
}
|
||||
MergingSucc::False
|
||||
} else {
|
||||
let llret =
|
||||
bx.call(fn_ty, fn_attrs, Some(fn_abi), fn_ptr, llargs, self.funclet(fx), instance);
|
||||
let llret = bx.call(
|
||||
fn_ty,
|
||||
caller_attrs,
|
||||
Some(fn_abi),
|
||||
fn_ptr,
|
||||
llargs,
|
||||
self.funclet(fx),
|
||||
instance,
|
||||
);
|
||||
if fx.mir[self.bb].is_cleanup {
|
||||
bx.apply_attrs_to_cleanup_callsite(llret);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -600,10 +600,13 @@ pub trait BuilderMethods<'a, 'tcx>:
|
|||
///
|
||||
/// ## Arguments
|
||||
///
|
||||
/// The `fn_attrs`, `fn_abi`, and `instance` arguments are Options because they are advisory.
|
||||
/// They relate to optional codegen enhancements like LLVM CFI, and do not affect ABI per se.
|
||||
/// Any ABI-related transformations should be handled by different, earlier stages of codegen.
|
||||
/// For instance, in the caller of `BuilderMethods::call`.
|
||||
/// `caller_attrs` are the attributes of the surrounding caller; they have nothing to do with
|
||||
/// the callee.
|
||||
///
|
||||
/// The `caller_attrs`, `fn_abi`, and `callee_instance` arguments are Options because they are
|
||||
/// advisory. They relate to optional codegen enhancements like LLVM CFI, and do not affect ABI
|
||||
/// per se. Any ABI-related transformations should be handled by different, earlier stages of
|
||||
/// codegen. For instance, in the caller of `BuilderMethods::call`.
|
||||
///
|
||||
/// This means that a codegen backend which disregards `fn_attrs`, `fn_abi`, and `instance`
|
||||
/// should still do correct codegen, and code should not be miscompiled if they are omitted.
|
||||
|
|
@ -620,23 +623,23 @@ pub trait BuilderMethods<'a, 'tcx>:
|
|||
fn call(
|
||||
&mut self,
|
||||
llty: Self::Type,
|
||||
fn_attrs: Option<&CodegenFnAttrs>,
|
||||
caller_attrs: Option<&CodegenFnAttrs>,
|
||||
fn_abi: Option<&FnAbi<'tcx, Ty<'tcx>>>,
|
||||
fn_val: Self::Value,
|
||||
args: &[Self::Value],
|
||||
funclet: Option<&Self::Funclet>,
|
||||
instance: Option<Instance<'tcx>>,
|
||||
callee_instance: Option<Instance<'tcx>>,
|
||||
) -> Self::Value;
|
||||
|
||||
fn tail_call(
|
||||
&mut self,
|
||||
llty: Self::Type,
|
||||
fn_attrs: Option<&CodegenFnAttrs>,
|
||||
caller_attrs: Option<&CodegenFnAttrs>,
|
||||
fn_abi: &FnAbi<'tcx, Ty<'tcx>>,
|
||||
llfn: Self::Value,
|
||||
args: &[Self::Value],
|
||||
funclet: Option<&Self::Funclet>,
|
||||
instance: Option<Instance<'tcx>>,
|
||||
callee_instance: Option<Instance<'tcx>>,
|
||||
);
|
||||
|
||||
fn zext(&mut self, val: Self::Value, dest_ty: Self::Type) -> Self::Value;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue