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

feat[venom]: inline pass and call conv #4468

Draft
wants to merge 311 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 250 commits
Commits
Show all changes
311 commits
Select commit Hold shift + click to select a range
44fb876
Merge branch 'master' into feat/cse
HodanPlodky Oct 28, 2024
45c3612
add some review
charles-cooper Nov 10, 2024
5e7f603
basic refactors and bit of improvement
HodanPlodky Nov 11, 2024
2434789
Merge branch 'master' into feat/cse
HodanPlodky Nov 11, 2024
709dc4d
Merge branch 'master' into feat/cse
HodanPlodky Nov 12, 2024
33f3dae
weird patch
HodanPlodky Nov 13, 2024
4e36a9c
different way of same fuction implementation
HodanPlodky Nov 18, 2024
dc07dff
small cleanup and more unintresting instruction
HodanPlodky Nov 18, 2024
4d57171
removed depth
HodanPlodky Nov 18, 2024
1a9c9ab
lint
HodanPlodky Nov 18, 2024
639d70b
removed forgoten comment
HodanPlodky Nov 18, 2024
bd89aae
Merge branch 'master' into feat/cse
HodanPlodky Nov 22, 2024
c75a273
feat[venom]: add calloca instruction
charles-cooper Nov 26, 2024
c647456
save/restore alloca table inside functions
charles-cooper Nov 26, 2024
f660a3c
float calloca
charles-cooper Nov 26, 2024
5591c53
Merge branch 'master' into feat/cse
HodanPlodky Nov 28, 2024
23d1267
add callsite to calloca
charles-cooper Dec 2, 2024
9b1a92d
Merge branch 'master' into feat/cse
HodanPlodky Dec 12, 2024
3275824
update readme
charles-cooper Dec 17, 2024
ca1c09d
Merge branch 'master' into feat/venom/calloca
charles-cooper Dec 18, 2024
a26b503
formatting
charles-cooper Dec 18, 2024
ef3ad9c
Merge branch 'master' into feat/venom/calloca
charles-cooper Dec 19, 2024
5cef52e
Merge branch 'master' into feat/venom/calloca
charles-cooper Dec 20, 2024
2065480
Merge branch 'master' into feat/venom/calloca
charles-cooper Dec 20, 2024
c16d171
remove callsite from calloca
charles-cooper Dec 22, 2024
8238831
init
harkal Dec 26, 2024
c54273c
add fcg
harkal Dec 26, 2024
5565d4c
func inliner
harkal Dec 26, 2024
5f01394
params
harkal Dec 26, 2024
6b88eed
helpers
harkal Dec 26, 2024
2b19059
global opti
harkal Dec 26, 2024
7d144de
work
harkal Dec 26, 2024
fe9f39a
refactor
harkal Dec 27, 2024
051225a
float
harkal Dec 27, 2024
1997b25
codename `asylum`
harkal Dec 27, 2024
027a2eb
more conservative
harkal Dec 28, 2024
d79c6d9
disable load elimination
harkal Dec 28, 2024
ca1ba5f
export func for repl
harkal Dec 28, 2024
7508436
first function is entry
harkal Dec 28, 2024
1257fd4
debuging aids
harkal Dec 28, 2024
d4893bd
work
harkal Dec 28, 2024
a1f76b6
fix grammar
harkal Dec 28, 2024
b4b4ae6
test
harkal Dec 28, 2024
a4d4ea9
lint
harkal Dec 28, 2024
7c79be7
mem2var debug
charles-cooper Dec 28, 2024
29ece7c
update varname in mem2var
charles-cooper Dec 28, 2024
542c115
invalidate dfg
harkal Dec 28, 2024
a376e88
polish store elimination
charles-cooper Dec 28, 2024
33fd262
test update
harkal Dec 28, 2024
30e0c79
remove superflus passes
harkal Dec 28, 2024
c6c3c8a
testing
harkal Dec 28, 2024
020b9b2
Merge branch 'master' into feat/inline_pass
harkal Dec 28, 2024
2ef4df6
helper
harkal Dec 28, 2024
7341c04
handle reverts
harkal Dec 28, 2024
757563d
add tests
harkal Dec 29, 2024
bf0ebb3
cleanup
harkal Dec 29, 2024
289d683
bounds
harkal Dec 29, 2024
674fb50
refactors
harkal Dec 29, 2024
057246c
Merge branch 'master' into feat/inline_pass
harkal Dec 29, 2024
05adb1a
refactor, lint, cleanup
harkal Dec 29, 2024
4a2041f
debug
harkal Dec 29, 2024
4878398
work
harkal Dec 29, 2024
385e59f
recursive inline out
harkal Dec 30, 2024
af699c6
add has block method
harkal Dec 30, 2024
33d8ffd
make "consts".. "private"
harkal Dec 30, 2024
dab4060
temp
harkal Dec 30, 2024
476b9de
inliner
harkal Dec 30, 2024
6fd42ef
fix var equivalance
harkal Dec 30, 2024
4e602b9
lint
harkal Dec 30, 2024
5d0ac96
comment wip stuff
harkal Dec 30, 2024
828e623
make cost a function
harkal Dec 30, 2024
2d5d872
Merge branch 'master' into feat/inline_pass
harkal Jan 4, 2025
ad2e8b7
dfg equiv
harkal Jan 4, 2025
6bf03ec
drop var equivalence
harkal Jan 4, 2025
6ca95a6
lint
harkal Jan 4, 2025
d4dcc8e
Merge branch 'master' into feat/cse
HodanPlodky Jan 5, 2025
06c627f
effect IMMUTABLE can interfere with MEMORY
HodanPlodky Jan 6, 2025
0971f58
early return
HodanPlodky Jan 6, 2025
eb136b8
Merge branch 'master' into feat/cse
HodanPlodky Jan 12, 2025
82a5ebc
Merge branch 'master' into feat/inline_pass
harkal Jan 16, 2025
e4c43c7
add function signature to ir_node passthrough metadata
charles-cooper Jan 19, 2025
79be32a
add a comment
charles-cooper Jan 19, 2025
319ddd4
Merge branch 'master' into feat/venom/calloca
charles-cooper Jan 19, 2025
6cd1927
better handling of available expressions
HodanPlodky Jan 20, 2025
08a0bd4
lint
HodanPlodky Jan 20, 2025
752b70f
Merge branch 'master' into feat/cse
HodanPlodky Jan 20, 2025
938c144
lint
HodanPlodky Jan 20, 2025
ab04c84
removed unused
HodanPlodky Jan 21, 2025
58393ec
Merge branch 'master' into feat/cse
HodanPlodky Jan 21, 2025
bb31c40
passthroug
harkal Jan 21, 2025
9d17a79
assert
harkal Jan 21, 2025
aba2afc
params
harkal Jan 21, 2025
2e6c79b
temp
harkal Jan 22, 2025
7380f52
Merge branch 'master' into feat/inline_pass
harkal Jan 22, 2025
29c1302
fix edge case in mem2var
harkal Jan 22, 2025
cac9d4c
post merge
harkal Jan 22, 2025
f04400c
temp
harkal Jan 22, 2025
7fe033d
tmep
harkal Jan 22, 2025
733e3b2
fix
harkal Jan 22, 2025
e54bd0f
comment out
harkal Jan 22, 2025
3cdbb48
dfg linting
harkal Jan 23, 2025
70ff390
lint
harkal Jan 23, 2025
eaef2a4
sccp fixes
harkal Jan 23, 2025
8a35af2
inter bb
HodanPlodky Jan 24, 2025
e66b348
order fix
HodanPlodky Jan 24, 2025
abd12cd
add back
harkal Jan 27, 2025
d98dbcd
enable more
harkal Jan 27, 2025
317cfb5
fix
harkal Jan 27, 2025
0234851
new failing test
harkal Jan 27, 2025
bd82d5c
venom -> evm changed
harkal Jan 27, 2025
abba8ca
internal update test case
harkal Jan 27, 2025
3552bae
get param by name
harkal Jan 27, 2025
b61009b
store
harkal Jan 27, 2025
7d44552
fix
harkal Jan 27, 2025
1d212ac
fixes for inter bb
HodanPlodky Jan 27, 2025
d3e2d64
removed unused code
HodanPlodky Jan 27, 2025
9ca6609
Merge branch 'master' into feat/cse
HodanPlodky Jan 28, 2025
5e406d5
small change in removing instructions
HodanPlodky Jan 28, 2025
09afa3e
merge
HodanPlodky Jan 28, 2025
4755b12
test rewrite with new parser + small fix
HodanPlodky Jan 28, 2025
75d1a44
start
harkal Jan 28, 2025
9f3eac0
Revert "start"
harkal Jan 28, 2025
0b50b4b
new cc on all prims
harkal Jan 28, 2025
3093987
bugfix
harkal Jan 28, 2025
4e19321
fixes and cleanup
harkal Jan 29, 2025
042f584
non indempotent instruction test
HodanPlodky Jan 29, 2025
fb21434
param support in inliner
harkal Jan 29, 2025
b1df259
failing test
harkal Jan 29, 2025
642dcb2
no return handling
harkal Jan 29, 2025
cf743a9
Merge branch 'master' into feat/inline_pass
harkal Jan 29, 2025
83134fa
lint
harkal Jan 29, 2025
678c80c
wrong paste
harkal Jan 29, 2025
d35bed0
loops test and fixes
HodanPlodky Jan 29, 2025
daaa20c
loops without substitution test + simple inst test
HodanPlodky Jan 29, 2025
32384f1
comments
HodanPlodky Jan 29, 2025
5ad8951
removed unreachable
HodanPlodky Jan 30, 2025
bbc4c86
small refactors
HodanPlodky Jan 30, 2025
4573c95
small refactors
HodanPlodky Jan 30, 2025
4727ba5
bb input cache
HodanPlodky Jan 30, 2025
7a59827
removed unnecessary copies
HodanPlodky Jan 30, 2025
5fb3aa3
early return in get_expression
HodanPlodky Jan 30, 2025
84cf322
lint
HodanPlodky Jan 31, 2025
1e976e7
comments in tests
HodanPlodky Jan 31, 2025
34ba28d
more test for effects
HodanPlodky Jan 31, 2025
43a059b
Merge branch 'master' into feat/cse
HodanPlodky Jan 31, 2025
0d01653
comments and removed get_operands method
HodanPlodky Jan 31, 2025
2cf6090
test renames
HodanPlodky Feb 1, 2025
1cc93db
removed _check_pre_post_fn and _check_no_change_fn
HodanPlodky Feb 1, 2025
6d43af9
wip
harkal Feb 2, 2025
6adc1c1
wip
harkal Feb 2, 2025
7d6a204
Revert "wip"
harkal Feb 2, 2025
a5e4ed8
Revert "wip"
harkal Feb 2, 2025
1941ced
Merge remote-tracking branch 'origin-vyper/master' into feat/inline_pass
harkal Feb 2, 2025
77cf70a
fix
harkal Feb 2, 2025
42e15a4
added frozen on `_Expression` class
HodanPlodky Feb 3, 2025
90e03f0
Removed unnecessary `RemovedUnusedVariablesPass`
HodanPlodky Feb 3, 2025
6a79288
remove unnecessary effect
HodanPlodky Feb 3, 2025
246dff6
updates for algebraic opts and memmerge
HodanPlodky Feb 6, 2025
ff660f2
removed stray debug msg
HodanPlodky Feb 6, 2025
95a1bf7
Added tests for mstore/dload pairs merging
HodanPlodky Feb 6, 2025
9e732f8
comment for mstore/dload merge
HodanPlodky Feb 6, 2025
f3e5691
Merge branch 'master' into feat/venom/algebraicopt-and-memmerge-update
HodanPlodky Feb 6, 2025
584d965
used `make_nop` instead of `mark_for_removal`
HodanPlodky Feb 6, 2025
b0b7ea0
removed unnecessary pass
HodanPlodky Feb 6, 2025
3621c05
added `RemovedUnusedVariablePass` back + deep effects
HodanPlodky Feb 6, 2025
30eee09
Merge branch 'master' into feat/cse
HodanPlodky Feb 6, 2025
62cf3cb
small fixes
HodanPlodky Feb 6, 2025
3fd3a0a
comment
HodanPlodky Feb 7, 2025
d5ede4f
lint
HodanPlodky Feb 7, 2025
ccdccf6
iszero can help
HodanPlodky Feb 7, 2025
fbb2da5
comment
HodanPlodky Feb 7, 2025
2085b80
review comments
charles-cooper Feb 6, 2025
8785d61
review
charles-cooper Feb 7, 2025
ea843b9
Merge branch 'master' into feat/inline_pass
harkal Feb 10, 2025
3251fec
work list
HodanPlodky Feb 10, 2025
73c7db3
lint
HodanPlodky Feb 10, 2025
86d930e
tmp
harkal Nov 19, 2024
9f6b5f4
temp
harkal Nov 20, 2024
47bd5cf
generalize
harkal Dec 16, 2024
4343b45
work
harkal Dec 16, 2024
d05c184
lint
harkal Dec 16, 2024
bc52a28
print context
harkal Dec 16, 2024
f0f127b
work
harkal Dec 16, 2024
62a9c08
print changes
harkal Dec 16, 2024
f77ce89
add operands to phi and printout
harkal Dec 16, 2024
332b6db
lint
harkal Dec 16, 2024
7f554bb
work
harkal Dec 16, 2024
b387ba1
work
harkal Dec 16, 2024
0cf9f44
merge in walker stuff
harkal Dec 17, 2024
93f131b
enable passes
harkal Dec 17, 2024
e7f61b3
cleanup
harkal Dec 17, 2024
4dbda44
use cfg pre walk and prettier output
harkal Dec 17, 2024
b4bec1a
post merge
harkal Dec 20, 2024
c8985be
swash alias stuff
harkal Dec 20, 2024
f5fa7b2
fix imports
harkal Feb 12, 2025
dcd6f22
repr fix
harkal Feb 12, 2025
a0caa85
post rebase fixes
harkal Feb 12, 2025
0797e15
Merge branch 'feat/cse' into venom
harkal Feb 12, 2025
7ba24ba
Merge branch 'venom' into feat/memssa
harkal Feb 12, 2025
f212891
Merge branch 'feat/venom/algebraicopt-and-memmerge-update' into venom
harkal Feb 12, 2025
7362708
Merge branch 'venom' into feat/memssa
harkal Feb 12, 2025
0dcc6a8
Merge branch 'venom' into feat/inline_pass
harkal Feb 12, 2025
9a1a7b2
Merge branch 'feat/memssa' into venom
harkal Feb 12, 2025
ebd87d7
Merge branch 'venom' into feat/memssa
harkal Feb 12, 2025
861510a
Merge branch 'feat/memssa' into venom
harkal Feb 12, 2025
32c8a9d
Merge branch 'venom' into feat/inline_pass
harkal Feb 12, 2025
e28e62a
use zeros to avoid linter nightmare
harkal Feb 12, 2025
38ec33b
lint
harkal Feb 12, 2025
80fb952
Merge branch 'feat/memssa' into venom
harkal Feb 12, 2025
431804a
ignoring more instructions
HodanPlodky Feb 12, 2025
a06471d
Merge branch 'master' into feat/cse
HodanPlodky Feb 12, 2025
7824ac9
Merge branch 'master' into venom
harkal Feb 13, 2025
da79364
Merge branch 'master' into feat/venom/calloca
charles-cooper Feb 13, 2025
3d3cf78
disable inliner
harkal Feb 14, 2025
8bb435a
Merge branch 'venom' into feat/inline_pass
harkal Feb 14, 2025
346aeef
equiv
harkal Feb 14, 2025
7b1bbf6
Merge branch 'feat/inline_pass' into scratch/call-conv
charles-cooper Feb 14, 2025
dfafa50
scratch - try poison for caller buf copies
charles-cooper Feb 14, 2025
0806f5c
Revert "scratch - try poison for caller buf copies"
charles-cooper Feb 14, 2025
da0420a
remove extra mstore
harkal Feb 14, 2025
cbfb22d
Merge branch 'feat/inline_pass' into scratch/call-conv
charles-cooper Feb 14, 2025
8935323
small refactor
charles-cooper Feb 14, 2025
c791b2a
rework calling convention translation
charles-cooper Feb 14, 2025
a8f620b
move is_prim_word check to callsite
charles-cooper Feb 14, 2025
0ff4a45
add notes
charles-cooper Feb 14, 2025
0e382ae
hevm tests for cse
HodanPlodky Feb 14, 2025
fba8ae3
lint
HodanPlodky Feb 14, 2025
ae28b65
Merge branch 'feat/cse' into venom-develop
harkal Feb 16, 2025
c63ca5c
simple invoke return handling
harkal Feb 17, 2025
1eb8ef3
use alloca'ed return_buf
charles-cooper Feb 17, 2025
54876f2
fix bad variable
charles-cooper Feb 17, 2025
8a392f3
return buffer
charles-cooper Feb 17, 2025
7723dc9
add comment
charles-cooper Feb 17, 2025
234a2b5
fix alloca again
charles-cooper Feb 17, 2025
4d1d842
fix bad None value
charles-cooper Feb 17, 2025
85dca7a
add ensure_well_formed util
charles-cooper Feb 17, 2025
ca92e89
fix bug
charles-cooper Feb 17, 2025
8e9e582
change heuristic
charles-cooper Feb 17, 2025
0572f58
Merge branch 'venom-develop' into feat/inline_pass
harkal Feb 17, 2025
0292ead
enable inliner
harkal Feb 17, 2025
584b7a0
fix index handling
charles-cooper Feb 17, 2025
6d46d87
by value return support for inliner
harkal Feb 18, 2025
2d6d1a3
types
harkal Feb 18, 2025
8f83ec2
cleanup
harkal Feb 18, 2025
3b71fd7
fix IROperand
charles-cooper Feb 18, 2025
889fb4c
lint
charles-cooper Feb 18, 2025
15ea0b6
don't apply mem2var for complex types in calling conv
charles-cooper Feb 18, 2025
09e09d6
guard changed code with new call conv flag
charles-cooper Feb 18, 2025
b9f5dd7
improve assertion message
charles-cooper Feb 18, 2025
d3a7b32
hide another piece of call conv code behind flag
charles-cooper Feb 18, 2025
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
4 changes: 3 additions & 1 deletion tests/unit/compiler/asm/test_asm_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@ def foo():
input_bundle = make_input_bundle({"library.vy": library})
res = compile_code(code, input_bundle=input_bundle, output_formats=["asm"])
asm = res["asm"]
assert "some_function()" in asm

