Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/SILOptimizer/Transforms/SILMem2Reg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2185,7 +2185,8 @@ bool MemoryToRegisters::promoteAllocation(AllocStackInst *alloc,
++NumAllocStackFound;

// In OSSA, don't do Mem2Reg on non-trivial alloc_stack with dynamic_lifetime.
if (alloc->hasDynamicLifetime() && !alloc->getType().isTrivial(f)) {
if (alloc->hasDynamicLifetime() && f.hasOwnership() &&
!alloc->getType().isTrivial(f)) {
return false;
}

Expand Down
18 changes: 0 additions & 18 deletions test/SILOptimizer/mem2reg.sil
Original file line number Diff line number Diff line change
Expand Up @@ -578,21 +578,3 @@ bb0:
dealloc_stack %11 : $*Pair<T, ()>
return undef : $()
}

// CHECK-LABEL: sil @dont_promote_dynamic_lifetime : {{.*}} {
// CHECK: alloc_stack
// CHECK-LABEL: } // end sil function 'dont_promote_dynamic_lifetime'
sil @dont_promote_dynamic_lifetime : $@convention(thin) () -> () {
%stack = alloc_stack [dynamic_lifetime] $Klass
cond_br undef, left, right
left:
%kin = apply undef() : $@convention(thin) () -> (@owned Klass)
%k = load %stack : $*Klass
strong_release %k : $Klass
br exit
right:
br exit
exit:
dealloc_stack %stack : $*Klass
return undef : $()
}