alloc_stack needs to return two values like alloc_box.

The current implementation of dealloc_stack in IR-gen is a
no-op, but that's very much wrong for types with non-trivial
local allocation requirements, e.g. archetypes.  So we need
to be able to do non-trivial code here.  However, that means
modeling both the buffer pointer and the allocated address
in SIL.

To make this more type-safe, introduce a SIL-specific
'[local_storage] T' type that represents the required
allocation for locally storing a T.  alloc_stack now returns
one of those in additon to a *T, and dealloc_stack expects
the former.

IR-gen still implements dealloc_stack as a no-op, but
that's now easy to fix.

Swift SVN r6937
This commit is contained in:
John McCall
2013-08-06 07:31:41 +00:00
parent adfba641a8
commit 36aa6c2645
39 changed files with 314 additions and 103 deletions

View File

@@ -1671,6 +1671,14 @@ Type ModuleFile::getType(TypeID TID) {
break;
}
case decls_block::LOCAL_STORAGE_TYPE: {
TypeID valueTypeID;
decls_block::LocalStorageTypeLayout::readRecord(scratch, valueTypeID);
typeOrOffset = LocalStorageType::get(getType(valueTypeID), ctx);
break;
}
case decls_block::REFERENCE_STORAGE_TYPE: {
uint8_t rawOwnership;
TypeID referentTypeID;