Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat[venom]: improve liveness computation time #4086

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions vyper/venom/analysis/liveness.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from collections import deque

from vyper.exceptions import CompilerPanic
from vyper.utils import OrderedSet
from vyper.venom.analysis.analysis import IRAnalysis
Expand All @@ -13,14 +15,19 @@ class LivenessAnalysis(IRAnalysis):
def analyze(self):
self.analyses_cache.request_analysis(CFGAnalysis)
self._reset_liveness()
while True:
changed = False
for bb in self.function.get_basic_blocks():
changed |= self._calculate_out_vars(bb)
changed |= self._calculate_liveness(bb)

if not changed:
break
self._worklist = deque()
self._worklist.extend(self.function.get_basic_blocks())

while len(self._worklist) > 0:
changed = False
bb = self._worklist.popleft()
changed |= self._calculate_out_vars(bb)
changed |= self._calculate_liveness(bb)
# recompute liveness for basic blocks pointing into
# this basic block
if changed:
self._worklist.extend(bb.cfg_in)

def _reset_liveness(self) -> None:
for bb in self.function.get_basic_blocks():
Expand Down
Loading