Skip to content

Commit

Permalink
Merge branch 'refactor/dfg-domtree' into perf/liveness2
Browse files Browse the repository at this point in the history
  • Loading branch information
charles-cooper committed Oct 29, 2024
2 parents 3863ed2 + 6178526 commit 8135181
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
6 changes: 5 additions & 1 deletion vyper/codegen/ir_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from typing import Any, List, Optional, Union

import vyper.ast as vy_ast
from vyper.compiler.settings import VYPER_COLOR_OUTPUT
from vyper.compiler.settings import VYPER_COLOR_OUTPUT, get_global_settings
from vyper.evm.address_space import AddrSpace
from vyper.evm.opcodes import get_ir_opcodes
from vyper.exceptions import CodegenPanic, CompilerPanic
Expand Down Expand Up @@ -426,6 +426,10 @@ def is_pointer(self) -> bool:

@property # probably could be cached_property but be paranoid
def _optimized(self):
if get_global_settings().experimental_codegen:
# in venom pipeline, we don't need to inline constants.
return self

# TODO figure out how to fix this circular import
from vyper.ir.optimizer import optimize

Expand Down
22 changes: 12 additions & 10 deletions vyper/venom/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,17 +167,19 @@ def chain_basic_blocks(self) -> None:
"""
bbs = list(self.get_basic_blocks())
for i, bb in enumerate(bbs):
if not bb.is_terminated:
if i < len(bbs) - 1:
# TODO: revisit this. When contructor calls internal functions they
# are linked to the last ctor block. Should separate them before this
# so we don't have to handle this here
if bbs[i + 1].label.value.startswith("internal"):
bb.append_instruction("stop")
else:
bb.append_instruction("jmp", bbs[i + 1].label)
if bb.is_terminated:
continue

if i < len(bbs) - 1:
# TODO: revisit this. When contructor calls internal functions
# they are linked to the last ctor block. Should separate them
# before this so we don't have to handle this here
if bbs[i + 1].label.value.startswith("internal"):
bb.append_instruction("stop")
else:
bb.append_instruction("exit")
bb.append_instruction("jmp", bbs[i + 1].label)
else:
bb.append_instruction("stop")

def copy(self):
new = IRFunction(self.name)
Expand Down
6 changes: 2 additions & 4 deletions vyper/venom/ir_node_to_venom.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ def _convert_ir_bb(fn, ir, symbols):
elif ir.value == "deploy":
ctx.ctor_mem_size = ir.args[0].value
ctx.immutables_len = ir.args[2].value
fn.get_basic_block().append_instruction("exit")
return None
elif ir.value == "seq":
if len(ir.args) == 0:
Expand Down Expand Up @@ -398,10 +399,7 @@ def _convert_ir_bb(fn, ir, symbols):
bb = IRBasicBlock(label, fn)
fn.append_basic_block(bb)
code = ir.args[2]
if code.value == "pass":
bb.append_instruction("exit")
else:
_convert_ir_bb(fn, code, symbols)
_convert_ir_bb(fn, code, symbols)
elif ir.value == "exit_to":
args = _convert_ir_bb_list(fn, ir.args[1:], symbols)
var_list = args
Expand Down

0 comments on commit 8135181

Please sign in to comment.