if not experimental_codegen:
assert "some_function()" in asm # Venom function inliner will remove this

assert "unused1()" not in asm
assert "unused2()" not in asm
Expand Down
9 changes: 8 additions & 1 deletion tests/unit/compiler/test_source_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,23 @@ def test_jump_map(optimize, experimental_codegen):
jump_map = source_map["pc_jump_map"]

expected_jumps = 1
expected_internals = 2
if optimize == OptimizationLevel.NONE:
# some jumps which don't get optimized out when optimizer is off
# (slightly different behavior depending if venom pipeline is enabled):
if not experimental_codegen:
expected_jumps = 3
else:
expected_jumps = 2
else:
if not experimental_codegen:
expected_internals = 2
else:
expected_jumps = 0
expected_internals = 0

assert len([v for v in jump_map.values() if v == "o"]) == expected_jumps
assert len([v for v in jump_map.values() if v == "i"]) == 2
assert len([v for v in jump_map.values() if v == "i"]) == expected_internals

code_lines = [i + "\n" for i in TEST_CODE.split("\n")]
for pc in [k for k, v in jump_map.items() if v == "o"]:
Expand Down
112 changes: 112 additions & 0 deletions tests/unit/compiler/venom/test_call_conv.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
def test_simple_call(get_contract):
code = """
@internal
def name(_name: uint256) -> uint256:
return _name + 1


@external
def foo(x: uint256) -> uint256:
u: uint256 = 1 + x
ret: uint256 = self.name(u + 10)
return ret
"""

