fix crash with non-power-of-2 globals
MODIFY
ir/memory.cpp
ir/memory.cpp
@@ -1810,8 +1810,6 @@ Memory::alloc(const expr &size, unsigned align, BlockKind blockKind,
expr size_zext = size.zextOrTrunc(bits_size_t);
expr nooverflow = size_zext.extract(bits_size_t - 1, bits_size_t - 1) == 0;
- assert(bits_byte == 8 || is_local ||
- size_zext.urem(expr::mkUInt(bits_byte/8, bits_size_t)).isZero());
expr allocated = precond && nooverflow;
state->addPre(nonnull.implies(allocated));

ADD
tests/alive-tv/memory/glb-6.srctgt.ll
+@g = global [3 x i8] zeroinitializer, align 1
+
+define void @f() {
+ call void @fn2([3 x i8]* @g)
+ ret void
+}
+
+declare void @fn2([3 x i8]*)

MODIFY
tools/transform.cpp
tools/transform.cpp
@@ -840,23 +840,7 @@ static void calculateAndInitConstants(Transform &t) {
bits_size_t = ilog2_ceil(max_alloc_size, true);
bits_size_t = min(max(bits_for_offset, bits_size_t)+1, bits_program_pointer);
- // size of byte
- if (num_globals != 0) {
- if (does_mem_access || has_vector_bitcast)
- min_access_size = gcd(min_global_size, min_access_size);
- else {
- min_access_size = min_global_size;
- while (min_access_size > 8) {
- if (min_access_size % 2) {
- min_access_size = 1;
- break;
- }
- min_access_size /= 2;
- }
- }
- }
- bits_byte = 8 * ((does_mem_access || num_globals != 0)
- ? (unsigned)min_access_size : 1);
+ bits_byte = 8 * (does_mem_access ? (unsigned)min_access_size : 1);
bits_poison_per_byte = 1;
if (min_vect_elem_sz > 0)

fix crash with non-power-of-2 globals