Allow wider byte size in the presence of fn calls without dereferenceable attr
MODIFY
ir/instr.cpp
ir/instr.cpp
@@ -2054,9 +2054,10 @@ FnCall::ByteAccessInfo FnCall::getByteAccessInfo() const {
sz = attr.derefBytes; \
if (attr.has(decay<decltype(attr)>::type::DereferenceableOrNull)) \
sz = gcd(sz, attr.derefOrNullBytes); \
- /* Without align, nothing is guaranteed about the bytesize */ \
+ if (sz) { \
sz = gcd(sz, retattr.align ? retattr.align : 1); \
bytesize = bytesize ? gcd(bytesize, sz) : sz; \
+ } \
} while (0)
auto &retattr = getAttributes();
@@ -2076,12 +2077,11 @@ FnCall::ByteAccessInfo FnCall::getByteAccessInfo() const {
// f(%p, %q) does not contribute to the bytesize. After bytesize is fixed,
// function calls update a memory with the granularity.
}
- if (bytesize == 0) {
+#undef UPDATE
+
// No dereferenceable attribute
+ if (bytesize == 0)
return {};
- }
-
-#undef UPDATE
return ByteAccessInfo::anyType(bytesize);
}

ADD
tests/alive-tv/opt-memory/call_byte_size.ident.ll
+; TEST-ARGS: -dbg
+; CHECK: bits_byte: 64
+
+define void @f(ptr %p) {
+ store ptr null, ptr %p, align 8
+ call void @g()
+ ret void
+}
+
+declare void @g()

Allow wider byte size in the presence of fn calls without dereferenceable attr