Skip to content

Commit 99165ce

Browse files
committed
Caller location is propagated via immediates rather than memory.
1 parent 7afbbf7 commit 99165ce

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

src/librustc_codegen_ssa/mir/block.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -1016,9 +1016,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
10161016
bx: &mut Bx,
10171017
span: Span,
10181018
) -> OperandRef<'tcx, Bx::Value> {
1019-
if let Some(l) = self.caller_location {
1020-
bx.load_operand(l)
1021-
} else {
1019+
self.caller_location.unwrap_or_else(|| {
10221020
let topmost = span.ctxt().outer_expn().expansion_cause().unwrap_or(span);
10231021
let caller = bx.tcx().sess.source_map().lookup_char_pos(topmost.lo());
10241022
let const_loc = bx.tcx().const_caller_location((
@@ -1027,7 +1025,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
10271025
caller.col_display as u32 + 1,
10281026
));
10291027
OperandRef::from_const(bx, const_loc)
1030-
}
1028+
})
10311029
}
10321030

10331031
fn get_personality_slot(

src/librustc_codegen_ssa/mir/mod.rs

+11-4
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ pub struct FunctionCx<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> {
7979
per_local_var_debug_info: Option<IndexVec<mir::Local, Vec<&'tcx mir::VarDebugInfo<'tcx>>>>,
8080

8181
/// Caller location propagated if this function has `#[track_caller]`.
82-
caller_location: Option<PlaceRef<'tcx, Bx::Value>>,
82+
caller_location: Option<OperandRef<'tcx, Bx::Value>>,
8383
}
8484

8585
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>>(
434434
fx.fn_abi.args.len(), args.len() + 1,
435435
"#[track_caller] fn's must have 1 more argument in their ABI than in their MIR",
436436
);
437+
437438
let arg = &fx.fn_abi.args.last().unwrap();
438-
let place = PlaceRef::alloca(bx, arg.layout);
439-
bx.store_fn_arg(arg, &mut llarg_idx, place);
440-
fx.caller_location = Some(place);
439+
match arg.mode {
440+
PassMode::Direct(_) => (),
441+
_ => panic!("caller location must be PassMode::Direct, found {:?}", arg.mode),
442+
}
443+
444+
fx.caller_location = Some(OperandRef {
445+
val: OperandValue::Immediate(bx.get_param(llarg_idx)),
446+
layout: arg.layout,
447+
});
441448
}
442449

443450
args

0 commit comments

Comments
 (0)