Skip to content

Commit 583b733

Browse files
committed
fix crash with fn calls with read-only memory attr
1 parent 05f674c commit 583b733

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

ir/memory.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1853,7 +1853,8 @@ void Memory::setState(const Memory::CallState &st,
18531853
if (!only_write_inaccess.isTrue()) {
18541854
unsigned idx = 1;
18551855
unsigned limit = num_nonlocals_src - num_inaccessiblememonly_fns;
1856-
for (unsigned bid = 0; bid < limit; ++bid) {
1856+
const auto written_blocks = st.non_local_block_val.size();
1857+
for (unsigned bid = 0; bid < limit && idx < written_blocks; ++bid) {
18571858
if (always_nowrite(bid, true, true))
18581859
continue;
18591860

@@ -1884,7 +1885,7 @@ void Memory::setState(const Memory::CallState &st,
18841885
if (modifies.isTrue())
18851886
non_local_block_val[bid].undef.clear();
18861887
}
1887-
assert(idx == st.non_local_block_val.size());
1888+
assert(written_blocks == 0 || idx == written_blocks);
18881889
}
18891890

18901891
if (!st.non_local_liveness.isAllOnes()) {

ir/state.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ expr SMTMemoryAccess::canWriteSomething() const {
7272
}
7373

7474
expr SMTMemoryAccess::refinedBy(const SMTMemoryAccess &other) const {
75-
return val == other.val;
75+
return (val & other.val) == val;
7676
}
7777

7878
SMTMemoryAccess

0 commit comments

Comments
 (0)