fix regression in Ptr::inbounds now that size doesn't have an extra zero
MODIFY
ir/function.h
ir/function.h
@@ -81,7 +81,6 @@ class Function final {
FnAttrs attrs;
-
public:
Function() {}
Function(Type &type, std::string &&name, unsigned bits_pointers = 64,

MODIFY
ir/pointer.cpp
ir/pointer.cpp
@@ -277,10 +277,9 @@ static expr inbounds(const Pointer &p, bool strict) {
if (isUndef(p.getOffset()))
return false;
- // equivalent to offset >= 0 && offset <= block_size
- // because block_size u<= 0x7FFF..FF
- return strict ? p.getOffsetSizet().ult(p.blockSizeOffsetT()) :
- p.getOffsetSizet().ule(p.blockSizeOffsetT());
+ auto offset = p.getOffsetSizet();
+ auto size = p.blockSizeOffsetT();
+ return (strict ? offset.ult(size) : offset.ule(size)) && !offset.isNegative();
}
expr Pointer::inbounds(bool simplify_ptr, bool strict) {

MODIFY
tools/transform.cpp
tools/transform.cpp
@@ -948,6 +948,7 @@ static void calculateAndInitConstants(Transform &t) {
true) + 1;
bits_for_offset = min(round_up(max_geps, 4), (uint64_t)t.src.bitsPtrOffset());
bits_for_offset = min(bits_for_offset, config::max_offset_bits);
+ bits_for_offset = min(bits_for_offset, bits_program_pointer);
// ASSUMPTION: programs can only allocate up to half of address space
// so the first bit of size is always zero.

fix regression in Ptr::inbounds now that size doesn't have an extra zero