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) {
2177
2177
if (!result.has_value ())
2178
2178
return false ;
2179
2179
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
+
2180
2186
++NumLoadPromoted;
2181
2187
2182
2188
SILType loadTy = result->first ;
Original file line number Diff line number Diff line change @@ -1341,6 +1341,25 @@ bbEnd(%8 : @owned $Optional<Builtin.NativeObject>):
1341
1341
return %8 : $Optional<Builtin.NativeObject>
1342
1342
}
1343
1343
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
+
1344
1363
class Foo {}
1345
1364
struct MyInt {
1346
1365
var _value: Builtin.Int64
You can’t perform that action at this time.
0 commit comments