Merge pull request #72479 from meg-gupta/fixsilcombineagain

Fix SILCombine of inject_enum_addr to correctly check for unreferenceable storage
This commit is contained in:
Meghana Gupta
2024-03-21 10:14:14 -07:00
committed by GitHub
4 changed files with 53 additions and 1 deletions

View File

@@ -2009,3 +2009,21 @@ SILValue swift::createEmptyAndUndefValue(SILType ty,
assert(!noUndef);
return SILUndef::get(insertionPoint->getFunction(), ty);
}
bool swift::findUnreferenceableStorage(StructDecl *decl, SILType structType,
SILFunction *func) {
if (decl->hasUnreferenceableStorage()) {
return true;
}
// Check if any fields have unreferenceable stoage
for (auto *field : decl->getStoredProperties()) {
TypeExpansionContext tec = *func;
auto fieldTy = structType.getFieldType(field, func->getModule(), tec);
if (auto *fieldStructDecl = fieldTy.getStructOrBoundGenericStruct()) {
if (findUnreferenceableStorage(fieldStructDecl, fieldTy, func)) {
return true;
}
}
}
return false;
}