-
-
Notifications
You must be signed in to change notification settings - Fork 836
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
harkal
wants to merge
311
commits into
vyperlang:master
Choose a base branch
from
harkal:feat/inline_pass
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 91 commits
Commits
Show all changes
311 commits
Select commit
Hold shift + click to select a range
44fb876
Merge branch 'master' into feat/cse
HodanPlodky 45c3612
add some review
charles-cooper 5e7f603
basic refactors and bit of improvement
HodanPlodky 2434789
Merge branch 'master' into feat/cse
HodanPlodky 709dc4d
Merge branch 'master' into feat/cse
HodanPlodky 33f3dae
weird patch
HodanPlodky 4e36a9c
different way of same fuction implementation
HodanPlodky dc07dff
small cleanup and more unintresting instruction
HodanPlodky 4d57171
removed depth
HodanPlodky 1a9c9ab
lint
HodanPlodky 639d70b
removed forgoten comment
HodanPlodky bd89aae
Merge branch 'master' into feat/cse
HodanPlodky c75a273
feat[venom]: add calloca instruction
charles-cooper c647456
save/restore alloca table inside functions
charles-cooper f660a3c
float calloca
charles-cooper 5591c53
Merge branch 'master' into feat/cse
HodanPlodky 23d1267
add callsite to calloca
charles-cooper 9b1a92d
Merge branch 'master' into feat/cse
HodanPlodky 3275824
update readme
charles-cooper ca1c09d
Merge branch 'master' into feat/venom/calloca
charles-cooper a26b503
formatting
charles-cooper ef3ad9c
Merge branch 'master' into feat/venom/calloca
charles-cooper 5cef52e
Merge branch 'master' into feat/venom/calloca
charles-cooper 2065480
Merge branch 'master' into feat/venom/calloca
charles-cooper c16d171
remove callsite from calloca
charles-cooper 8238831
init
harkal c54273c
add fcg
harkal 5565d4c
func inliner
harkal 5f01394
params
harkal 6b88eed
helpers
harkal 2b19059
global opti
harkal 7d144de
work
harkal fe9f39a
refactor
harkal 051225a
float
harkal 1997b25
codename `asylum`
harkal 027a2eb
more conservative
harkal d79c6d9
disable load elimination
harkal ca1ba5f
export func for repl
harkal 7508436
first function is entry
harkal 1257fd4
debuging aids
harkal d4893bd
work
harkal a1f76b6
fix grammar
harkal b4b4ae6
test
harkal a4d4ea9
lint
harkal 7c79be7
mem2var debug
charles-cooper 29ece7c
update varname in mem2var
charles-cooper 542c115
invalidate dfg
harkal a376e88
polish store elimination
charles-cooper 33fd262
test update
harkal 30e0c79
remove superflus passes
harkal c6c3c8a
testing
harkal 020b9b2
Merge branch 'master' into feat/inline_pass
harkal 2ef4df6
helper
harkal 7341c04
handle reverts
harkal 757563d
add tests
harkal bf0ebb3
cleanup
harkal 289d683
bounds
harkal 674fb50
refactors
harkal 057246c
Merge branch 'master' into feat/inline_pass
harkal 05adb1a
refactor, lint, cleanup
harkal 4a2041f
debug
harkal 4878398
work
harkal 385e59f
recursive inline out
harkal af699c6
add has block method
harkal 33d8ffd
make "consts".. "private"
harkal dab4060
temp
harkal 476b9de
inliner
harkal 6fd42ef
fix var equivalance
harkal 4e602b9
lint
harkal 5d0ac96
comment wip stuff
harkal 828e623
make cost a function
harkal 2d5d872
Merge branch 'master' into feat/inline_pass
harkal ad2e8b7
dfg equiv
harkal 6bf03ec
drop var equivalence
harkal 6ca95a6
lint
harkal d4dcc8e
Merge branch 'master' into feat/cse
HodanPlodky 06c627f
effect IMMUTABLE can interfere with MEMORY
HodanPlodky 0971f58
early return
HodanPlodky eb136b8
Merge branch 'master' into feat/cse
HodanPlodky 82a5ebc
Merge branch 'master' into feat/inline_pass
harkal e4c43c7
add function signature to ir_node passthrough metadata
charles-cooper 79be32a
add a comment
charles-cooper 319ddd4
Merge branch 'master' into feat/venom/calloca
charles-cooper 6cd1927
better handling of available expressions
HodanPlodky 08a0bd4
lint
HodanPlodky 752b70f
Merge branch 'master' into feat/cse
HodanPlodky 938c144
lint
HodanPlodky ab04c84
removed unused
HodanPlodky 58393ec
Merge branch 'master' into feat/cse
HodanPlodky bb31c40
passthroug
harkal 9d17a79
assert
harkal aba2afc
params
harkal 2e6c79b
temp
harkal 7380f52
Merge branch 'master' into feat/inline_pass
harkal 29c1302
fix edge case in mem2var
harkal cac9d4c
post merge
harkal f04400c
temp
harkal 7fe033d
tmep
harkal 733e3b2
fix
harkal e54bd0f
comment out
harkal 3cdbb48
dfg linting
harkal 70ff390
lint
harkal eaef2a4
sccp fixes
harkal 8a35af2
inter bb
HodanPlodky e66b348
order fix
HodanPlodky abd12cd
add back
harkal d98dbcd
enable more
harkal 317cfb5
fix
harkal 0234851
new failing test
harkal bd82d5c
venom -> evm changed
harkal abba8ca
internal update test case
harkal 3552bae
get param by name
harkal b61009b
store
harkal 7d44552
fix
harkal 1d212ac
fixes for inter bb
HodanPlodky d3e2d64
removed unused code
HodanPlodky 9ca6609
Merge branch 'master' into feat/cse
HodanPlodky 5e406d5
small change in removing instructions
HodanPlodky 09afa3e
merge
HodanPlodky 4755b12
test rewrite with new parser + small fix
HodanPlodky 75d1a44
start
harkal 9f3eac0
Revert "start"
harkal 0b50b4b
new cc on all prims
harkal 3093987
bugfix
harkal 4e19321
fixes and cleanup
harkal 042f584
non indempotent instruction test
HodanPlodky fb21434
param support in inliner
harkal b1df259
failing test
harkal 642dcb2
no return handling
harkal cf743a9
Merge branch 'master' into feat/inline_pass
harkal 83134fa
lint
harkal 678c80c
wrong paste
harkal d35bed0
loops test and fixes
HodanPlodky daaa20c
loops without substitution test + simple inst test
HodanPlodky 32384f1
comments
HodanPlodky 5ad8951
removed unreachable
HodanPlodky bbc4c86
small refactors
HodanPlodky 4573c95
small refactors
HodanPlodky 4727ba5
bb input cache
HodanPlodky 7a59827
removed unnecessary copies
HodanPlodky 5fb3aa3
early return in get_expression
HodanPlodky 84cf322
lint
HodanPlodky 1e976e7
comments in tests
HodanPlodky 34ba28d
more test for effects
HodanPlodky 43a059b
Merge branch 'master' into feat/cse
HodanPlodky 0d01653
comments and removed get_operands method
HodanPlodky 2cf6090
test renames
HodanPlodky 1cc93db
removed _check_pre_post_fn and _check_no_change_fn
HodanPlodky 6d43af9
wip
harkal 6adc1c1
wip
harkal 7d6a204
Revert "wip"
harkal a5e4ed8
Revert "wip"
harkal 1941ced
Merge remote-tracking branch 'origin-vyper/master' into feat/inline_pass
harkal 77cf70a
fix
harkal 42e15a4
added frozen on `_Expression` class
HodanPlodky 90e03f0
Removed unnecessary `RemovedUnusedVariablesPass`
HodanPlodky 6a79288
remove unnecessary effect
HodanPlodky 246dff6
updates for algebraic opts and memmerge
HodanPlodky ff660f2
removed stray debug msg
HodanPlodky 95a1bf7
Added tests for mstore/dload pairs merging
HodanPlodky 9e732f8
comment for mstore/dload merge
HodanPlodky f3e5691
Merge branch 'master' into feat/venom/algebraicopt-and-memmerge-update
HodanPlodky 584d965
used `make_nop` instead of `mark_for_removal`
HodanPlodky b0b7ea0
removed unnecessary pass
HodanPlodky 3621c05
added `RemovedUnusedVariablePass` back + deep effects
HodanPlodky 30eee09
Merge branch 'master' into feat/cse
HodanPlodky 62cf3cb
small fixes
HodanPlodky 3fd3a0a
comment
HodanPlodky d5ede4f
lint
HodanPlodky ccdccf6
iszero can help
HodanPlodky fbb2da5
comment
HodanPlodky 2085b80
review comments
charles-cooper 8785d61
review
charles-cooper ea843b9
Merge branch 'master' into feat/inline_pass
harkal 3251fec
work list
HodanPlodky 73c7db3
lint
HodanPlodky 86d930e
tmp
harkal 9f6b5f4
temp
harkal 47bd5cf
generalize
harkal 4343b45
work
harkal d05c184
lint
harkal bc52a28
print context
harkal f0f127b
work
harkal 62a9c08
print changes
harkal f77ce89
add operands to phi and printout
harkal 332b6db
lint
harkal 7f554bb
work
harkal b387ba1
work
harkal 0cf9f44
merge in walker stuff
harkal 93f131b
enable passes
harkal e7f61b3
cleanup
harkal 4dbda44
use cfg pre walk and prettier output
harkal b4bec1a
post merge
harkal c8985be
swash alias stuff
harkal f5fa7b2
fix imports
harkal dcd6f22
repr fix
harkal a0caa85
post rebase fixes
harkal 0797e15
Merge branch 'feat/cse' into venom
harkal 7ba24ba
Merge branch 'venom' into feat/memssa
harkal f212891
Merge branch 'feat/venom/algebraicopt-and-memmerge-update' into venom
harkal 7362708
Merge branch 'venom' into feat/memssa
harkal 0dcc6a8
Merge branch 'venom' into feat/inline_pass
harkal 9a1a7b2
Merge branch 'feat/memssa' into venom
harkal ebd87d7
Merge branch 'venom' into feat/memssa
harkal 861510a
Merge branch 'feat/memssa' into venom
harkal 32c8a9d
Merge branch 'venom' into feat/inline_pass
harkal e28e62a
use zeros to avoid linter nightmare
harkal 38ec33b
lint
harkal 80fb952
Merge branch 'feat/memssa' into venom
harkal 431804a
ignoring more instructions
HodanPlodky a06471d
Merge branch 'master' into feat/cse
HodanPlodky 7824ac9
Merge branch 'master' into venom
harkal da79364
Merge branch 'master' into feat/venom/calloca
charles-cooper 3d3cf78
disable inliner
harkal 8bb435a
Merge branch 'venom' into feat/inline_pass
harkal 346aeef
equiv
harkal 7b1bbf6
Merge branch 'feat/inline_pass' into scratch/call-conv
charles-cooper dfafa50
scratch - try poison for caller buf copies
charles-cooper 0806f5c
Revert "scratch - try poison for caller buf copies"
charles-cooper da0420a
remove extra mstore
harkal cbfb22d
Merge branch 'feat/inline_pass' into scratch/call-conv
charles-cooper 8935323
small refactor
charles-cooper c791b2a
rework calling convention translation
charles-cooper a8f620b
move is_prim_word check to callsite
charles-cooper 0ff4a45
add notes
charles-cooper 0e382ae
hevm tests for cse
HodanPlodky fba8ae3
lint
HodanPlodky ae28b65
Merge branch 'feat/cse' into venom-develop
harkal c63ca5c
simple invoke return handling
harkal 1eb8ef3
use alloca'ed return_buf
charles-cooper 54876f2
fix bad variable
charles-cooper 8a392f3
return buffer
charles-cooper 7723dc9
add comment
charles-cooper 234a2b5
fix alloca again
charles-cooper 4d1d842
fix bad None value
charles-cooper 85dca7a
add ensure_well_formed util
charles-cooper ca92e89
fix bug
charles-cooper 8e9e582
change heuristic
charles-cooper 0572f58
Merge branch 'venom-develop' into feat/inline_pass
harkal 0292ead
enable inliner
harkal 584b7a0
fix index handling
charles-cooper 6d46d87
by value return support for inliner
harkal 2d6d1a3
types
harkal 8f83ec2
cleanup
harkal 3b71fd7
fix IROperand
charles-cooper 889fb4c
lint
charles-cooper 15ea0b6
don't apply mem2var for complex types in calling conv
charles-cooper 09e09d6
guard changed code with new call conv flag
charles-cooper b9f5dd7
improve assertion message
charles-cooper d3a7b32
hide another piece of call conv code behind flag
charles-cooper File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import pytest | ||
|
||
from tests.evm_backends.base_env import ExecutionReverted | ||
|
||
|
||
def test_call_in_call(get_contract): | ||
code = """ | ||
@internal | ||
def _foo(a: uint256,) -> uint256: | ||
return 1 + a | ||
|
||
@internal | ||
def _foo2() -> uint256: | ||
return 4 | ||
|
||
@external | ||
def foo() -> uint256: | ||
return self._foo(self._foo2()) | ||
""" | ||
|
||
c = get_contract(code) | ||
assert c.foo() == 5 | ||
|
||
|
||
def test_call_in_call_with_raise(get_contract): | ||
code = """ | ||
@internal | ||
def sum(a: uint256) -> uint256: | ||
if a > 1: | ||
return a + 1 | ||
raise | ||
|
||
@internal | ||
def middle(a: uint256) -> uint256: | ||
return self.sum(a) | ||
|
||
@external | ||
def test(a: uint256) -> uint256: | ||
return self.middle(a) | ||
""" | ||
|
||
c = get_contract(code) | ||
|
||
assert c.test(2) == 3 | ||
|
||
with pytest.raises(ExecutionReverted): | ||
c.test(0) | ||
|
||
|
||
def test_inliner_with_unused_param(get_contract): | ||
code = """ | ||
data: public(uint256) | ||
|
||
@internal | ||
def _foo(start: uint256, length: uint256): | ||
self.data = start | ||
|
||
@external | ||
def foo(x: uint256, y: uint256): | ||
self._foo(x, y) | ||
""" | ||
|
||
c = get_contract(code) | ||
c.foo(1, 2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import itertools | ||
|
||
from tests.venom_utils import parse_from_basic_block | ||
from vyper.venom.analysis import DFGAnalysis, IRAnalysesCache | ||
from vyper.venom.basicblock import IRVariable | ||
from vyper.venom.context import IRContext | ||
|
||
|
||
def _entry_fn(ctx: "IRContext"): | ||
# TODO: make this part of IRContext | ||
return next(iter(ctx.functions.values())) | ||
|
||
|
||
def test_variable_equivalence_dfg_order(): | ||
a_code = """ | ||
main: | ||
%1 = 1 | ||
%2 = %1 | ||
%3 = %2 | ||
""" | ||
# technically invalid code, but variable equivalence should handle | ||
# it either way | ||
b_code = """ | ||
main: | ||
%3 = %2 | ||
%2 = %1 | ||
%1 = 1 | ||
""" | ||
fn1 = _entry_fn(parse_from_basic_block(a_code)) | ||
fn2 = _entry_fn(parse_from_basic_block(b_code)) | ||
|
||
dfg1 = IRAnalysesCache(fn1).request_analysis(DFGAnalysis) | ||
dfg2 = IRAnalysesCache(fn2).request_analysis(DFGAnalysis) | ||
|
||
vars_ = map(IRVariable, ("%1", "%2", "%3")) | ||
for var1, var2 in itertools.combinations(vars_, 2): | ||
assert dfg1.are_equivalent(var1, var2) | ||
assert dfg2.are_equivalent(var1, var2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#4411