Skip to content

Commit

Permalink
overlaping source from the mload barier fix
Browse files Browse the repository at this point in the history
  • Loading branch information
HodanPlodky committed Dec 4, 2024
1 parent b29b55d commit 46fddbb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion tests/unit/compiler/venom/test_memmerging.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def test_memmerging_imposs_mload():
val0 = bb.append_instruction("mload", 0)
val1 = bb.append_instruction("mload", 32)
bb.append_instruction("mstore", val0, 1024)
val2 = bb.append_instruction("mload", 0)
val2 = bb.append_instruction("mload", 1024)
bb.append_instruction("mstore", val1, 1024 + 32)
bb.append_instruction("mstore", val2, 2048)
bb.append_instruction("stop")
Expand Down
10 changes: 5 additions & 5 deletions vyper/venom/passes/memmerging.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ def dst_end(self) -> int:
def dst_overlaps_src(self) -> bool:
# return true if dst overlaps src. this is important for blocking
# mcopy batching in certain cases.
a = max(self.src_start, self.dst_start)
b = min(self.src_end, self.dst_end)
a = max(self.dst_start, self.src_start)
b = min(self.dst_end, self.src_end)
return a < b

def overlap(self, other: "_Interval") -> bool:
a = max(self.src_start, other.src_start)
b = min(self.src_end, other.src_end)
a = max(self.dst_start, other.src_start)
b = min(self.dst_end, other.src_end)
return a < b

def merge(self, other: "_Interval", ok_dst_overlap: bool = True) -> bool:
Expand Down Expand Up @@ -115,7 +115,7 @@ def _add_interval(
return True

def _overlap_exist(self, intervals: list[_Interval], inter: _Interval) -> bool:
index = bisect_left(intervals, inter)
index = bisect_left(intervals, inter.src_start, key=lambda x: x.dst_start)

if index > 0:
if intervals[index - 1].overlap(inter):
Expand Down

0 comments on commit 46fddbb

Please sign in to comment.