You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This prepares a fix to GEP offset computations on vectors
of overaligned elements.
We have many places that analyze GEP offsets using GEP iterators
with the following pattern:
GTI = gep_type_begin(ElemTy, Indices),
GTE = gep_type_end(ElemTy, Indices);
for (; GTI != GTE; ++GTI) {
if (StructType *STy = GTI.getStructTypeOrNull()) {
// handle struct
[..]
} else {
// handle sequential (outmost index, array, vector):
auto Stride = DL.getTypeAllocSize(GTI.getIndexedType());
Offset += Index * Size;
}
}
This is incorrect for vectors of types whose bit size does not
equal its alloc size (e.g. overaligned types), as vectors
always bit-pack their elements.
This patch introduces new functions generic_gep_type_iterator::isVector()
and generic_gep_type_iterator::getSequentialElementStride(const DataLayout &)
to fix these patterns without having to teach all these places about
the specifics of vector bit layouts. With these helpers, the pattern
above can be fixed by replacing the stride computation:
auto Stride = GTI.getSequentialElementStride(DL);
0 commit comments