Caller location is propagated via immediates rather than memory.
This commit is contained in:
parent
7afbbf7e8a
commit
99165ce1f7
2 changed files with 13 additions and 8 deletions
|
@ -1016,9 +1016,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||||
bx: &mut Bx,
|
bx: &mut Bx,
|
||||||
span: Span,
|
span: Span,
|
||||||
) -> OperandRef<'tcx, Bx::Value> {
|
) -> OperandRef<'tcx, Bx::Value> {
|
||||||
if let Some(l) = self.caller_location {
|
self.caller_location.unwrap_or_else(|| {
|
||||||
bx.load_operand(l)
|
|
||||||
} else {
|
|
||||||
let topmost = span.ctxt().outer_expn().expansion_cause().unwrap_or(span);
|
let topmost = span.ctxt().outer_expn().expansion_cause().unwrap_or(span);
|
||||||
let caller = bx.tcx().sess.source_map().lookup_char_pos(topmost.lo());
|
let caller = bx.tcx().sess.source_map().lookup_char_pos(topmost.lo());
|
||||||
let const_loc = bx.tcx().const_caller_location((
|
let const_loc = bx.tcx().const_caller_location((
|
||||||
|
@ -1027,7 +1025,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||||
caller.col_display as u32 + 1,
|
caller.col_display as u32 + 1,
|
||||||
));
|
));
|
||||||
OperandRef::from_const(bx, const_loc)
|
OperandRef::from_const(bx, const_loc)
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_personality_slot(
|
fn get_personality_slot(
|
||||||
|
|
|
@ -79,7 +79,7 @@ pub struct FunctionCx<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> {
|
||||||
per_local_var_debug_info: Option<IndexVec<mir::Local, Vec<&'tcx mir::VarDebugInfo<'tcx>>>>,
|
per_local_var_debug_info: Option<IndexVec<mir::Local, Vec<&'tcx mir::VarDebugInfo<'tcx>>>>,
|
||||||
|
|
||||||
/// Caller location propagated if this function has `#[track_caller]`.
|
/// Caller location propagated if this function has `#[track_caller]`.
|
||||||
caller_location: Option<PlaceRef<'tcx, Bx::Value>>,
|
caller_location: Option<OperandRef<'tcx, Bx::Value>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||||
|
@ -434,10 +434,17 @@ fn arg_local_refs<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||||
fx.fn_abi.args.len(), args.len() + 1,
|
fx.fn_abi.args.len(), args.len() + 1,
|
||||||
"#[track_caller] fn's must have 1 more argument in their ABI than in their MIR",
|
"#[track_caller] fn's must have 1 more argument in their ABI than in their MIR",
|
||||||
);
|
);
|
||||||
|
|
||||||
let arg = &fx.fn_abi.args.last().unwrap();
|
let arg = &fx.fn_abi.args.last().unwrap();
|
||||||
let place = PlaceRef::alloca(bx, arg.layout);
|
match arg.mode {
|
||||||
bx.store_fn_arg(arg, &mut llarg_idx, place);
|
PassMode::Direct(_) => (),
|
||||||
fx.caller_location = Some(place);
|
_ => panic!("caller location must be PassMode::Direct, found {:?}", arg.mode),
|
||||||
|
}
|
||||||
|
|
||||||
|
fx.caller_location = Some(OperandRef {
|
||||||
|
val: OperandValue::Immediate(bx.get_param(llarg_idx)),
|
||||||
|
layout: arg.layout,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
args
|
args
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue