From 4819e4ceaba92a5aa535c15da384f5bb2a7197e8 Mon Sep 17 00:00:00 2001 From: Charles Cooper Date: Fri, 21 Feb 2025 16:37:42 +0100 Subject: [PATCH] fix[codegen]: fix gas usage of iterators cd318676a0b7bcb introduces a gas regression, which is that `IRnode.is_literal` evaluates to true even for pointers (which are not source-level literals). this commit changes the condition to be `not .is_pointer`, which should be the correct condition for needing to strictify into memory. --- vyper/codegen/ir_node.py | 2 -- vyper/codegen/stmt.py | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/vyper/codegen/ir_node.py b/vyper/codegen/ir_node.py index 81ec47f10f..6ed6345674 100644 --- a/vyper/codegen/ir_node.py +++ b/vyper/codegen/ir_node.py @@ -425,8 +425,6 @@ def int_value(self) -> int: @property def is_pointer(self) -> bool: - # not used yet but should help refactor/clarify downstream code - # eventually return self.location is not None @property # probably could be cached_property but be paranoid diff --git a/vyper/codegen/stmt.py b/vyper/codegen/stmt.py index b306d83376..53af7a9e10 100644 --- a/vyper/codegen/stmt.py +++ b/vyper/codegen/stmt.py @@ -257,8 +257,8 @@ def _parse_For_list(self): ret = ["seq"] - # list literal, force it to memory first - if iter_list.is_literal: + # if it's a list literal, force it to memory first + if not iter_list.is_pointer: tmp_list = self.context.new_internal_variable(iter_list.typ) ret.append(make_setter(tmp_list, iter_list)) iter_list = tmp_list