Skip to content

Commit f994334

Browse files
committed
SILOptimizer: AllocBoxToStack preserves [transparent] bit in cloned function
We need this to uphold the invariant that in the performance pipeline before SIL serialization occurs, a function has ownership iff it is transparent.
1 parent 4017a16 commit f994334

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

lib/SILOptimizer/Transforms/AllocBoxToStack.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ SILFunction *PromotedParamCloner::initCloned(SILOptFunctionBuilder &FuncBuilder,
634634
assert(!Orig->isGlobalInit() && "Global initializer cannot be cloned");
635635
auto *Fn = FuncBuilder.createFunction(
636636
SILLinkage::Shared, ClonedName, ClonedTy, Orig->getGenericEnvironment(),
637-
Orig->getLocation(), Orig->isBare(), IsNotTransparent, Serialized,
637+
Orig->getLocation(), Orig->isBare(), Orig->isTransparent(), Serialized,
638638
IsNotDynamic, Orig->getEntryCount(), Orig->isThunk(),
639639
Orig->getClassSubclassScope(), Orig->getInlineStrategy(),
640640
Orig->getEffectsKind(), Orig, Orig->getDebugScope());

test/SILOptimizer/allocbox_to_stack_ownership.sil

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -391,10 +391,10 @@ bb0(%0 : $Int):
391391
return %10 : $() // id: %11
392392
}
393393

394-
// CHECK-LABEL: sil shared [ossa] @$s6struct8useStack1tySi_tFSiycfU_Tf0s_n
395-
// CHECK-LABEL: sil private [ossa] @$s6struct8useStack1tySi_tFSiycfU_
394+
// CHECK-LABEL: sil shared [transparent] [ossa] @$s6struct8useStack1tySi_tFSiycfU_Tf0s_n
395+
// CHECK-LABEL: sil private [transparent] [ossa] @$s6struct8useStack1tySi_tFSiycfU_
396396
// struct.(useStack (t : Swift.Int) -> ()).(closure #1)
397-
sil private [ossa] @$s6struct8useStack1tySi_tFSiycfU_ : $@convention(thin) (@owned <τ_0_0> { var τ_0_0 } <Int>) -> Int {
397+
sil private [transparent] [ossa] @$s6struct8useStack1tySi_tFSiycfU_ : $@convention(thin) (@owned <τ_0_0> { var τ_0_0 } <Int>) -> Int {
398398
bb0(%0 : @owned $<τ_0_0> { var τ_0_0 } <Int>):
399399
%1 = project_box %0 : $<τ_0_0> { var τ_0_0 } <Int>, 0
400400
// function_ref Swift.++ @postfix <A : Swift._Incrementable>(x : @inout A) -> A

0 commit comments

Comments
 (0)