From ba0b872ecbcaab130b576669a76786700353d987 Mon Sep 17 00:00:00 2001 From: trocher <43437004+trocher@users.noreply.github.com> Date: Fri, 14 Jun 2024 17:56:24 +0200 Subject: [PATCH] chore: remove useless IRnode.from_list --- vyper/codegen/abi_encoder.py | 1 - vyper/codegen/core.py | 2 +- vyper/codegen/expr.py | 1 - vyper/codegen/self_call.py | 6 ++---- vyper/codegen/stmt.py | 16 +++------------- 5 files changed, 6 insertions(+), 20 deletions(-) diff --git a/vyper/codegen/abi_encoder.py b/vyper/codegen/abi_encoder.py index 09a22cd857..2ea8e3b6fd 100644 --- a/vyper/codegen/abi_encoder.py +++ b/vyper/codegen/abi_encoder.py @@ -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", diff --git a/vyper/codegen/core.py b/vyper/codegen/core.py index ff0f801d74..7a0613ebce 100644 --- a/vyper/codegen/core.py +++ b/vyper/codegen/core.py @@ -1097,7 +1097,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) diff --git a/vyper/codegen/expr.py b/vyper/codegen/expr.py index 65df5a0930..161f19e8bb 100644 --- a/vyper/codegen/expr.py +++ b/vyper/codegen/expr.py @@ -706,7 +706,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 diff --git a/vyper/codegen/self_call.py b/vyper/codegen/self_call.py index 8cd599d3e7..fef6070d14 100644 --- a/vyper/codegen/self_call.py +++ b/vyper/codegen/self_call.py @@ -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 diff --git a/vyper/codegen/stmt.py b/vyper/codegen/stmt.py index 830f2f923d..225cede747 100644 --- a/vyper/codegen/stmt.py +++ b/vyper/codegen/stmt.py @@ -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 @@ -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): @@ -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 @@ -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) @@ -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