pub struct DeadCodeEliminator {
pub eliminated_count: usize,
pub blocks_removed: usize,
pub unused_params: usize,
}Expand description
Dead Code Elimination pass.
Removes instructions that:
- Have a result that is never used
- Have no side effects
- Are in unreachable blocks
- Are instructions after a terminator (unreachable code)
Side-effect instructions (SSTORE, MSTORE, CALL, LOG, etc.) are always kept.
Fields§
§eliminated_count: usizeNumber of instructions eliminated in the last run.
blocks_removed: usizeNumber of unreachable blocks removed.
unused_params: usizeNumber of unused parameters detected.
Implementations§
Source§impl DeadCodeEliminator
impl DeadCodeEliminator
Sourcepub fn run(&mut self, func: &mut Function) -> usize
pub fn run(&mut self, func: &mut Function) -> usize
Runs dead code elimination on a function. Returns the number of instructions eliminated.
Sourcepub fn run_with_stats(&mut self, func: &mut Function) -> DceStats
pub fn run_with_stats(&mut self, func: &mut Function) -> DceStats
Runs dead code elimination with full statistics.
Sourcepub fn run_to_fixpoint(&mut self, func: &mut Function) -> usize
pub fn run_to_fixpoint(&mut self, func: &mut Function) -> usize
Runs dead code elimination iteratively until no more changes.
Sourcepub fn find_unused_parameters(&self, func: &Function) -> Vec<u32>
pub fn find_unused_parameters(&self, func: &Function) -> Vec<u32>
Finds unused function parameters. Returns the indices of parameters that are never used.
Trait Implementations§
Source§impl Debug for DeadCodeEliminator
impl Debug for DeadCodeEliminator
Source§impl Default for DeadCodeEliminator
impl Default for DeadCodeEliminator
Source§fn default() -> DeadCodeEliminator
fn default() -> DeadCodeEliminator
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for DeadCodeEliminator
impl RefUnwindSafe for DeadCodeEliminator
impl Send for DeadCodeEliminator
impl Sync for DeadCodeEliminator
impl Unpin for DeadCodeEliminator
impl UnsafeUnpin for DeadCodeEliminator
impl UnwindSafe for DeadCodeEliminator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T, R> CollectAndApply<T, R> for T
impl<T, R> CollectAndApply<T, R> for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more