fix bug in memory refinement where ptr byte offset wasn't being checked
MODIFY
ir/memory.cpp
ir/memory.cpp
@@ -666,7 +666,9 @@ expr Pointer::block_val_refined(const Pointer &other) const {
if (!does_ptr_store || is_ptr.isFalse() || is_ptr2.isFalse()) {
ptr_cnstr = val == val2;
} else {
- ptr_cnstr = val2.ptr_nonpoison() && val.ptr().refined(val2.ptr());
+ ptr_cnstr = val2.ptr_nonpoison() &&
+ val.ptr_byteoffset() == val2.ptr_byteoffset() &&
+ val.ptr().refined(val2.ptr());
}
return val.is_poison() ||
expr::mkIf(is_ptr == is_ptr2,

ADD
tests/alive-tv/memory/store-ptr-fail.src.ll
+; ERROR: Mismatch in memory
+
+define void @f(i8* %ptr) {
+ %ptr1 = getelementptr i8, i8* %ptr, i64 1
+ %dst = bitcast i8* %ptr1 to i8**
+ store i8* %ptr, i8** %dst, align 1
+
+ %dst2 = bitcast i8* %ptr to i8**
+ store i8* %ptr, i8** %dst2, align 1
+ ret void
+}

ADD
tests/alive-tv/memory/store-ptr-fail.tgt.ll
+define void @f(i8* %ptr) {
+ %dst2 = bitcast i8* %ptr to i8**
+ store i8* %ptr, i8** %dst2, align 1
+
+ %ptr1 = getelementptr i8, i8* %ptr, i64 1
+ %dst = bitcast i8* %ptr1 to i8**
+ store i8* %ptr, i8** %dst, align 1
+ ret void
+}

fix bug in memory refinement where ptr byte offset wasn't being checked