Skip to content

Commit 1f4efeb

Browse files
committed
Enable temprvalueopt of lexical enum values
1 parent f833bdb commit 1f4efeb

File tree

2 files changed

+2
-13
lines changed

2 files changed

+2
-13
lines changed

lib/SILOptimizer/Transforms/TempRValueElimination.cpp

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -731,8 +731,6 @@ TempRValueOptPass::tryOptimizeStoreIntoTemp(StoreInst *si) {
731731
return std::next(si->getIterator());
732732
}
733733

734-
bool isOrHasEnum = tempObj->getType().isOrHasEnum();
735-
736734
// Scan all uses of the temporary storage (tempObj) to verify they all refer
737735
// to the value initialized by this copy. It is sufficient to check that the
738736
// only users that modify memory are the copy_addr [initialization] and
@@ -743,15 +741,6 @@ TempRValueOptPass::tryOptimizeStoreIntoTemp(StoreInst *si) {
743741
if (user == si)
744742
continue;
745743

746-
// For lexical stored values that are enums, we require that all uses are in
747-
// the same block. This is because we can have incomplete address lifetimes
748-
// on none/trivial paths. and OSSALifetimeCompletion currently can complete
749-
// lexical values only in the presence of dead end blocks.
750-
if (isOrHasEnum && si->getSrc()->isLexical() &&
751-
user->getParent() != si->getParent() && !isa<DeallocStackInst>(user)) {
752-
return std::next(si->getIterator());
753-
}
754-
755744
// Bail if there is any kind of user which is not handled in the code below.
756745
switch (user->getKind()) {
757746
case SILInstructionKind::DestroyAddrInst:
@@ -955,7 +944,7 @@ void TempRValueOptPass::run() {
955944
// Call the utlity to complete ossa lifetime.
956945
OSSALifetimeCompletion completion(function, da->get(function));
957946
for (auto it : valuesToComplete) {
958-
completion.completeOSSALifetime(it);
947+
completion.completeOSSALifetime(it, /* forceBoundaryCompletion */ true);
959948
}
960949
}
961950

test/SILOptimizer/temp_rvalue_opt_ossa.sil

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1364,7 +1364,7 @@ bb7:
13641364
}
13651365

13661366
// CHECK-LABEL: sil [ossa] @test_optimize_store_of_enum2
1367-
// CHECK: alloc_stack
1367+
// CHECK-NOT: alloc_stack
13681368
// CHECK: } // end sil function 'test_optimize_store_of_enum2'
13691369
sil [ossa] @test_optimize_store_of_enum2 : $@convention(method) <Element> (@owned Optional<Klass>) -> () {
13701370
bb0(%0 : @owned $Optional<Klass>):

0 commit comments

Comments
 (0)