@@ -1034,8 +1034,8 @@ struct SemanticARCOptVisitor
10341034} // end anonymous namespace
10351035
10361036static llvm::cl::opt<bool >
1037- VerifyAfterTransform (" sil-semantic-arc-opts-verify-after-transform" ,
1038- llvm::cl::init (false ), llvm::cl::Hidden);
1037+ VerifyAfterTransform (" sil-semantic-arc-opts-verify-after-transform" ,
1038+ llvm::cl::init (false ), llvm::cl::Hidden);
10391039
10401040static bool canEliminatePhi (
10411041 SemanticARCOptVisitor::FrozenMultiMapRange optimizableIntroducerRange,
@@ -1436,7 +1436,8 @@ bool SemanticARCOptVisitor::visitBeginBorrowInst(BeginBorrowInst *bbi) {
14361436// are within the borrow scope.
14371437//
14381438// TODO: This needs a better name.
1439- bool SemanticARCOptVisitor::performGuaranteedCopyValueOptimization (CopyValueInst *cvi) {
1439+ bool SemanticARCOptVisitor::performGuaranteedCopyValueOptimization (
1440+ CopyValueInst *cvi) {
14401441 // For now, do not run this optimization. This is just to be careful.
14411442 if (onlyGuaranteedOpts)
14421443 return false ;
@@ -1617,7 +1618,8 @@ bool SemanticARCOptVisitor::performGuaranteedCopyValueOptimization(CopyValueInst
16171618
16181619// / If cvi only has destroy value users, then cvi is a dead live range. Lets
16191620// / eliminate all such dead live ranges.
1620- bool SemanticARCOptVisitor::eliminateDeadLiveRangeCopyValue (CopyValueInst *cvi) {
1621+ bool SemanticARCOptVisitor::eliminateDeadLiveRangeCopyValue (
1622+ CopyValueInst *cvi) {
16211623 // This is a cheap optimization generally.
16221624
16231625 // See if we are lucky and have a simple case.
@@ -1857,8 +1859,7 @@ namespace {
18571859// / written to again. In both cases, we can convert load [copy] -> load_borrow
18581860// / safely.
18591861class StorageGuaranteesLoadVisitor
1860- : public AccessUseDefChainVisitor<StorageGuaranteesLoadVisitor>
1861- {
1862+ : public AccessUseDefChainVisitor<StorageGuaranteesLoadVisitor> {
18621863 // The outer SemanticARCOptVisitor.
18631864 SemanticARCOptVisitor &ARCOpt;
18641865
@@ -1867,7 +1868,7 @@ class StorageGuaranteesLoadVisitor
18671868
18681869 // The current address being visited.
18691870 SILValue currentAddress;
1870-
1871+
18711872 Optional<bool > isWritten;
18721873
18731874public:
@@ -1880,11 +1881,9 @@ class StorageGuaranteesLoadVisitor
18801881 currentAddress = nullptr ;
18811882 isWritten = written;
18821883 }
1883-
1884- void next (SILValue address) {
1885- currentAddress = address;
1886- }
1887-
1884+
1885+ void next (SILValue address) { currentAddress = address; }
1886+
18881887 void visitNestedAccess (BeginAccessInst *access) {
18891888 // First see if we have read/modify. If we do not, just look through the
18901889 // nested access.
@@ -1901,9 +1900,7 @@ class StorageGuaranteesLoadVisitor
19011900 // scope. If so, we may be able to use a load_borrow here!
19021901 SmallVector<Operand *, 8 > endScopeUses;
19031902 transform (access->getEndAccesses (), std::back_inserter (endScopeUses),
1904- [](EndAccessInst *eai) {
1905- return &eai->getAllOperands ()[0 ];
1906- });
1903+ [](EndAccessInst *eai) { return &eai->getAllOperands ()[0 ]; });
19071904 SmallPtrSet<SILBasicBlock *, 4 > visitedBlocks;
19081905 LinearLifetimeChecker checker (visitedBlocks, ARCOpt.getDeadEndBlocks ());
19091906 if (!checker.validateLifetime (access, endScopeUses,
@@ -1930,7 +1927,7 @@ class StorageGuaranteesLoadVisitor
19301927
19311928 return answer (true );
19321929 }
1933-
1930+
19341931 void visitArgumentAccess (SILFunctionArgument *arg) {
19351932 // If this load_copy is from an indirect in_guaranteed argument, then we
19361933 // know for sure that it will never be written to.
@@ -2007,15 +2004,15 @@ class StorageGuaranteesLoadVisitor
20072004 // able to also to promote load [copy] from such args to load_borrow.
20082005 return answer (true );
20092006 }
2010-
2007+
20112008 void visitGlobalAccess (SILValue global) {
20122009 return answer (!AccessedStorage (global, AccessedStorage::Global)
2013- .isLetAccess (&ARCOpt.F ));
2010+ .isLetAccess (&ARCOpt.F ));
20142011 }
2015-
2012+
20162013 void visitClassAccess (RefElementAddrInst *field) {
20172014 currentAddress = nullptr ;
2018-
2015+
20192016 // We know a let property won't be written to if the base object is
20202017 // guaranteed for the duration of the access.
20212018 // For non-let properties conservatively assume they may be written to.
@@ -2071,15 +2068,13 @@ class StorageGuaranteesLoadVisitor
20712068 baseObject, endScopeInsts, liveRange.getAllConsumingUses ());
20722069 return answer (foundError);
20732070 }
2074-
2071+
20752072 // TODO: Handle other access kinds?
20762073 void visitBase (SILValue base, AccessedStorage::Kind kind) {
20772074 return answer (true );
20782075 }
20792076
2080- void visitNonAccess (SILValue addr) {
2081- return answer (true );
2082- }
2077+ void visitNonAccess (SILValue addr) { return answer (true ); }
20832078
20842079 void visitCast (SingleValueInstruction *cast, Operand *parentAddr) {
20852080 return next (parentAddr->get ());
0 commit comments