Skip to content

Commit 6c06cf4

Browse files
committed
Revert "Add a load of debug logging around ConstProp"
This reverts commit aef5074.
1 parent a95ffcf commit 6c06cf4

File tree

2 files changed

+5
-34
lines changed

2 files changed

+5
-34
lines changed

compiler/rustc_const_eval/src/interpret/operand.rs

-3
Original file line numberDiff line numberDiff line change
@@ -623,15 +623,13 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
623623
///
624624
/// This is public because it is used by [priroda](https://github.com/oli-obk/priroda) to get an
625625
/// OpTy from a local.
626-
#[instrument(skip(self, layout, frame))]
627626
pub fn local_to_op(
628627
&self,
629628
frame: &Frame<'mir, 'tcx, M::Provenance, M::FrameExtra>,
630629
local: mir::Local,
631630
layout: Option<TyAndLayout<'tcx>>,
632631
) -> InterpResult<'tcx, OpTy<'tcx, M::Provenance>> {
633632
let layout = self.layout_of_local(frame, local, layout)?;
634-
trace!(?frame.locals, "here's the locals");
635633
let op = *frame.locals[local].access()?;
636634
if matches!(op, Operand::Immediate(_)) {
637635
if layout.is_unsized() {
@@ -640,7 +638,6 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
640638
throw_inval!(ConstPropNonsense);
641639
}
642640
}
643-
trace!(?op, "the op");
644641
Ok(OpTy { op, layout })
645642
}
646643

compiler/rustc_mir_transform/src/const_prop.rs

+5-31
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,6 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
360360
ConstPropagator { ecx, tcx, param_env, local_decls: &body.local_decls, patch }
361361
}
362362

363-
#[instrument(skip(self), level = "debug")]
364363
fn get_const(&self, place: Place<'tcx>) -> Option<OpTy<'tcx>> {
365364
let op = match self.ecx.eval_place_to_op(place, None) {
366365
Ok(op) => {
@@ -382,14 +381,10 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
382381

383382
// Try to read the local as an immediate so that if it is representable as a scalar, we can
384383
// handle it as such, but otherwise, just return the value as is.
385-
let r = Some(match self.ecx.read_immediate_raw(&op) {
384+
Some(match self.ecx.read_immediate_raw(&op) {
386385
Ok(Right(imm)) => imm.into(),
387386
_ => op,
388-
});
389-
390-
trace!("found = {r:?}");
391-
392-
r
387+
})
393388
}
394389

395390
/// Remove `local` from the pool of `Locals`. Allows writing to them,
@@ -399,7 +394,6 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
399394
ecx.machine.written_only_inside_own_block_locals.remove(&local);
400395
}
401396

402-
#[instrument(skip(self), level = "debug")]
403397
fn check_rvalue(&mut self, rvalue: &Rvalue<'tcx>) -> Option<()> {
404398
// Perform any special handling for specific Rvalue types.
405399
// Generally, checks here fall into one of two categories:
@@ -516,7 +510,6 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
516510
}
517511
}
518512

519-
#[instrument(skip(self), level = "debug")]
520513
fn replace_with_const(&mut self, place: Place<'tcx>) -> Option<Const<'tcx>> {
521514
// This will return None if the above `const_prop` invocation only "wrote" a
522515
// type whose creation requires no write. E.g. a coroutine whose initial state
@@ -619,7 +612,6 @@ impl CanConstProp {
619612
}
620613

621614
impl<'tcx> Visitor<'tcx> for CanConstProp {
622-
#[instrument(skip(self), level = "debug")]
623615
fn visit_place(&mut self, place: &Place<'tcx>, mut context: PlaceContext, loc: Location) {
624616
use rustc_middle::mir::visit::PlaceContext::*;
625617

@@ -632,7 +624,6 @@ impl<'tcx> Visitor<'tcx> for CanConstProp {
632624
self.visit_projection(place.as_ref(), context, loc);
633625
}
634626

635-
#[instrument(skip(self), level = "debug")]
636627
fn visit_local(&mut self, local: Local, context: PlaceContext, _: Location) {
637628
use rustc_middle::mir::visit::PlaceContext::*;
638629
match context {
@@ -691,22 +682,15 @@ impl<'tcx> Visitor<'tcx> for CanConstProp {
691682
}
692683

693684
impl<'tcx> Visitor<'tcx> for ConstPropagator<'_, 'tcx> {
694-
#[instrument(skip(self), level = "debug")]
695685
fn visit_operand(&mut self, operand: &Operand<'tcx>, location: Location) {
696686
self.super_operand(operand, location);
697-
698-
trace!("about to do it");
699-
700687
if let Some(place) = operand.place()
701688
&& let Some(value) = self.replace_with_const(place)
702689
{
703-
trace!(?place, ?value, "know whats going on");
704690
self.patch.before_effect.insert((location, place), value);
705691
}
706692
}
707693

708-
#[instrument(skip(self), level = "debug")]
709-
710694
fn visit_projection_elem(
711695
&mut self,
712696
_: PlaceRef<'tcx>,
@@ -721,7 +705,6 @@ impl<'tcx> Visitor<'tcx> for ConstPropagator<'_, 'tcx> {
721705
}
722706
}
723707

724-
#[instrument(skip(self), level = "debug")]
725708
fn visit_assign(&mut self, place: &Place<'tcx>, rvalue: &Rvalue<'tcx>, location: Location) {
726709
self.super_assign(place, rvalue, location);
727710

@@ -736,14 +719,14 @@ impl<'tcx> Visitor<'tcx> for ConstPropagator<'_, 'tcx> {
736719
_ if place.is_indirect() => {}
737720
ConstPropMode::NoPropagation => self.ensure_not_propagated(place.local),
738721
ConstPropMode::OnlyInsideOwnBlock | ConstPropMode::FullConstProp => {
739-
trace!("trying to do some const-prop");
740722
if let Some(()) = self.eval_rvalue_with_identities(rvalue, *place) {
741723
// If this was already an evaluated constant, keep it.
742724
if let Rvalue::Use(Operand::Constant(c)) = rvalue
743725
&& let Const::Val(..) = c.const_
744726
{
745727
trace!(
746-
"skipping replace of Rvalue::Use({c:?}) because it is already a const"
728+
"skipping replace of Rvalue::Use({:?} because it is already a const",
729+
c
747730
);
748731
} else if let Some(operand) = self.replace_with_const(*place) {
749732
self.patch.assignments.insert(location, operand);
@@ -770,12 +753,8 @@ impl<'tcx> Visitor<'tcx> for ConstPropagator<'_, 'tcx> {
770753
}
771754
}
772755

773-
#[instrument(skip(self), level = "trace")]
774756
fn visit_statement(&mut self, statement: &Statement<'tcx>, location: Location) {
775-
{
776-
let frame = &self.ecx.frame().locals;
777-
trace!(?frame, "initial frame");
778-
}
757+
trace!("visit_statement: {:?}", statement);
779758

780759
// We want to evaluate operands before any change to the assigned-to value,
781760
// so we recurse first.
@@ -816,11 +795,6 @@ impl<'tcx> Visitor<'tcx> for ConstPropagator<'_, 'tcx> {
816795
// In both cases, this does not matter, as those reads would be UB anyway.
817796
_ => {}
818797
}
819-
820-
{
821-
let frame = &self.ecx.frame().locals;
822-
trace!(?frame, "final frame");
823-
}
824798
}
825799

826800
fn visit_basic_block_data(&mut self, block: BasicBlock, data: &BasicBlockData<'tcx>) {

0 commit comments

Comments
 (0)