Skip to content

Commit

Permalink
fixup! Fix to TypeOptimizer to allow literal structs.
Browse files Browse the repository at this point in the history
  • Loading branch information
Maqrkk committed Feb 3, 2024
1 parent 9058dd4 commit 5093d6d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion llvm/lib/CheerpUtils/TypeOptimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,10 @@ bool TypeOptimizer::isUnsafeDowncastSource(StructType* st)
bool TypeOptimizer::canCollapseStruct(llvm::StructType* st, llvm::StructType* newStruct, llvm::Type* newType)
{
if (newStruct == nullptr)
{
assert(st->isLiteral());
return false;
}
// Stop if the element is just a int8, we may be dealing with an empty struct
// Empty structs are unsafe as the int8 inside is just a placeholder and will be replaced
// by a different type in a derived class
Expand Down Expand Up @@ -447,7 +450,8 @@ TypeOptimizer::TypeMappingInfo TypeOptimizer::rewriteType(Type* t)
return CacheAndReturn(newType, TypeMappingInfo::BYTE_LAYOUT_TO_ARRAY);
}

// Generate a new type inconditionally, it may end up being the same as the old one
// Generate a new type if it's not a literal struct. It may end up being the same as the old one
// In case of literal, it will be created as a literal at the end.
StructType* newStruct=nullptr;
if (!st->isLiteral())
newStruct=StructType::create(st->getContext());
Expand Down

0 comments on commit 5093d6d

Please sign in to comment.