Skip to content

Commit

Permalink
fix unused variables pass
Browse files Browse the repository at this point in the history
it corrupts the DFG. to see the bug before this commit, add another
StoreEliminationPass after RemoveUnusedVariablesPass.
  • Loading branch information
charles-cooper committed Sep 25, 2024
1 parent 48a5da4 commit 3b2ece2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions vyper/venom/analysis/dfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ def remove_use(self, op: IRVariable, inst: IRInstruction):
uses = self._dfg_inputs.get(op, [])
uses.remove(inst)

def remove_var(self, op: IRVariable):
self._dfg_outputs.pop(op)

@property
def outputs(self) -> dict[IRVariable, IRInstruction]:
return self._dfg_outputs
Expand Down
1 change: 1 addition & 0 deletions vyper/venom/passes/remove_unused_variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,5 @@ def _process_instruction(self, inst):
new_uses = self.dfg.get_uses(operand)
self.work_list.addmany(new_uses)

self.dfg.remove_var(inst.output)
inst.parent.remove_instruction(inst)

0 comments on commit 3b2ece2

Please sign in to comment.