File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed
lib/SILOptimizer/Mandatory Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -2177,6 +2177,12 @@ bool AllocOptimize::promoteLoadBorrow(LoadBorrowInst *lbi) {
21772177 if (!result.has_value ())
21782178 return false ;
21792179
2180+ // Bail if the load_borrow has reborrows. In this case it's not so easy to
2181+ // find the insertion points for the destroys.
2182+ if (!lbi->getUsersOfType <BranchInst>().empty ()) {
2183+ return false ;
2184+ }
2185+
21802186 ++NumLoadPromoted;
21812187
21822188 SILType loadTy = result->first ;
Original file line number Diff line number Diff line change @@ -1341,6 +1341,25 @@ bbEnd(%8 : @owned $Optional<Builtin.NativeObject>):
13411341 return %8 : $Optional<Builtin.NativeObject>
13421342}
13431343
1344+ // CHECK-LABEL: sil [ossa] @dont_promote_load_borrow_with_reborrows :
1345+ // CHECK: load_borrow
1346+ // CHECK: } // end sil function 'dont_promote_load_borrow_with_reborrows'
1347+ sil [ossa] @dont_promote_load_borrow_with_reborrows : $@convention(thin) (@owned SomeClass) -> () {
1348+ bb0(%0 : @owned $SomeClass):
1349+ %1 = alloc_stack $SomeClass
1350+ store %0 to [init] %1 : $*SomeClass
1351+ %3 = load_borrow %1 : $*SomeClass
1352+ br bb1(%3 : $SomeClass)
1353+
1354+ bb1(%5 : @reborrow @guaranteed $SomeClass):
1355+ end_borrow %5 : $SomeClass
1356+ destroy_addr %1 : $*SomeClass
1357+ dealloc_stack %1 : $*SomeClass
1358+ %9 = tuple ()
1359+ return %9 : $()
1360+ }
1361+
1362+
13441363class Foo {}
13451364struct MyInt {
13461365 var _value: Builtin.Int64
You can’t perform that action at this time.
0 commit comments