Skip to content

Commit bd46860

Browse files
authored
Merge pull request #71913 from meg-gupta/savecodesize
Create mark_dependence for array allocation in OSLogOptimization
2 parents bc1d2a4 + 0fc2e13 commit bd46860

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

lib/SILOptimizer/Mandatory/OSLogOptimization.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,8 @@ static SILValue emitCodeForConstantArray(ArrayRef<SILValue> elements,
529529
builder.createDestructureTuple(loc, applyInst);
530530
SILValue arraySIL = destructureInst->getResults()[0];
531531
SILValue storagePointerSIL = destructureInst->getResults()[1];
532+
storagePointerSIL = builder.createMarkDependence(
533+
loc, storagePointerSIL, arraySIL, MarkDependenceKind::Escaping);
532534

533535
if (elements.empty()) {
534536
// Nothing more to be done if we are creating an empty array.

test/SILOptimizer/OSLogMandatoryOptTest.sil

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,8 @@ bb0:
407407
// CHECK: [[ALLOCATORREF:%[0-9]+]] = function_ref @$ss27_allocateUninitializedArrayySayxG_BptBwlF
408408
// CHECK: [[TUPLE:%[0-9]+]] = apply [[ALLOCATORREF]]<Int64>([[NUMELEMS]])
409409
// CHECK: ([[ARRAY:%[0-9]+]], [[STORAGEPTR:%[0-9]+]]) = destructure_tuple [[TUPLE]]
410-
// CHECK: [[STORAGEADDR:%[0-9]+]] = pointer_to_address [[STORAGEPTR]] : $Builtin.RawPointer to [strict] $*Int64
410+
// CHECK: [[MDI:%.*]] = mark_dependence [[STORAGEPTR]] : $Builtin.RawPointer on [[ARRAY]] : $Array<Int64>
411+
// CHECK: [[STORAGEADDR:%[0-9]+]] = pointer_to_address [[MDI]] : $Builtin.RawPointer to [strict] $*Int64
411412
// CHECK: store [[ELEM1INT]] to [trivial] [[STORAGEADDR]] : $*Int64
412413
// CHECK: [[INDEX1:%[0-9]+]] = integer_literal $Builtin.Word, 1
413414
// CHECK: [[INDEXADDR1:%[0-9]+]] = index_addr [[STORAGEADDR]] : $*Int64, [[INDEX1]] : $Builtin.Word
@@ -539,7 +540,8 @@ bb0:
539540
// CHECK: [[ALLOCATORREF:%[0-9]+]] = function_ref @$ss27_allocateUninitializedArrayySayxG_BptBwlF
540541
// CHECK: [[TUPLE:%[0-9]+]] = apply [[ALLOCATORREF]]<String>([[NUMELEMS]])
541542
// CHECK: ([[ARRAY:%[0-9]+]], [[STORAGEPTR:%[0-9]+]]) = destructure_tuple [[TUPLE]]
542-
// CHECK: [[STORAGEADDR:%[0-9]+]] = pointer_to_address [[STORAGEPTR]] : $Builtin.RawPointer to [strict] $*String
543+
// CHECK: [[MDI:%.*]] = mark_dependence [[STORAGEPTR]] : $Builtin.RawPointer on [[ARRAY]] : $Array<String>
544+
// CHECK: [[STORAGEADDR:%[0-9]+]] = pointer_to_address [[MDI]] : $Builtin.RawPointer to [strict] $*String
543545
// CHECK: store [[STRINGCONST]] to [init] [[STORAGEADDR]] : $*String
544546
// CHECK: [[FINALIZEREF:%[0-9]+]] = function_ref @$ss27_finalizeUninitializedArrayySayxGABnlF
545547
// CHECK: [[FINALIZED:%[0-9]+]] = apply [[FINALIZEREF]]<String>([[ARRAY]])

0 commit comments

Comments
 (0)