Skip to content

Commit dc72692

Browse files
committed
Add tracing to various miscellaneous functions
Also use tracing macro syntax instead of format()
1 parent a153133 commit dc72692

File tree

5 files changed

+15
-5
lines changed

5 files changed

+15
-5
lines changed

compiler/rustc_const_eval/src/interpret/eval_context.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
325325
let _span = enter_trace_span!(
326326
M,
327327
"instantiate_from_frame_and_normalize_erasing_regions",
328-
"{}",
329-
frame.instance
328+
%frame.instance
330329
);
331330
frame
332331
.instance
@@ -582,6 +581,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
582581
span: Span,
583582
layout: Option<TyAndLayout<'tcx>>,
584583
) -> InterpResult<'tcx, OpTy<'tcx, M::Provenance>> {
584+
let _trace = enter_trace_span!(M, const_eval::eval_mir_constant, ?val);
585585
let const_val = val.eval(*self.tcx, self.typing_env, span).map_err(|err| {
586586
if M::ALL_CONSTS_ARE_PRECHECKED {
587587
match err {

compiler/rustc_const_eval/src/interpret/stack.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use super::{
2020
MemoryKind, Operand, PlaceTy, Pointer, Provenance, ReturnAction, Scalar, from_known_layout,
2121
interp_ok, throw_ub, throw_unsup,
2222
};
23-
use crate::errors;
23+
use crate::{enter_trace_span, errors};
2424

2525
// The Phantomdata exists to prevent this type from being `Send`. If it were sent across a thread
2626
// boundary and dropped in the other thread, it would exit the span in the other thread.
@@ -386,6 +386,9 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
386386

387387
// Make sure all the constants required by this frame evaluate successfully (post-monomorphization check).
388388
for &const_ in body.required_consts() {
389+
// We can't use `eval_mir_constant` here as that assumes that all required consts have
390+
// already been checked, so we need a separate tracing call.
391+
let _trace = enter_trace_span!(M, const_eval::required_consts, ?const_.const_);
389392
let c =
390393
self.instantiate_from_current_frame_and_normalize_erasing_regions(const_.const_)?;
391394
c.eval(*self.tcx, self.typing_env, const_.span).map_err(|err| {

compiler/rustc_const_eval/src/interpret/step.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,10 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
436436
.map(|arg| self.eval_fn_call_argument(&arg.node))
437437
.collect::<InterpResult<'tcx, Vec<_>>>()?;
438438

439-
let fn_sig_binder = func.layout.ty.fn_sig(*self.tcx);
439+
let fn_sig_binder = {
440+
let _trace = enter_trace_span!(M, "fn_sig", ty = ?func.layout.ty.kind());
441+
func.layout.ty.fn_sig(*self.tcx)
442+
};
440443
let fn_sig = self.tcx.normalize_erasing_late_bound_regions(self.typing_env, fn_sig_binder);
441444
let extra_args = &args[fn_sig.inputs().len()..];
442445
let extra_args =

compiler/rustc_const_eval/src/interpret/validity.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1418,7 +1418,9 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
14181418
let _span = enter_trace_span!(
14191419
M,
14201420
"validate_operand",
1421-
"recursive={recursive}, reset_provenance_and_padding={reset_provenance_and_padding}, val={val:?}"
1421+
recursive,
1422+
reset_provenance_and_padding,
1423+
?val,
14221424
);
14231425

14241426
// Note that we *could* actually be in CTFE here with `-Zextra-const-ub-checks`, but it's

src/tools/miri/src/machine.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,6 +1111,7 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> {
11111111
) -> InterpResult<'tcx, Option<(&'tcx mir::Body<'tcx>, ty::Instance<'tcx>)>> {
11121112
// For foreign items, try to see if we can emulate them.
11131113
if ecx.tcx.is_foreign_item(instance.def_id()) {
1114+
let _trace = enter_trace_span!("emulate_foreign_item");
11141115
// An external function call that does not have a MIR body. We either find MIR elsewhere
11151116
// or emulate its effect.
11161117
// This will be Ok(None) if we're emulating the intrinsic entirely within Miri (no need
@@ -1123,6 +1124,7 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> {
11231124
}
11241125

11251126
// Otherwise, load the MIR.
1127+
let _trace = enter_trace_span!("load_mir");
11261128
interp_ok(Some((ecx.load_mir(instance.def, None)?, instance)))
11271129
}
11281130

0 commit comments

Comments
 (0)