mir: introduce passes::dce and minimal MirPass trait; rewire optimizer to use modular DCE pass. Build + PyVM Stage-2 smokes PASS.

This commit is contained in:
Selfhosting Dev
2025-09-17 03:32:05 +09:00
parent b60d3a0305
commit 56463c75f6
3 changed files with 85 additions and 2 deletions

View File

@ -62,8 +62,11 @@ impl MirOptimizer {
// Normalize Python helper form: py.getattr(obj, name) → obj.getattr(name)
stats.merge(self.normalize_python_helper_calls(module));
// Pass 1: Dead code elimination
stats.merge(self.eliminate_dead_code(module));
// Pass 1: Dead code elimination (modularized pass)
{
let eliminated = crate::mir::passes::dce::eliminate_dead_code(module);
stats.dead_code_eliminated += eliminated;
}
// Pass 2: Pure instruction CSE (Common Subexpression Elimination)
stats.merge(self.common_subexpression_elimination(module));