Skip to content

Commit 0059864

Browse files
authored
Merge pull request #35474 from eeckstein/fix-loadablebyaddr-crash
LoadableByAddress: fix a crash related to single-element tuples containing a label and a closure.
2 parents d185ccb + 132b09b commit 0059864

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

lib/IRGen/LoadableByAddress.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2765,7 +2765,8 @@ bool LoadableByAddress::recreateTupleInstr(
27652765
for (auto elem : tupleInstr->getElements()) {
27662766
elems.push_back(elem);
27672767
}
2768-
auto *newTuple = tupleBuilder.createTuple(tupleInstr->getLoc(), elems);
2768+
auto *newTuple = tupleBuilder.createTuple(tupleInstr->getLoc(), newResultTy,
2769+
elems);
27692770
tupleInstr->replaceAllUsesWith(newTuple);
27702771
Delete.push_back(tupleInstr);
27712772
return true;

test/IRGen/big_types_corner_cases.sil

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,15 @@ bb0(%0 : $*BigStruct):
276276
return %12 : $()
277277
}
278278

279+
sil @dontCrashWithLabeledSingleElementTupleOfClosure : $@convention(thin) () -> @callee_guaranteed () -> @owned BigStruct {
280+
bb0:
281+
%f = function_ref @returnBigStruct : $@convention(thin) () -> @owned BigStruct
282+
%thick = thin_to_thick_function %f : $@convention(thin) () -> @owned BigStruct to $@callee_guaranteed () -> @owned BigStruct
283+
%38 = tuple $(closure: @callee_guaranteed () -> @owned BigStruct) (%thick)
284+
%99 = tuple_extract %38 : $(closure: @callee_guaranteed () -> @owned BigStruct), 0
285+
return %99 : $@callee_guaranteed () -> @owned BigStruct
286+
}
287+
279288
sil_vtable SuperBase {
280289
}
281290

0 commit comments

Comments
 (0)