memory: take alignment of globals into account when computing bits_byte
MODIFY
ir/memory.cpp
ir/memory.cpp
@@ -521,7 +521,7 @@ expr Pointer::block_alignment() const {
}
expr Pointer::is_block_aligned(unsigned align, bool exact) const {
- assert(align != 0);
+ assert(align >= bits_byte / 8);
if (!exact && align == 1)
return true;
@@ -531,7 +531,7 @@ expr Pointer::is_block_aligned(unsigned align, bool exact) const {
}
expr Pointer::is_aligned(unsigned align) const {
- assert(align != 0);
+ assert(align >= bits_byte / 8);
if (align == 1)
return true;
@@ -997,7 +997,8 @@ Memory::Memory(State &state) : state(&state) {
// Initialize a memory block for null pointer.
if (num_nonlocals > 0)
- alloc(expr::mkUInt(0, bits_size_t), 1, GLOBAL, false, false, 0);
+ alloc(expr::mkUInt(0, bits_size_t), bits_program_pointer, GLOBAL, false,
+ false, 0);
escaped_local_blks.resize(num_locals, false);

MODIFY
tests/alive-tv/memory/memset-large.src.ll
tests/alive-tv/memory/memset-large.src.ll
-; TEST-ARGS: -smt-to=10000
+; TEST-ARGS: -smt-to=10000 -disable-undef-input
declare void @llvm.memset.p0i8.i128(i8*, i8, i128, i1)

MODIFY
tools/transform.cpp
tools/transform.cpp
@@ -534,8 +534,10 @@ static uint64_t max_gep(const Instr &inst) {
static bool has_sub_byte(const Type &t) {
if (auto agg = t.getAsAggregateType()) {
- if (t.isVectorType())
- return agg->getChild(0).bits() % 8;
+ if (t.isVectorType()) {
+ auto &elemTy = agg->getChild(0);
+ return elemTy.isPtrType() ? false : (elemTy.bits() % 8);
+ }
for (unsigned i = 0, e = agg->numElementsConst(); i != e; ++i) {
if (has_sub_byte(agg->getChild(i)))
@@ -636,6 +638,7 @@ static void calculateAndInitConstants(Transform &t) {
min_global_size = min_global_size != UINT64_MAX
? gcd(sz, min_global_size)
: sz;
+ min_global_size = gcd(min_global_size, glb->getAlignment());
}
}

memory: take alignment of globals into account when computing bits_byte