-
-
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]: implement mem2var
and sccp
passes
#3941
Merged
Merged
Changes from 250 commits
Commits
Show all changes
563 commits
Select commit
Hold shift + click to select a range
aff18ad
added comment
harkal 560e4a9
remove debugging leftover
harkal b942c03
rename members
harkal 0c066f6
lint
harkal 54feec4
assert there is a producing instruction
harkal 0b5e764
remove unnecessary check
harkal 20536bf
variable name elaboration
harkal 2a404cc
add documentation
harkal 6259962
update dominator users
harkal 3c88c50
lint
charles-cooper 50146d1
depth first
harkal 06d216f
lint
harkal d72a41f
add volatile instruction
harkal 46fe757
fix dominator test
harkal 1325d48
revert
harkal ef78ccf
before cleanup
harkal 86acccb
improvements to OrderedSet performance
charles-cooper fbe4e28
index basic blocks
charles-cooper 6ebf977
add comment
charles-cooper bcfa42d
OrderedSet hide dict implementation better
charles-cooper 3e4de66
cleanupo
harkal 84a02d7
mark test
harkal afa5173
some more small optimizations
charles-cooper 58e1a33
fix a couple tests
charles-cooper 0e59adb
Merge pull request #5 from charles-cooper/perf/venom
harkal 8bc466f
fix workflow
harkal 6f9923e
lint
harkal 66977b4
remove some xfails
charles-cooper fb5d87d
Merge branch 'master' into feature/venom_updates
charles-cooper 91ea9bd
lint
harkal 544c90c
add some comments, sanity check
charles-cooper c05bcff
add some review comments
charles-cooper 91a9401
fix cursed __repr__ function
charles-cooper 0a0d592
Merge branch 'master' into feature/venom_updates
harkal 15573c4
Merge branch 'feature/venom_updates' of github.com:harkal/vyper into …
harkal 10d3c82
lint
harkal affdb09
change mstore evaluation order
harkal 9909513
protect b from double evaluation
harkal c3b4dc7
revert mstore evaluation order
harkal 193f275
Merge branch 'feature/venom_updates' into feature/sccp
harkal 64c107d
update dominator tree usage
harkal cedd518
Merge branch 'master' into feature/venom_updates
harkal b1ba5cb
add review
charles-cooper ebf776e
refactor dominator tree constructor
harkal 8400481
rename variables, refactor code
harkal 52c6f61
commenting
harkal a5a1844
add DominatorTree.build_dominator_tree()
harkal 3e53d7f
Merge branch 'master' into feature/venom_updates
harkal fec8b84
ensure revaluation order for select
harkal 85bbd8c
Merge branch 'master' into feature/venom_updates
harkal 50cb1b4
lint
harkal 4a8a472
Update vyper/codegen/stmt.py
harkal 4beaaa4
unlint
harkal f57a9d1
verify phi placement
harkal 6099dae
Merge branch 'feature/venom_updates' of github.com:harkal/vyper into …
harkal fece7b1
remove stray alloca
harkal 7ac26d8
Merge branch 'feature/venom_updates' into feature/sccp
harkal 34eba09
missplaced comment
harkal 9206f81
Merge branch 'feature/venom_updates' into feature/sccp
harkal 14f00b3
handle unused
harkal 664cd8f
Add arithmetic optimization to SCCP pass
harkal bf0b217
Add constant propagation method to SCCP pass
harkal 1c6d6f0
make settings into a global object
charles-cooper 319be84
do not perform deallocation in venom pipeline
charles-cooper a047691
wip -- change new_variable to return IRnode with alloca metadata instead
charles-cooper b79403a
pass thru alloca in gep
charles-cooper 685164c
fix a fixture scope
charles-cooper 73a68f1
use more add_ofst / fix instances where IRnodes are not expected
charles-cooper 21eefb3
fix some more instances
charles-cooper 5518af3
fix a comment
charles-cooper 4a3bd4b
fix bad evm_version fixture
charles-cooper b37d4d9
fix some fixtures
charles-cooper a5dd7bb
small fix
charles-cooper 597d00a
fix another builtin bug
charles-cooper 75169cc
fix typo
charles-cooper aa19207
fix a bad from_list
charles-cooper ab9d60f
last fixes
charles-cooper 0f75973
simplify alloca, lint
charles-cooper 3221c1c
update alloca check
charles-cooper 5adc7d4
fix with variable shadowing
charles-cooper 42289dd
update alloca generation
charles-cooper 593d2ee
remove memory elision code
charles-cooper b22ab61
remove mload and mstore handling in ir_node_to_venom
charles-cooper 77427f6
lint
charles-cooper 607502d
fix buf in revert with reason
charles-cooper 24d7eac
fix a variable lookup
charles-cooper df3b5b8
Merge branch 'master' into venom-alloca
charles-cooper f7d9432
fix order of arguments
charles-cooper e41e6d6
fix bad variable
charles-cooper 00bc095
fix another variable
charles-cooper 5c3231b
remove mstore from passthru instructions, add argument names
charles-cooper 7569a34
another variable rename
charles-cooper ca4a817
Add Mem2Stack pass to optimize memory usage
harkal 55b852e
Refactor IRPass class to use instance methods instead of class methods
harkal 345f9f5
Update code to use pass instances
harkal 6fb76e2
Update tests to use pass instances
harkal 53587b9
Merge branch 'fix/use_pass_instances' into mem2stack
harkal d529b4b
Merge branch 'fix/use_pass_instances' into feature/sccp
harkal 6fcea4d
remove parameters
harkal f8d88d2
remove test
harkal 37a8985
Remove unnecessary __eq__ method from IRVariable class
harkal 4a6fd78
revert symbols change
charles-cooper b0e918e
fix operand order
charles-cooper 1a27693
fix a defaults test
charles-cooper b908cae
Merge branch 'venom-alloca' into mem2stack
harkal ebf38d9
Refactor Mem2Stack pass to use DFG outputs
harkal 731da63
Refactor Mem2Stack pass and MakeSSA pass
harkal 4dd5384
Merge branch 'mem2stack' into feature/sccp
harkal 53d1711
Merge branch 'master' into feature/sccp
harkal d372ad9
wip -- different kind of alloca for internal function params
charles-cooper 5c18284
temp
harkal b28ac5a
Merge branch 'venom-alloca' into feature/sccp
harkal 6799b97
param alloca
harkal b193c70
Add global symbol tracking in ir_node_to_venom.py
harkal a60fa6c
temp commit
harkal 8d6699a
Refactor memory allocation to use stack
harkal 69e3ec1
Refactor if-else block in ir_node_to_venom.py
harkal ce9f447
add global symbol saving/restoring for repeat body
harkal 3c48258
enable sccp
harkal 1a424c5
run sccp on all functions
harkal 9dcd136
Merge branch 'master' into feature/sccp
harkal a8e8576
remove unused parameter
harkal 07ba210
fix merge accident
harkal f8b5a04
cleanup
harkal 8036078
refactor
harkal b09cddf
lint
harkal 432b830
fix
harkal efd533a
fixes
harkal 2298a27
refactor class hierarchy
harkal 63a6d84
use new class structure and `is_` functions
harkal 29ae288
refactor IROperand as base
harkal 0fbd68a
lint
harkal ea34e4d
remove unused member
harkal b1a8c37
Merge branch 'refactor/venom_classes' into feature/sccp
harkal ae53c2d
refactors
harkal fae87ba
Refactor IROperand checks to use isinstance() instead of custom funct…
harkal 273f814
Merge branch 'master' into refactor/venom_classes
harkal cbd6a13
Merge branch 'refactor/venom_classes' into feature/sccp
harkal 213b205
use isinstance
harkal f3be009
Merge branch 'master' into feature/sccp
harkal 0e44392
constant jump optimization
harkal b04e08c
lint
harkal 200f816
`nop` instruction
harkal 313881a
temp
harkal 2b69335
Fix SCCP algorithm and add conditional jump optimization
harkal dde71b9
Fix SCCP propagation bug
harkal 78efcf7
Remove phi operand method
harkal 1647e3e
Updated unreachable block elimination with new phi
harkal 9a04a28
Fix phi operand bug in SCCP pass
harkal 50fbdd8
Refactor SCCP pass to propagate variables for cleaner code for humans
harkal 9055dca
reverse condition order
harkal dcea498
Refactor SCCP pass files and evaluation functions
harkal 2c30b7c
Add CEILING_UINT256 constant to SizeLimits class
harkal 0f92f1e
clean sccp
harkal dcaaefd
Refactor arithmetic operations in SCCP evaluation
harkal cda1348
Update arithmetic operations in SCCP
harkal 6e3d7fc
fix phi issue
harkal c75c89c
fixes
harkal ddb5795
Merge branch 'master' into feature/sccp
harkal 05194e3
Merge branch 'master' into feature/sccp
harkal d116cc1
Fix operand order in binary operations and add new EVM instructions
harkal ee833ed
block optimization and remove unreachable blocks
harkal b12717a
Commented out SCCP pass and rearranged code
harkal 779ce77
Fix operand order in EVM shift operations
harkal 5ae8ede
Refactor Mem2Stack pass and add variable propagation
harkal 1e93650
enable for internals
harkal 53fcc75
Add _evm_not function to handle bitwise NOT operation
harkal 85e6ad8
update test cases in test_sccp
harkal 536af1e
fix branch selection logic to actually use _meet()
harkal ca97135
disable variable propagation
harkal b29975d
fixes
harkal dd481fc
fix exp evaluation
harkal f4b2fdc
lint
harkal d2d053d
Refactor exp in SCCP evaluation
harkal 7c232b0
fix successor phis
harkal 36da602
Fix incorrect lattice values in test_sccp.py
harkal 153844a
Fix signed integer operations in SCCP evaluation
harkal 184f371
add `abort` venom instruction
harkal 393b290
Swap order of operands in _evm_signextend function
harkal 234b208
Remove xfail markers from test functions
harkal c5ac59a
bugfix DFT
harkal 2354c8a
Remove unused code and add new instruction "abort"
harkal 63e2300
cleanup
harkal 6016d1b
Merge branch 'master' into feature/sccp
harkal a76341a
Add type hinting for ARITHMETIC_OPS dictionary
harkal 8c728b0
lint
harkal 4a8def3
Remove unused imports
harkal 96abd9f
lint
harkal 2a5e22b
raise CompilerPanic for unimplemented djmp with literal
harkal 9f9f1da
lint
harkal cbd5a58
Remove unused imports and optimize imports in venom/__init__.py
harkal 8a7024f
refactor sccp code
harkal ca40950
Enable liveness display in IRInstruction class
harkal 1b227f7
return iterators when posible
harkal adcbda7
Remove commented code in ir_node_to_venom.py
harkal 8047ce1
Remove unused function
harkal 073ddd2
Refactor `self.uses` handling to simplify code
harkal 4e41719
comments and a small optimization
harkal 5506b40
comments and cleanup
harkal cbec0a5
Remove unused code
harkal ac841ec
add comment
harkal b5548eb
lint
harkal c2a17ed
Remove `abort` opcode, make false assertions into compile error
harkal 34593bf
assertion failure and add get_ast_source method
harkal 2a77c88
fix signextend
harkal 225c593
lint
harkal 975d4eb
`ast_source` made into `IRnode`
harkal 1238c96
formatting
harkal b184206
update tests for venom compile time asserts
harkal 9545e36
formatting
harkal b105a01
update test for venom compile type assert
harkal e602265
remove unsused local
harkal 19c6a77
Merge branch 'master' into feature/sccp
harkal d234400
use `pytest.raises()'
harkal 02bcf8b
snakecasefy
harkal e684bd4
rename functions
harkal 8bda3f9
bound iterations
harkal 298504f
lint
harkal 913124f
right right shift
harkal 75a0bcb
Panic for too many iterations in SimplifyCFGPass
harkal 238d28e
refactor
harkal 09cb6ce
make use of vyper signed/unsigned conversion utility functions
harkal eba81af
Refactor EVM evaluation functions
harkal c778fbb
refactor _evm_iszero function
harkal b01b9af
Add input value bounds checks in SCCP evaluation functions
harkal 6bd1822
remove masking
harkal 93ae7ed
Merge branch 'master' into feature/sccp
harkal 5cd9c3e
Rename Mem2Stack to Mem2Var
harkal 1d0ae1c
generalize `mstore` insertion before `return`
harkal c83940a
remove fast paths
harkal 13d7cc2
use snake_case naming convention
harkal 40ad200
remove basic_block from SSAWorkItem
harkal 251181d
rename `vars` to `in_vars`
harkal bc95d0c
Move `cfg_in_exec` to `SCCP`
harkal a318522
remove fast return
harkal 1c8df40
nbytes
harkal cf478ed
Raise invalid work item type handling in SCCP
harkal 34354a0
Merge branch 'master' into feature/sccp
harkal 3c3072c
Reform type assertion in IRInstruction class
harkal be86cbf
refactor
harkal ea0b57f
remove unused self.dom
harkal 5e2be93
add back check
harkal 3769faa
remove unused import
harkal a8a6951
oob tests for compile/run time
harkal 4bb67fb
lint
harkal e3b40d1
Merge branch 'master' into feature/sccp
charles-cooper 3dca106
Fix typo in simplify_cfg.py
harkal 4c3b252
compile/runtime tests
harkal 2bee449
Fix typo
harkal 8bd05a9
reference wegman+zadeck
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 |
---|---|---|
@@ -1,5 +1,7 @@ | ||
import pytest | ||
|
||
from vyper.exceptions import StaticAssertionException | ||
|
||
|
||
def test_basic_repeater(get_contract_with_gas_estimation): | ||
basic_repeater = """ | ||
|
@@ -271,17 +273,21 @@ def test(): | |
|
||
|
||
@pytest.mark.parametrize("typ", ["uint8", "int128", "uint256"]) | ||
def test_for_range_oob_check(get_contract, tx_failed, typ): | ||
def test_for_range_oob_check(get_contract, tx_failed, typ, experimental_codegen): | ||
code = f""" | ||
@external | ||
def test(): | ||
x: {typ} = max_value({typ}) | ||
for i: {typ} in range(x, x + 2, bound=2): | ||
pass | ||
""" | ||
c = get_contract(code) | ||
with tx_failed(): | ||
c.test() | ||
if experimental_codegen: | ||
with pytest.raises(StaticAssertionException): | ||
get_contract(code) | ||
else: | ||
c = get_contract(code) | ||
with tx_failed(): | ||
c.test() | ||
|
||
|
||
@pytest.mark.parametrize("typ", ["int128", "uint256"]) | ||
|
@@ -416,7 +422,7 @@ def foo(a: {typ}) -> {typ}: | |
assert c.foo(0) == 31337 | ||
|
||
|
||
def test_for_range_signed_int_overflow(get_contract, tx_failed): | ||
def test_for_range_signed_int_overflow(get_contract, tx_failed, experimental_codegen): | ||
code = """ | ||
@external | ||
def foo() -> DynArray[int256, 10]: | ||
|
@@ -427,6 +433,11 @@ def foo() -> DynArray[int256, 10]: | |
res.append(i) | ||
return res | ||
""" | ||
c = get_contract(code) | ||
with tx_failed(): | ||
c.foo() | ||
|
||
if experimental_codegen: | ||
with pytest.raises(StaticAssertionException): | ||
get_contract(code) | ||
else: | ||
c = get_contract(code) | ||
with tx_failed(): | ||
c.foo() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should change the code as above so the runtime check is appropriately checked |
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 |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
from vyper.exceptions import ( | ||
InvalidOperation, | ||
OverflowException, | ||
StaticAssertionException, | ||
TypeMismatch, | ||
ZeroDivisionException, | ||
) | ||
|
@@ -73,18 +74,22 @@ def foo(x: int256) -> int256: | |
|
||
# TODO: make this test pass | ||
@pytest.mark.parametrize("base", (0, 1)) | ||
def test_exponent_negative_power(get_contract, tx_failed, base): | ||
def test_exponent_negative_power(get_contract, tx_failed, base, experimental_codegen): | ||
# #2985 | ||
code = f""" | ||
@external | ||
def bar() -> int16: | ||
x: int16 = -2 | ||
return {base} ** x | ||
""" | ||
c = get_contract(code) | ||
# known bug: 2985 | ||
with tx_failed(): | ||
c.bar() | ||
if experimental_codegen: | ||
with pytest.raises(StaticAssertionException): | ||
get_contract(code) | ||
else: | ||
c = get_contract(code) | ||
# known bug: 2985 | ||
with tx_failed(): | ||
c.bar() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto |
||
|
||
|
||
def test_exponent_min_int16(get_contract): | ||
|
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,139 @@ | ||
from vyper.venom.basicblock import IRBasicBlock, IRLabel, IRVariable | ||
from vyper.venom.function import IRFunction | ||
from vyper.venom.passes.make_ssa import MakeSSA | ||
from vyper.venom.passes.sccp import SCCP | ||
from vyper.venom.passes.sccp.sccp import LatticeEnum | ||
|
||
|
||
def test_simple_case(): | ||
ctx = IRFunction(IRLabel("_global")) | ||
|
||
bb = ctx.get_basic_block() | ||
p1 = bb.append_instruction("param") | ||
op1 = bb.append_instruction("store", 32) | ||
op2 = bb.append_instruction("store", 64) | ||
op3 = bb.append_instruction("add", op1, op2) | ||
bb.append_instruction("return", p1, op3) | ||
|
||
make_ssa_pass = MakeSSA() | ||
make_ssa_pass.run_pass(ctx, ctx.basic_blocks[0]) | ||
sccp = SCCP(make_ssa_pass.dom) | ||
sccp.run_pass(ctx, ctx.basic_blocks[0]) | ||
|
||
assert sccp.lattice[IRVariable("%1")] == LatticeEnum.BOTTOM | ||
assert sccp.lattice[IRVariable("%2")].value == 32 | ||
assert sccp.lattice[IRVariable("%3")].value == 64 | ||
assert sccp.lattice[IRVariable("%4")].value == 96 | ||
|
||
|
||
def test_cont_jump_case(): | ||
ctx = IRFunction(IRLabel("_global")) | ||
|
||
bb = ctx.get_basic_block() | ||
|
||
br1 = IRBasicBlock(IRLabel("then"), ctx) | ||
ctx.append_basic_block(br1) | ||
br2 = IRBasicBlock(IRLabel("else"), ctx) | ||
ctx.append_basic_block(br2) | ||
|
||
p1 = bb.append_instruction("param") | ||
op1 = bb.append_instruction("store", 32) | ||
op2 = bb.append_instruction("store", 64) | ||
op3 = bb.append_instruction("add", op1, op2) | ||
bb.append_instruction("jnz", op3, br1.label, br2.label) | ||
|
||
br1.append_instruction("add", op3, 10) | ||
br1.append_instruction("stop") | ||
br2.append_instruction("add", op3, p1) | ||
br2.append_instruction("stop") | ||
|
||
make_ssa_pass = MakeSSA() | ||
make_ssa_pass.run_pass(ctx, ctx.basic_blocks[0]) | ||
sccp = SCCP(make_ssa_pass.dom) | ||
sccp.run_pass(ctx, ctx.basic_blocks[0]) | ||
|
||
assert sccp.lattice[IRVariable("%1")] == LatticeEnum.BOTTOM | ||
assert sccp.lattice[IRVariable("%2")].value == 32 | ||
assert sccp.lattice[IRVariable("%3")].value == 64 | ||
assert sccp.lattice[IRVariable("%4")].value == 96 | ||
assert sccp.lattice[IRVariable("%5")].value == 106 | ||
assert sccp.lattice.get(IRVariable("%6")) == LatticeEnum.BOTTOM | ||
|
||
|
||
def test_cont_phi_case(): | ||
ctx = IRFunction(IRLabel("_global")) | ||
|
||
bb = ctx.get_basic_block() | ||
|
||
br1 = IRBasicBlock(IRLabel("then"), ctx) | ||
ctx.append_basic_block(br1) | ||
br2 = IRBasicBlock(IRLabel("else"), ctx) | ||
ctx.append_basic_block(br2) | ||
join = IRBasicBlock(IRLabel("join"), ctx) | ||
ctx.append_basic_block(join) | ||
|
||
p1 = bb.append_instruction("param") | ||
op1 = bb.append_instruction("store", 32) | ||
op2 = bb.append_instruction("store", 64) | ||
op3 = bb.append_instruction("add", op1, op2) | ||
bb.append_instruction("jnz", op3, br1.label, br2.label) | ||
|
||
op4 = br1.append_instruction("add", op3, 10) | ||
br1.append_instruction("jmp", join.label) | ||
br2.append_instruction("add", op3, p1, ret=op4) | ||
br2.append_instruction("jmp", join.label) | ||
|
||
join.append_instruction("return", op4, p1) | ||
|
||
make_ssa_pass = MakeSSA() | ||
make_ssa_pass.run_pass(ctx, ctx.basic_blocks[0]) | ||
|
||
sccp = SCCP(make_ssa_pass.dom) | ||
sccp.run_pass(ctx, ctx.basic_blocks[0]) | ||
|
||
assert sccp.lattice[IRVariable("%1")] == LatticeEnum.BOTTOM | ||
assert sccp.lattice[IRVariable("%2")].value == 32 | ||
assert sccp.lattice[IRVariable("%3")].value == 64 | ||
assert sccp.lattice[IRVariable("%4")].value == 96 | ||
assert sccp.lattice[IRVariable("%5", version=1)].value == 106 | ||
assert sccp.lattice[IRVariable("%5", version=2)] == LatticeEnum.BOTTOM | ||
assert sccp.lattice[IRVariable("%5")].value == 2 | ||
|
||
|
||
def test_cont_phi_const_case(): | ||
ctx = IRFunction(IRLabel("_global")) | ||
|
||
bb = ctx.get_basic_block() | ||
|
||
br1 = IRBasicBlock(IRLabel("then"), ctx) | ||
ctx.append_basic_block(br1) | ||
br2 = IRBasicBlock(IRLabel("else"), ctx) | ||
ctx.append_basic_block(br2) | ||
join = IRBasicBlock(IRLabel("join"), ctx) | ||
ctx.append_basic_block(join) | ||
|
||
p1 = bb.append_instruction("store", 1) | ||
op1 = bb.append_instruction("store", 32) | ||
op2 = bb.append_instruction("store", 64) | ||
op3 = bb.append_instruction("add", op1, op2) | ||
bb.append_instruction("jnz", op3, br1.label, br2.label) | ||
|
||
op4 = br1.append_instruction("add", op3, 10) | ||
br1.append_instruction("jmp", join.label) | ||
br2.append_instruction("add", op3, p1, ret=op4) | ||
br2.append_instruction("jmp", join.label) | ||
|
||
join.append_instruction("return", op4, p1) | ||
|
||
make_ssa_pass = MakeSSA() | ||
make_ssa_pass.run_pass(ctx, ctx.basic_blocks[0]) | ||
sccp = SCCP(make_ssa_pass.dom) | ||
sccp.run_pass(ctx, ctx.basic_blocks[0]) | ||
|
||
assert sccp.lattice[IRVariable("%1")].value == 1 | ||
assert sccp.lattice[IRVariable("%2")].value == 32 | ||
assert sccp.lattice[IRVariable("%3")].value == 64 | ||
assert sccp.lattice[IRVariable("%4")].value == 96 | ||
assert sccp.lattice[IRVariable("%5", version=1)].value == 106 | ||
assert sccp.lattice[IRVariable("%5", version=2)].value == 97 | ||
assert sccp.lattice[IRVariable("%5")].value == 2 |
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.
this is so cool
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.
we might want to keep showing that there is a runtime check though. can we pass
x
as a parameter thru calldata?