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

fix: initcode codesize regression #3450

Merged
merged 7 commits into from
May 23, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
7 changes: 5 additions & 2 deletions tests/compiler/asm/test_asm_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,12 @@ def __init__():
foo_label = "_sym_internal_foo___"
qux_label = "_sym_internal_qux___"

# all the labels should be in all the unoptimized asms
# qux reachable from unoptimized initcode, foo not reachable.
assert qux_label + "_deploy" in initcode_asm
assert foo_label + "_deploy" not in initcode_asm

# all labels should be in unoptimized runtime asm
for s in (foo_label, qux_label):
assert s + "_deploy" in initcode_asm
assert s + "_runtime" in runtime_asm

c = CompilerData(code, no_optimize=False)
Expand Down
7 changes: 5 additions & 2 deletions vyper/codegen/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ def _runtime_ir(runtime_functions, global_ctx):
["label", "fallback", ["var_list"], fallback_ir],
]

# note: dead code eliminator will clean dead functions
runtime.extend(internal_functions_ir)

return runtime
Expand Down Expand Up @@ -178,10 +177,14 @@ def generate_ir_for_module(global_ctx: GlobalContext) -> tuple[IRnode, IRnode]:
# internal functions come after everything else
internal_functions = [f for f in runtime_functions if _is_internal(f)]
for f in internal_functions:
init_func_t = init_function._metadata["type"]
if f.name not in init_func_t.recursive_calls:
# unreachable
continue

func_ir = generate_ir_for_function(
f, global_ctx, skip_nonpayable_check=False, is_ctor_context=True
)
# note: we depend on dead code eliminator to clean dead function defs
deploy_code.append(func_ir)

else:
Expand Down