SIL: a new library intrinsic to "finalize" array literals

For COW support in SIL it's required to "finalize" array literals.
_finalizeUninitializedArray is a compiler known stdlib function which is called after all elements of an array literal are stored.
This runtime function marks the array literal as finished.

  %uninitialized_result_tuple = apply %_allocateUninitializedArray(%count)
  %mutable_array = tuple_extract %uninitialized_result_tuple, 0
  %elem_base_address = tuple_extract %uninitialized_result_tuple, 1
  ...
  store %elem_0 to %elem_addr_0
  store %elem_1 to %elem_addr_1
  ...
  %final_array = apply %_finalizeUninitializedArray(%mutable_array)

In this commit _finalizeUninitializedArray is still a no-op because the COW support is not used in the Array implementation yet.
This commit is contained in:
Erik Eckstein
2020-05-25 21:32:22 +02:00
parent f96f9368b4
commit 1559fe333f
20 changed files with 229 additions and 77 deletions

View File

@@ -642,7 +642,7 @@ bool COWArrayOpt::hasLoopOnlyDestructorSafeArrayOperations() {
// Semantic calls are safe.
ArraySemanticsCall Sem(Inst);
if (Sem) {
if (Sem && Sem.hasSelf()) {
auto Kind = Sem.getKind();
// Safe because they create new arrays.
if (Kind == ArrayCallKind::kArrayInit ||