Skip to content

Commit 8256a75

Browse files
Rollup merge of rust-lang#143051 - Stypox:tracing-validity, r=RalfJung
Add tracing to `validate_operand` This PR adds a tracing call to keep track of how much time is spent in `validate_operand` and `const_validate_operand`. Let me know if more fine-grained tracing is needed (e.g. adding tracing to `validate_operand_internal` too, which is just called from those two functions). I also fixed the rustdoc of `validate_operand` and `const_validate_operand` since it was referencing an older name for the `val` parameter which was renamed in cbdcbf0. Here is some tracing output when Miri is run on `src/tools/miri/tests/pass/hello.rs`, visualizable in [ui.perfetto.dev](https://ui.perfetto.dev/): [trace-1750932222218210.json](https://github.com/user-attachments/files/20924000/trace-1750932222218210.json) **Note: obtaining tracing output depends on rust-lang/miri#4406, but this PR is standalone and can be merged without waiting for rust-lang/miri#4406 r? `@RalfJung`
2 parents 599a061 + 89a636f commit 8256a75

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

compiler/rustc_const_eval/src/interpret/validity.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ use super::{
3535
Machine, MemPlaceMeta, PlaceTy, Pointer, Projectable, Scalar, ValueVisitor, err_ub,
3636
format_interp_error,
3737
};
38+
use crate::enter_trace_span;
3839

3940
// for the validation errors
4041
#[rustfmt::skip]
@@ -1363,8 +1364,8 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
13631364
})
13641365
}
13651366

1366-
/// This function checks the data at `op` to be const-valid.
1367-
/// `op` is assumed to cover valid memory if it is an indirect operand.
1367+
/// This function checks the data at `val` to be const-valid.
1368+
/// `val` is assumed to cover valid memory if it is an indirect operand.
13681369
/// It will error if the bits at the destination do not match the ones described by the layout.
13691370
///
13701371
/// `ref_tracking` is used to record references that we encounter so that they
@@ -1390,8 +1391,8 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
13901391
)
13911392
}
13921393

1393-
/// This function checks the data at `op` to be runtime-valid.
1394-
/// `op` is assumed to cover valid memory if it is an indirect operand.
1394+
/// This function checks the data at `val` to be runtime-valid.
1395+
/// `val` is assumed to cover valid memory if it is an indirect operand.
13951396
/// It will error if the bits at the destination do not match the ones described by the layout.
13961397
#[inline(always)]
13971398
pub fn validate_operand(
@@ -1400,6 +1401,12 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
14001401
recursive: bool,
14011402
reset_provenance_and_padding: bool,
14021403
) -> InterpResult<'tcx> {
1404+
let _span = enter_trace_span!(
1405+
M,
1406+
"validate_operand",
1407+
"recursive={recursive}, reset_provenance_and_padding={reset_provenance_and_padding}, val={val:?}"
1408+
);
1409+
14031410
// Note that we *could* actually be in CTFE here with `-Zextra-const-ub-checks`, but it's
14041411
// still correct to not use `ctfe_mode`: that mode is for validation of the final constant
14051412
// value, it rules out things like `UnsafeCell` in awkward places.

0 commit comments

Comments
 (0)