Skip to content

Commit ec5fb36

Browse files
committed
llvm2alive: skip structs with vscale elements
1 parent 8bf8625 commit ec5fb36

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

llvm_util/utils.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,18 +157,25 @@ Type* llvm_type2alive(const llvm::Type *ty) {
157157
auto layout = DL->getStructLayout(const_cast<llvm::StructType *>(strty));
158158
for (unsigned i = 0; i < strty->getNumElements(); ++i) {
159159
auto e = strty->getElementType(i);
160-
unsigned ofs = layout->getElementOffset(i);
161-
unsigned sz = DL->getTypeStoreSize(e);
160+
auto ofs = layout->getElementOffset(i);
161+
auto sz = DL->getTypeStoreSize(e);
162+
163+
// TODO: support vscale
164+
if (ofs.isScalable() || sz.isScalable())
165+
return nullptr;
162166

163167
if (auto ty = llvm_type2alive(e)) {
164168
elems.push_back(ty);
165169
is_padding.push_back(false);
166170
} else
167171
return nullptr;
168172

169-
unsigned ofs_next = i + 1 == strty->getNumElements() ?
173+
auto ofs_next = i + 1 == strty->getNumElements() ?
170174
DL->getTypeAllocSize(const_cast<llvm::StructType *>(strty)) :
171175
layout->getElementOffset(i + 1);
176+
// TODO: support vscale
177+
if (ofs_next.isScalable())
178+
return nullptr;
172179
assert(ofs + sz <= ofs_next);
173180

174181
if (ofs_next != ofs + sz) {

0 commit comments

Comments
 (0)