Skip to main content

eliminate_dead_code

Function eliminate_dead_code 

Source
pub fn eliminate_dead_code(
    instructions: &[Instruction],
) -> (Vec<Instruction>, usize)
Expand description

Remove instructions whose results are never used.

Performs iterative dead code elimination until a fixed point is reached: each pass removes instructions that define registers not consumed by any other instruction, provided the instruction has no side effects.

§Arguments

  • instructions - The original instruction sequence.

§Returns

A tuple of (optimized_instructions, eliminated_count).