Skip to content

Commit dd45d79

Browse files
committed
---
yaml --- r: 349596 b: refs/heads/master-next c: 9eeb661 h: refs/heads/master
1 parent e0da040 commit dd45d79

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
refs/heads/master: 3574c513bbc5578dd9346b4ea9ab5995c5927bb5
3-
refs/heads/master-next: d3ca90f4f2a8c3f463df67086c78ad4558fe8c7f
3+
refs/heads/master-next: 9eeb66154bdb5fb77d897aafacfb780c7cb0affd
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea
66
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-b: 66d897bfcf64a82cb9a87f5e663d889189d06d07

branches/master-next/lib/SILOptimizer/Mandatory/SemanticARCOpts.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,10 @@ struct SemanticARCOptVisitor
186186
bool visitCopyValueInst(CopyValueInst *cvi);
187187
bool visitBeginBorrowInst(BeginBorrowInst *bbi);
188188
bool visitLoadInst(LoadInst *li);
189-
190-
bool isWrittenTo(LoadInst *li);
189+
190+
/// Return true if all of load insts destroy_value users are within the
191+
/// guaranteed lifetime of the storage that is being loaded from.
192+
bool isLoadGuaranteedByStorage(LoadInst *li);
191193

192194
bool processWorklist();
193195

@@ -713,7 +715,7 @@ class StorageGuaranteesLoadVisitor
713715
};
714716
} // namespace
715717

716-
bool SemanticARCOptVisitor::isWrittenTo(LoadInst *load) {
718+
bool SemanticARCOptVisitor::isLoadGuaranteedByStorage(LoadInst *load) {
717719
StorageGuaranteesLoadVisitor visitor(*this, load);
718720
return visitor.doIt();
719721
}
@@ -735,9 +737,10 @@ bool SemanticARCOptVisitor::visitLoadInst(LoadInst *li) {
735737
if (isConsumed(li, destroyValues))
736738
return false;
737739

738-
// Then check if our address is ever written to. If it is, then we
739-
// can not use the load_borrow.
740-
if (isWrittenTo(li))
740+
// Then check if our address is guaranteed to never be written to within the
741+
// lifetime of our loaded value. If so, we can convert the loaded value to be
742+
// at +0 instead of +1.
743+
if (isLoadGuaranteedByStorage(li))
741744
return false;
742745

743746
// Ok, we can perform our optimization. Convert the load [copy] into a

0 commit comments

Comments
 (0)