Skip to content

Commit 2947510

Browse files
Merge pull request #76719 from aschwaighofer/revert_pr76656
Revert "Merge pull request #76656 from nate-chandler/rdar136388508"
2 parents b8f1876 + 8d89517 commit 2947510

File tree

2 files changed

+2
-19
lines changed

2 files changed

+2
-19
lines changed

lib/SILOptimizer/Transforms/SILMem2Reg.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2185,7 +2185,8 @@ bool MemoryToRegisters::promoteAllocation(AllocStackInst *alloc,
21852185
++NumAllocStackFound;
21862186

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

test/SILOptimizer/mem2reg.sil

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -578,21 +578,3 @@ bb0:
578578
dealloc_stack %11 : $*Pair<T, ()>
579579
return undef : $()
580580
}
581-
582-
// CHECK-LABEL: sil @dont_promote_dynamic_lifetime : {{.*}} {
583-
// CHECK: alloc_stack
584-
// CHECK-LABEL: } // end sil function 'dont_promote_dynamic_lifetime'
585-
sil @dont_promote_dynamic_lifetime : $@convention(thin) () -> () {
586-
%stack = alloc_stack [dynamic_lifetime] $Klass
587-
cond_br undef, left, right
588-
left:
589-
%kin = apply undef() : $@convention(thin) () -> (@owned Klass)
590-
%k = load %stack : $*Klass
591-
strong_release %k : $Klass
592-
br exit
593-
right:
594-
br exit
595-
exit:
596-
dealloc_stack %stack : $*Klass
597-
return undef : $()
598-
}

0 commit comments

Comments
 (0)