You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
vyper Version (output of vyper --version): 074073f
What's your issue about?
sometimes, venom produces some unneeded stack traffic. this can't be fixed by improved dataflow analysis, because it is an issue in the stack scheduler rather than instruction reordering. what happens is a stack item is produced, but it has a longer lifespan than other things on the stack. i think a lot of it can be solved with a simple heuristic: at the time of stack item production, check the live list for something with "shorter" liveness we can swap it with.
How can it be fixed?
i think something like this does what we want (but in its current form it is borked, it causes some larger contracts to puke):
diff --git a/vyper/venom/venom_to_assembly.py b/vyper/venom/venom_to_assembly.py
index dd4901aaa..8104c205e 100644
--- a/vyper/venom/venom_to_assembly.py+++ b/vyper/venom/venom_to_assembly.py@@ -16,6 +16,7 @@ from vyper.venom.analysis import (
calculate_dup_requirements,
calculate_liveness,
input_vars_from,
+ DFG,
)
from vyper.venom.basicblock import (
IRBasicBlock,
@@ -156,6 +157,7 @@ class VenomCompiler:
calculate_cfg(ctx)
calculate_liveness(ctx)
calculate_dup_requirements(ctx)
+ self._dfg = DFG.build_dfg(ctx)
assert ctx.normalized, "Non-normalized CFG!"
@@ -532,8 +534,16 @@ class VenomCompiler:
# Step 6: Emit instructions output operands (if any)
if inst.output is not None:
- if "call" in inst.opcode and inst.output not in next_liveness:+ if inst.output not in next_liveness:
self.pop(assembly, stack)
+ else:+ # peek at next_liveness to find the next scheduled item,+ # and optimistically swap with it+ bb = inst.parent+ for s in reversed(list(next_liveness)):+ if all(t.parent == bb for t in self._dfg.get_uses(s)):+ self.swap_op(assembly, stack, s)+ break
return apply_line_numbers(inst, assembly)
The text was updated successfully, but these errors were encountered:
Version Information
vyper --version
): 074073fWhat's your issue about?
sometimes, venom produces some unneeded stack traffic. this can't be fixed by improved dataflow analysis, because it is an issue in the stack scheduler rather than instruction reordering. what happens is a stack item is produced, but it has a longer lifespan than other things on the stack. i think a lot of it can be solved with a simple heuristic: at the time of stack item production, check the live list for something with "shorter" liveness we can swap it with.
How can it be fixed?
i think something like this does what we want (but in its current form it is borked, it causes some larger contracts to puke):
The text was updated successfully, but these errors were encountered: