@@ -406,32 +406,6 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
406406 ecx. machine . written_only_inside_own_block_locals . remove ( & local) ;
407407 }
408408
409- /// Returns the value, if any, of evaluating `c`.
410- fn eval_constant ( & mut self , c : & Constant < ' tcx > ) -> Option < OpTy < ' tcx > > {
411- // FIXME we need to revisit this for #67176
412- if c. has_param ( ) {
413- return None ;
414- }
415-
416- // No span, we don't want errors to be shown.
417- self . ecx . eval_mir_constant ( & c. literal , None , None ) . ok ( )
418- }
419-
420- /// Returns the value, if any, of evaluating `place`.
421- fn eval_place ( & mut self , place : Place < ' tcx > ) -> Option < OpTy < ' tcx > > {
422- trace ! ( "eval_place(place={:?})" , place) ;
423- self . ecx . eval_place_to_op ( place, None ) . ok ( )
424- }
425-
426- /// Returns the value, if any, of evaluating `op`. Calls upon `eval_constant`
427- /// or `eval_place`, depending on the variant of `Operand` used.
428- fn eval_operand ( & mut self , op : & Operand < ' tcx > ) -> Option < OpTy < ' tcx > > {
429- match * op {
430- Operand :: Constant ( ref c) => self . eval_constant ( c) ,
431- Operand :: Move ( place) | Operand :: Copy ( place) => self . eval_place ( place) ,
432- }
433- }
434-
435409 fn propagate_operand ( & mut self , operand : & mut Operand < ' tcx > ) {
436410 if let Some ( place) = operand. place ( ) && let Some ( op) = self . replace_with_const ( place) {
437411 * operand = op;
@@ -871,45 +845,6 @@ impl<'tcx> MutVisitor<'tcx> for ConstPropagator<'_, 'tcx> {
871845 }
872846 }
873847
874- fn visit_terminator ( & mut self , terminator : & mut Terminator < ' tcx > , location : Location ) {
875- self . super_terminator ( terminator, location) ;
876-
877- match & mut terminator. kind {
878- TerminatorKind :: Assert { expected, ref mut cond, .. } => {
879- if let Some ( ref value) = self . eval_operand ( & cond)
880- && let Ok ( value_const) = self . ecx . read_scalar ( & value)
881- && self . should_const_prop ( value)
882- {
883- trace ! ( "assertion on {:?} should be {:?}" , value, expected) ;
884- * cond = self . operand_from_scalar ( value_const, self . tcx . types . bool ) ;
885- }
886- }
887- TerminatorKind :: SwitchInt { ref mut discr, .. } => {
888- // FIXME: This is currently redundant with `visit_operand`, but sadly
889- // always visiting operands currently causes a perf regression in LLVM codegen, so
890- // `visit_operand` currently only runs for propagates places for `mir_opt_level=4`.
891- self . propagate_operand ( discr)
892- }
893- // None of these have Operands to const-propagate.
894- TerminatorKind :: Goto { .. }
895- | TerminatorKind :: Resume
896- | TerminatorKind :: Terminate
897- | TerminatorKind :: Return
898- | TerminatorKind :: Unreachable
899- | TerminatorKind :: Drop { .. }
900- | TerminatorKind :: Yield { .. }
901- | TerminatorKind :: GeneratorDrop
902- | TerminatorKind :: FalseEdge { .. }
903- | TerminatorKind :: FalseUnwind { .. }
904- | TerminatorKind :: InlineAsm { .. } => { }
905- // Every argument in our function calls have already been propagated in `visit_operand`.
906- //
907- // NOTE: because LLVM codegen gives slight performance regressions with it, so this is
908- // gated on `mir_opt_level=3`.
909- TerminatorKind :: Call { .. } => { }
910- }
911- }
912-
913848 fn visit_basic_block_data ( & mut self , block : BasicBlock , data : & mut BasicBlockData < ' tcx > ) {
914849 self . super_basic_block_data ( block, data) ;
915850
0 commit comments