Skip to content

Commit 47be53d

Browse files
committed
[memory-lifetime] Disable memory lifetime on tuple typed alloc_stack that have at least one enum tuple sub-elt.
Just until MemoryLifetime can handle enums completely.
1 parent f732762 commit 47be53d

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lib/SIL/Verifier/MemoryLifetime.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ static bool canHandleAllocStack(AllocStackInst *asi) {
142142
if (asi->hasDynamicLifetime())
143143
return false;
144144

145+
SILType stackType = asi->getType();
146+
145147
// Currently in this verifier, we stop verifying if we find a switch_enum_addr
146148
// use. This creates a problem since no one has gone through and changed the
147149
// frontend/optimizer to understand that it needs to insert destroy_addr on
@@ -155,9 +157,16 @@ static bool canHandleAllocStack(AllocStackInst *asi) {
155157
// implemented.
156158
//
157159
// https://bugs.swift.org/browse/SR-14123
158-
if (asi->getType().getEnumOrBoundGenericEnum())
160+
if (stackType.getEnumOrBoundGenericEnum())
159161
return false;
160162

163+
// Same for tuples that have an enum element. We are just working around this
164+
// for now until the radar above is solved.
165+
if (auto tt = stackType.getAs<TupleType>())
166+
for (unsigned i : range(tt->getNumElements()))
167+
if (stackType.getTupleElementType(i).getEnumOrBoundGenericEnum())
168+
return false;
169+
161170
// Otherwise we can optimize!
162171
return true;
163172
}

0 commit comments

Comments
 (0)