Struct rustc_mir::transform::const_prop::ConstPropagator[−][src]

struct ConstPropagator<'mir, 'tcx> {
    ecx: InterpCx<'mir, 'tcx, ConstPropMachine<'mir, 'tcx>>,
    tcx: TyCtxt<'tcx>,
    param_env: ParamEnv<'tcx>,
    source_scopes: IndexVec<SourceScope, SourceScopeData<'tcx>>,
    local_decls: IndexVec<Local, LocalDecl<'tcx>>,
    source_info: Option<SourceInfo>,
}
Expand description

Finds optimization opportunities on the MIR.

Fields

ecx: InterpCx<'mir, 'tcx, ConstPropMachine<'mir, 'tcx>>tcx: TyCtxt<'tcx>param_env: ParamEnv<'tcx>source_scopes: IndexVec<SourceScope, SourceScopeData<'tcx>>local_decls: IndexVec<Local, LocalDecl<'tcx>>source_info: Option<SourceInfo>

Implementations

impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx>[src]

fn new(
    body: &Body<'tcx>,
    dummy_body: &'mir Body<'tcx>,
    tcx: TyCtxt<'tcx>
) -> ConstPropagator<'mir, 'tcx>
[src]

fn get_const(&self, place: Place<'tcx>) -> Option<OpTy<'tcx>>[src]

fn remove_const(
    ecx: &mut InterpCx<'mir, 'tcx, ConstPropMachine<'mir, 'tcx>>,
    local: Local
)
[src]

Remove local from the pool of Locals. Allows writing to them, but not reading from them anymore.

fn lint_root(&self, source_info: SourceInfo) -> Option<HirId>[src]

fn use_ecx<F, T>(&mut self, f: F) -> Option<T> where
    F: FnOnce(&mut Self) -> InterpResult<'tcx, T>, 
[src]

fn eval_constant(
    &mut self,
    c: &Constant<'tcx>,
    source_info: SourceInfo
) -> Option<OpTy<'tcx>>
[src]

Returns the value, if any, of evaluating c.

fn eval_place(&mut self, place: Place<'tcx>) -> Option<OpTy<'tcx>>[src]

Returns the value, if any, of evaluating place.

fn eval_operand(
    &mut self,
    op: &Operand<'tcx>,
    source_info: SourceInfo
) -> Option<OpTy<'tcx>>
[src]

Returns the value, if any, of evaluating op. Calls upon eval_constant or eval_place, depending on the variant of Operand used.

fn report_assert_as_lint(
    &self,
    lint: &'static Lint,
    source_info: SourceInfo,
    message: &'static str,
    panic: AssertKind<impl Debug>
) -> Option<()>
[src]

fn check_unary_op(
    &mut self,
    op: UnOp,
    arg: &Operand<'tcx>,
    source_info: SourceInfo
) -> Option<()>
[src]

fn check_binary_op(
    &mut self,
    op: BinOp,
    left: &Operand<'tcx>,
    right: &Operand<'tcx>,
    source_info: SourceInfo
) -> Option<()>
[src]

fn propagate_operand(&mut self, operand: &mut Operand<'tcx>)[src]

fn const_prop(
    &mut self,
    rvalue: &Rvalue<'tcx>,
    source_info: SourceInfo,
    place: Place<'tcx>
) -> Option<()>
[src]

fn eval_rvalue_with_identities(
    &mut self,
    rvalue: &Rvalue<'tcx>,
    place: Place<'tcx>
) -> Option<()>
[src]

fn operand_from_scalar(
    &self,
    scalar: Scalar,
    ty: Ty<'tcx>,
    span: Span
) -> Operand<'tcx>
[src]

Creates a new Operand::Constant from a Scalar value

fn replace_with_const(
    &mut self,
    rval: &mut Rvalue<'tcx>,
    value: &OpTy<'tcx>,
    source_info: SourceInfo
)
[src]

fn should_const_prop(&mut self, op: &OpTy<'tcx>) -> bool[src]

Returns true if and only if this op should be const-propagated into.

Trait Implementations

impl<'mir, 'tcx> HasDataLayout for ConstPropagator<'mir, 'tcx>[src]

impl<'mir, 'tcx> HasTyCtxt<'tcx> for ConstPropagator<'mir, 'tcx>[src]

fn tcx(&self) -> TyCtxt<'tcx>[src]

impl<'mir, 'tcx> LayoutOf for ConstPropagator<'mir, 'tcx>[src]

type Ty = Ty<'tcx>

type TyAndLayout = Result<TyAndLayout<'tcx>, LayoutError<'tcx>>

fn layout_of(&self, ty: Ty<'tcx>) -> Self::TyAndLayout[src]

fn spanned_layout_of(&self, ty: Self::Ty, _span: Span) -> Self::TyAndLayout[src]

impl<'mir, 'tcx> MutVisitor<'tcx> for ConstPropagator<'mir, 'tcx>[src]

fn tcx(&self) -> TyCtxt<'tcx>[src]

fn visit_body(&mut self, body: &mut Body<'tcx>)[src]

fn visit_operand(&mut self, operand: &mut Operand<'tcx>, location: Location)[src]

fn visit_constant(&mut self, constant: &mut Constant<'tcx>, location: Location)[src]

fn visit_statement(
    &mut self,
    statement: &mut Statement<'tcx>,
    location: Location
)
[src]

fn visit_terminator(
    &mut self,
    terminator: &mut Terminator<'tcx>,
    location: Location
)
[src]

fn visit_basic_block_data(
    &mut self,
    block: BasicBlock,
    data: &mut BasicBlockData<'tcx>
)
[src]

fn visit_source_scope_data(&mut self, scope_data: &mut SourceScopeData<'tcx>)[src]

fn visit_assign(
    &mut self,
    place: &mut Place<'tcx>,
    rvalue: &mut Rvalue<'tcx>,
    location: Location
)
[src]

fn visit_assert_message(
    &mut self,
    msg: &mut AssertKind<Operand<'tcx>>,
    location: Location
)
[src]

fn visit_rvalue(&mut self, rvalue: &mut Rvalue<'tcx>, location: Location)[src]

fn visit_ascribe_user_ty(
    &mut self,
    place: &mut Place<'tcx>,
    variance: &mut Variance,
    user_ty: &mut UserTypeProjection,
    location: Location
)
[src]

fn visit_coverage(&mut self, coverage: &mut Coverage, location: Location)[src]

fn visit_retag(
    &mut self,
    kind: &mut RetagKind,
    place: &mut Place<'tcx>,
    location: Location
)
[src]

fn visit_place(
    &mut self,
    place: &mut Place<'tcx>,
    context: PlaceContext,
    location: Location
)
[src]

fn super_place(
    &mut self,
    place: &mut Place<'tcx>,
    context: PlaceContext,
    location: Location
)
[src]

fn process_projection(
    &mut self,
    projection: &'a [ProjectionElem<Local, &'tcx TyS<'tcx>>],
    location: Location
) -> Option<Vec<ProjectionElem<Local, &'tcx TyS<'tcx>>, Global>>
[src]

fn process_projection_elem(
    &mut self,
    elem: ProjectionElem<Local, &'tcx TyS<'tcx>>,
    location: Location
) -> Option<ProjectionElem<Local, &'tcx TyS<'tcx>>>
[src]

fn visit_span(&mut self, span: &mut Span)[src]

fn visit_source_info(&mut self, source_info: &mut SourceInfo)[src]

fn visit_ty(&mut self, ty: &mut &'tcx TyS<'tcx>, TyContext)[src]

fn visit_user_type_projection(&mut self, ty: &mut UserTypeProjection)[src]

fn visit_user_type_annotation(
    &mut self,
    index: UserTypeAnnotationIndex,
    ty: &mut CanonicalUserTypeAnnotation<'tcx>
)
[src]

fn visit_region(&mut self, region: &mut &'tcx RegionKind, Location)[src]

fn visit_const(&mut self, constant: &mut &'tcx Const<'tcx>, Location)[src]

fn visit_substs(&mut self, substs: &mut &'tcx List<GenericArg<'tcx>>, Location)[src]

fn visit_local_decl(&mut self, local: Local, local_decl: &mut LocalDecl<'tcx>)[src]

fn visit_var_debug_info(&mut self, var_debug_info: &mut VarDebugInfo<'tcx>)[src]

fn visit_local(
    &mut self,
    _local: &mut Local,
    _context: PlaceContext,
    _location: Location
)
[src]

fn visit_source_scope(&mut self, scope: &mut SourceScope)[src]

fn super_body(&mut self, body: &mut Body<'tcx>)[src]

fn super_basic_block_data(
    &mut self,
    block: BasicBlock,
    data: &mut BasicBlockData<'tcx>
)
[src]

fn super_source_scope_data(&mut self, scope_data: &mut SourceScopeData<'tcx>)[src]

fn super_statement(
    &mut self,
    statement: &mut Statement<'tcx>,
    location: Location
)
[src]

fn super_assign(
    &mut self,
    place: &mut Place<'tcx>,
    rvalue: &mut Rvalue<'tcx>,
    location: Location
)
[src]

fn super_terminator(
    &mut self,
    terminator: &mut Terminator<'tcx>,
    location: Location
)
[src]

fn super_assert_message(
    &mut self,
    msg: &mut AssertKind<Operand<'tcx>>,
    location: Location
)
[src]

fn super_rvalue(&mut self, rvalue: &mut Rvalue<'tcx>, location: Location)[src]

fn super_operand(&mut self, operand: &mut Operand<'tcx>, location: Location)[src]

fn super_ascribe_user_ty(
    &mut self,
    place: &mut Place<'tcx>,
    _variance: &mut Variance,
    user_ty: &mut UserTypeProjection,
    location: Location
)
[src]

fn super_coverage(&mut self, _coverage: &mut Coverage, _location: Location)[src]

fn super_retag(
    &mut self,
    _kind: &mut RetagKind,
    place: &mut Place<'tcx>,
    location: Location
)
[src]

fn super_local_decl(&mut self, local: Local, local_decl: &mut LocalDecl<'tcx>)[src]

fn super_var_debug_info(&mut self, var_debug_info: &mut VarDebugInfo<'tcx>)[src]

fn super_source_scope(&mut self, _scope: &mut SourceScope)[src]

fn super_constant(&mut self, constant: &mut Constant<'tcx>, location: Location)[src]

fn super_span(&mut self, _span: &mut Span)[src]

fn super_source_info(&mut self, source_info: &mut SourceInfo)[src]

fn super_user_type_projection(&mut self, _ty: &mut UserTypeProjection)[src]

fn super_user_type_annotation(
    &mut self,
    _index: UserTypeAnnotationIndex,
    ty: &mut CanonicalUserTypeAnnotation<'tcx>
)
[src]

fn super_ty(&mut self, _ty: &mut &'tcx TyS<'tcx>)[src]

fn super_region(&mut self, _region: &mut &'tcx RegionKind)[src]

fn super_const(&mut self, _const: &mut &'tcx Const<'tcx>)[src]

fn super_substs(&mut self, _substs: &mut &'tcx List<GenericArg<'tcx>>)[src]

fn visit_location(&mut self, body: &mut Body<'tcx>, location: Location)[src]

Auto Trait Implementations

impl<'mir, 'tcx> !RefUnwindSafe for ConstPropagator<'mir, 'tcx>

impl<'mir, 'tcx> !Send for ConstPropagator<'mir, 'tcx>

impl<'mir, 'tcx> !Sync for ConstPropagator<'mir, 'tcx>

impl<'mir, 'tcx> Unpin for ConstPropagator<'mir, 'tcx> where
    'tcx: 'mir, 

impl<'mir, 'tcx> !UnwindSafe for ConstPropagator<'mir, 'tcx>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized, 
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized, 
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized, 
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> PointerArithmetic for T where
    T: HasDataLayout, 
[src]

fn pointer_size(&self) -> Size[src]

fn machine_usize_max(&self) -> u64[src]

fn machine_isize_min(&self) -> i64[src]

fn machine_isize_max(&self) -> i64[src]

fn truncate_to_ptr(&self, (u64, bool)) -> (u64, bool)[src]

Helper function: truncate given value-“overflowed flag” pair to pointer size and update “overflowed flag” if there was an overflow. This should be called by all the other methods before returning! Read more

fn overflowing_offset(&self, val: u64, i: u64) -> (u64, bool)[src]

fn overflowing_signed_offset(&self, val: u64, i: i64) -> (u64, bool)[src]

fn offset<'tcx>(&self, val: u64, i: u64) -> Result<u64, InterpErrorInfo<'tcx>>[src]

fn signed_offset<'tcx>(
    &self,
    val: u64,
    i: i64
) -> Result<u64, InterpErrorInfo<'tcx>>
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.

impl<T> WithConstness for T[src]

fn with_constness(self, constness: Constness) -> ConstnessAnd<Self>[src]

fn with_const(self) -> ConstnessAnd<Self>[src]

fn without_const(self) -> ConstnessAnd<Self>[src]