Skip to content

Commit 6490878

Browse files
committed
Add tracing to more functions related to step.rs
1 parent 22479ca commit 6490878

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

compiler/rustc_const_eval/src/interpret/call.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@ use rustc_middle::ty::{self, AdtDef, Instance, Ty, VariantDef};
1111
use rustc_middle::{bug, mir, span_bug};
1212
use rustc_span::sym;
1313
use rustc_target::callconv::{ArgAbi, FnAbi, PassMode};
14+
use tracing::field::Empty;
1415
use tracing::{info, instrument, trace};
1516

1617
use super::{
1718
CtfeProvenance, FnVal, ImmTy, InterpCx, InterpResult, MPlaceTy, Machine, OpTy, PlaceTy,
1819
Projectable, Provenance, ReturnAction, ReturnContinuation, Scalar, StackPopInfo, interp_ok,
1920
throw_ub, throw_ub_custom, throw_unsup_format,
2021
};
21-
use crate::fluent_generated as fluent;
22+
use crate::{enter_trace_span, fluent_generated as fluent};
2223

2324
/// An argument passed to a function.
2425
#[derive(Clone, Debug)]
@@ -344,6 +345,8 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
344345
destination: &PlaceTy<'tcx, M::Provenance>,
345346
mut cont: ReturnContinuation,
346347
) -> InterpResult<'tcx> {
348+
let _span = enter_trace_span!(M, step::init_stack_frame, %instance, tracing_separate_thread = Empty);
349+
347350
// Compute callee information.
348351
// FIXME: for variadic support, do we have to somehow determine callee's extra_args?
349352
let callee_fn_abi = self.fn_abi_of_instance(instance, ty::List::empty())?;
@@ -523,6 +526,8 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
523526
target: Option<mir::BasicBlock>,
524527
unwind: mir::UnwindAction,
525528
) -> InterpResult<'tcx> {
529+
let _span =
530+
enter_trace_span!(M, step::init_fn_call, tracing_separate_thread = Empty, ?fn_val);
526531
trace!("init_fn_call: {:#?}", fn_val);
527532

528533
let instance = match fn_val {

compiler/rustc_const_eval/src/interpret/operand.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@ use rustc_middle::ty::print::{FmtPrinter, PrettyPrinter};
1313
use rustc_middle::ty::{ConstInt, ScalarInt, Ty, TyCtxt};
1414
use rustc_middle::{bug, mir, span_bug, ty};
1515
use rustc_span::DUMMY_SP;
16+
use tracing::field::Empty;
1617
use tracing::trace;
1718

1819
use super::{
1920
CtfeProvenance, Frame, InterpCx, InterpResult, MPlaceTy, Machine, MemPlace, MemPlaceMeta,
2021
OffsetMode, PlaceTy, Pointer, Projectable, Provenance, Scalar, alloc_range, err_ub,
2122
from_known_layout, interp_ok, mir_assign_valid_types, throw_ub,
2223
};
24+
use crate::enter_trace_span;
2325

2426
/// An `Immediate` represents a single immediate self-contained Rust value.
2527
///
@@ -770,6 +772,13 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
770772
mir_place: mir::Place<'tcx>,
771773
layout: Option<TyAndLayout<'tcx>>,
772774
) -> InterpResult<'tcx, OpTy<'tcx, M::Provenance>> {
775+
let _span = enter_trace_span!(
776+
M,
777+
step::eval_place_to_op,
778+
?mir_place,
779+
tracing_separate_thread = Empty
780+
);
781+
773782
// Do not use the layout passed in as argument if the base we are looking at
774783
// here is not the entire place.
775784
let layout = if mir_place.projection.is_empty() { layout } else { None };
@@ -813,6 +822,9 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
813822
mir_op: &mir::Operand<'tcx>,
814823
layout: Option<TyAndLayout<'tcx>>,
815824
) -> InterpResult<'tcx, OpTy<'tcx, M::Provenance>> {
825+
let _span =
826+
enter_trace_span!(M, step::eval_operand, ?mir_op, tracing_separate_thread = Empty);
827+
816828
use rustc_middle::mir::Operand::*;
817829
let op = match mir_op {
818830
// FIXME: do some more logic on `move` to invalidate the old location

compiler/rustc_const_eval/src/interpret/place.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@ use rustc_abi::{BackendRepr, HasDataLayout, Size};
99
use rustc_middle::ty::Ty;
1010
use rustc_middle::ty::layout::TyAndLayout;
1111
use rustc_middle::{bug, mir, span_bug};
12+
use tracing::field::Empty;
1213
use tracing::{instrument, trace};
1314

1415
use super::{
1516
AllocInit, AllocRef, AllocRefMut, CheckAlignMsg, CtfeProvenance, ImmTy, Immediate, InterpCx,
1617
InterpResult, Machine, MemoryKind, Misalignment, OffsetMode, OpTy, Operand, Pointer,
1718
Projectable, Provenance, Scalar, alloc_range, interp_ok, mir_assign_valid_types,
1819
};
20+
use crate::enter_trace_span;
1921

2022
#[derive(Copy, Clone, Hash, PartialEq, Eq, Debug)]
2123
/// Information required for the sound usage of a `MemPlace`.
@@ -524,6 +526,9 @@ where
524526
&self,
525527
mir_place: mir::Place<'tcx>,
526528
) -> InterpResult<'tcx, PlaceTy<'tcx, M::Provenance>> {
529+
let _span =
530+
enter_trace_span!(M, step::eval_place, ?mir_place, tracing_separate_thread = Empty);
531+
527532
let mut place = self.local_to_place(mir_place.local)?;
528533
// Using `try_fold` turned out to be bad for performance, hence the loop.
529534
for elem in mir_place.projection.iter() {

0 commit comments

Comments
 (0)