c = get_contract(code)
assert c.foo(1) == 13


def test_simple_call_multiple_args_in_call(get_contract):
code = """
@internal
def bar(_name: uint256, _name2: uint256) -> uint256:
return _name + 10

@external
def foo(x: uint256) -> uint256:
ret: uint256 = self.bar(20, 10)
return ret
"""

c = get_contract(code)
assert c.foo(1) == 30


def test_simple_call_multiple_args(get_contract):
code = """
@internal
def bar(_name: uint256, _name2: uint256) -> (uint256, uint256):
return _name + 1, _name + 2

@external
def foo(x: uint256) -> (uint256, uint256):
ret: (uint256, uint256) = self.bar(20, 10)
return ret
"""

c = get_contract(code)
assert c.foo(1) == (21, 22)


def test_call_in_call(get_contract):
code = """
@internal
def _foo(a: uint256) -> uint256:
return a

@external
def foo() -> uint256:
a: uint256 = 1
return self._foo(a)
"""

c = get_contract(code)

assert c.foo() == 1


def test_2d_array_input_1(get_contract):
code = """
@internal
def test_input(arr: DynArray[DynArray[int128, 2], 1]) -> DynArray[DynArray[int128, 2], 1]:
return arr

@external
def test_values(arr: DynArray[DynArray[int128, 2], 1]) -> DynArray[DynArray[int128, 2], 1]:
return self.test_input(arr)
"""

c = get_contract(code)
assert c.test_values([[1, 2]]) == ([[1, 2]])


def test_call_with_unused_params(get_contract):
code = """
@internal
def _foo3(a: uint256, b: uint256) -> uint256:
return 42

@external
def foo() -> uint256:
return self._foo3(9, 11)
"""

c = get_contract(code)

assert c.foo() == 42


def test_internal_assign(get_contract):
code = """
@internal
def foo(x: uint256) -> uint256:
x = 10
return x

@external
def bar(x: uint256) -> uint256:
return self.foo(x)
"""
c = get_contract(code)

assert c.bar(70) == 10
Loading
Loading