@@ -191,9 +191,7 @@ struct SemanticARCOptVisitor
191
191
bool visitBeginBorrowInst (BeginBorrowInst *bbi);
192
192
bool visitLoadInst (LoadInst *li);
193
193
194
- // / Return true if all of load insts destroy_value users are within the
195
- // / guaranteed lifetime of the storage that is being loaded from.
196
- bool isLoadGuaranteedByStorage (LoadInst *li);
194
+ bool isWrittenTo (LoadInst *li);
197
195
198
196
bool processWorklist ();
199
197
@@ -716,7 +714,7 @@ class StorageGuaranteesLoadVisitor
716
714
};
717
715
} // namespace
718
716
719
- bool SemanticARCOptVisitor::isLoadGuaranteedByStorage (LoadInst *load) {
717
+ bool SemanticARCOptVisitor::isWrittenTo (LoadInst *load) {
720
718
StorageGuaranteesLoadVisitor visitor (*this , load);
721
719
return visitor.doIt ();
722
720
}
@@ -738,10 +736,9 @@ bool SemanticARCOptVisitor::visitLoadInst(LoadInst *li) {
738
736
if (!isDeadLiveRange (li, destroyValues))
739
737
return false ;
740
738
741
- // Then check if our address is guaranteed to never be written to within the
742
- // lifetime of our loaded value. If so, we can convert the loaded value to be
743
- // at +0 instead of +1.
744
- if (isLoadGuaranteedByStorage (li))
739
+ // Then check if our address is ever written to. If it is, then we
740
+ // can not use the load_borrow.
741
+ if (isWrittenTo (li))
745
742
return false ;
746
743
747
744
// Ok, we can perform our optimization. Convert the load [copy] into a
0 commit comments