提交 99165ce1 编写于 作者: A Adam Perry

Caller location is propagated via immediates rather than memory.

上级 7afbbf7e
......@@ -1016,9 +1016,7 @@ fn get_caller_location(
bx: &mut Bx,
span: Span,
) -> OperandRef<'tcx, Bx::Value> {
if let Some(l) = self.caller_location {
bx.load_operand(l)
} else {
self.caller_location.unwrap_or_else(|| {
let topmost = span.ctxt().outer_expn().expansion_cause().unwrap_or(span);
let caller = bx.tcx().sess.source_map().lookup_char_pos(topmost.lo());
let const_loc = bx.tcx().const_caller_location((
......@@ -1027,7 +1025,7 @@ fn get_caller_location(
caller.col_display as u32 + 1,
));
OperandRef::from_const(bx, const_loc)
}
})
}
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>>>>,
/// 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> {
......@@ -434,10 +434,17 @@ fn arg_local_refs<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
fx.fn_abi.args.len(), args.len() + 1,
"#[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 place = PlaceRef::alloca(bx, arg.layout);
bx.store_fn_arg(arg, &mut llarg_idx, place);
fx.caller_location = Some(place);
match arg.mode {
PassMode::Direct(_) => (),
_ => 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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册