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

refactor[codegen]: remove redundant IRnode.from_list #4151

Merged
Merged
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion vyper/codegen/abi_encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ def _encode_dyn_array_helper(dst, ir_node, context):
# TODO handle this upstream somewhere
if ir_node.value == "multi":
buf = context.new_internal_variable(dst.typ)
buf = IRnode.from_list(buf, typ=dst.typ, location=MEMORY)
_bufsz = dst.typ.abi_type.size_bound()
return [
"seq",
Expand Down
2 changes: 1 addition & 1 deletion vyper/codegen/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1117,7 +1117,7 @@ def ensure_in_memory(ir_var, context):
return ir_var

typ = ir_var.typ
buf = IRnode.from_list(context.new_internal_variable(typ), typ=typ, location=MEMORY)
buf = context.new_internal_variable(typ)
do_copy = make_setter(buf, ir_var)

return IRnode.from_list(["seq", do_copy, buf], typ=typ, location=MEMORY)
Expand Down
1 change: 0 additions & 1 deletion vyper/codegen/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,6 @@ def parse_Call(self):
ret = ["seq"]
if potential_overlap(darray, arg):
tmp = self.context.new_internal_variable(arg.typ)
tmp = IRnode.from_list(tmp, typ=arg.typ, location=MEMORY)
ret.append(make_setter(tmp, arg))
arg = tmp

Expand Down
6 changes: 2 additions & 4 deletions vyper/codegen/self_call.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,8 @@ def ir_for_self_call(stmt_expr, context):
# allocate space for the return buffer
# TODO allocate in stmt and/or expr.py
if func_t.return_type is not None:
return_buffer = IRnode.from_list(
context.new_internal_variable(func_t.return_type),
annotation=f"{return_label}_return_buf",
)
return_buffer = context.new_internal_variable(func_t.return_type)
return_buffer.annotation = f"{return_label}_return_buf"
else:
return_buffer = None

Expand Down
16 changes: 3 additions & 13 deletions vyper/codegen/stmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
)
from vyper.codegen.expr import Expr
from vyper.codegen.return_ import make_return_stmt
from vyper.evm.address_space import MEMORY
from vyper.exceptions import CodegenPanic, StructureException, TypeCheckFailure, tag_exceptions
from vyper.semantics.types import DArrayT
from vyper.semantics.types.shortcuts import UINT256_T
Expand Down Expand Up @@ -56,13 +55,11 @@ def parse_Name(self):
def parse_AnnAssign(self):
ltyp = self.stmt.target._metadata["type"]
varname = self.stmt.target.id
alloced = self.context.new_variable(varname, ltyp)
lhs = self.context.new_variable(varname, ltyp)

assert self.stmt.value is not None
rhs = Expr(self.stmt.value, self.context).ir_node

lhs = IRnode.from_list(alloced, typ=ltyp, location=MEMORY)

return make_setter(lhs, rhs)

def parse_Assign(self):
Expand All @@ -76,7 +73,6 @@ def parse_Assign(self):
# complex - i.e., it spans multiple words. for safety, we
# copy to a temporary buffer before copying to the destination.
tmp = self.context.new_internal_variable(src.typ)
tmp = IRnode.from_list(tmp, typ=src.typ, location=MEMORY)
ret.append(make_setter(tmp, src))
src = tmp

Expand Down Expand Up @@ -247,9 +243,7 @@ def _parse_For_list(self):

# user-supplied name for loop variable
varname = self.stmt.target.target.id
loop_var = IRnode.from_list(
self.context.new_variable(varname, target_type), typ=target_type, location=MEMORY
)
loop_var = self.context.new_variable(varname, target_type)

i = IRnode.from_list(self.context.fresh_varname("for_list_ix"), typ=UINT256_T)

Expand All @@ -259,11 +253,7 @@ def _parse_For_list(self):

# list literal, force it to memory first
if isinstance(self.stmt.iter, vy_ast.List):
tmp_list = IRnode.from_list(
self.context.new_internal_variable(iter_list.typ),
typ=iter_list.typ,
location=MEMORY,
)
tmp_list = self.context.new_internal_variable(iter_list.typ)
ret.append(make_setter(tmp_list, iter_list))
iter_list = tmp_list

Expand Down
Loading