@@ -1034,8 +1034,8 @@ struct SemanticARCOptVisitor
1034
1034
} // end anonymous namespace
1035
1035
1036
1036
static 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);
1039
1039
1040
1040
static bool canEliminatePhi (
1041
1041
SemanticARCOptVisitor::FrozenMultiMapRange optimizableIntroducerRange,
@@ -1436,7 +1436,8 @@ bool SemanticARCOptVisitor::visitBeginBorrowInst(BeginBorrowInst *bbi) {
1436
1436
// are within the borrow scope.
1437
1437
//
1438
1438
// TODO: This needs a better name.
1439
- bool SemanticARCOptVisitor::performGuaranteedCopyValueOptimization (CopyValueInst *cvi) {
1439
+ bool SemanticARCOptVisitor::performGuaranteedCopyValueOptimization (
1440
+ CopyValueInst *cvi) {
1440
1441
// For now, do not run this optimization. This is just to be careful.
1441
1442
if (onlyGuaranteedOpts)
1442
1443
return false ;
@@ -1617,7 +1618,8 @@ bool SemanticARCOptVisitor::performGuaranteedCopyValueOptimization(CopyValueInst
1617
1618
1618
1619
// / If cvi only has destroy value users, then cvi is a dead live range. Lets
1619
1620
// / eliminate all such dead live ranges.
1620
- bool SemanticARCOptVisitor::eliminateDeadLiveRangeCopyValue (CopyValueInst *cvi) {
1621
+ bool SemanticARCOptVisitor::eliminateDeadLiveRangeCopyValue (
1622
+ CopyValueInst *cvi) {
1621
1623
// This is a cheap optimization generally.
1622
1624
1623
1625
// See if we are lucky and have a simple case.
@@ -1857,8 +1859,7 @@ namespace {
1857
1859
// / written to again. In both cases, we can convert load [copy] -> load_borrow
1858
1860
// / safely.
1859
1861
class StorageGuaranteesLoadVisitor
1860
- : public AccessUseDefChainVisitor<StorageGuaranteesLoadVisitor>
1861
- {
1862
+ : public AccessUseDefChainVisitor<StorageGuaranteesLoadVisitor> {
1862
1863
// The outer SemanticARCOptVisitor.
1863
1864
SemanticARCOptVisitor &ARCOpt;
1864
1865
@@ -1867,7 +1868,7 @@ class StorageGuaranteesLoadVisitor
1867
1868
1868
1869
// The current address being visited.
1869
1870
SILValue currentAddress;
1870
-
1871
+
1871
1872
Optional<bool > isWritten;
1872
1873
1873
1874
public:
@@ -1880,11 +1881,9 @@ class StorageGuaranteesLoadVisitor
1880
1881
currentAddress = nullptr ;
1881
1882
isWritten = written;
1882
1883
}
1883
-
1884
- void next (SILValue address) {
1885
- currentAddress = address;
1886
- }
1887
-
1884
+
1885
+ void next (SILValue address) { currentAddress = address; }
1886
+
1888
1887
void visitNestedAccess (BeginAccessInst *access) {
1889
1888
// First see if we have read/modify. If we do not, just look through the
1890
1889
// nested access.
@@ -1901,9 +1900,7 @@ class StorageGuaranteesLoadVisitor
1901
1900
// scope. If so, we may be able to use a load_borrow here!
1902
1901
SmallVector<Operand *, 8 > endScopeUses;
1903
1902
transform (access->getEndAccesses (), std::back_inserter (endScopeUses),
1904
- [](EndAccessInst *eai) {
1905
- return &eai->getAllOperands ()[0 ];
1906
- });
1903
+ [](EndAccessInst *eai) { return &eai->getAllOperands ()[0 ]; });
1907
1904
SmallPtrSet<SILBasicBlock *, 4 > visitedBlocks;
1908
1905
LinearLifetimeChecker checker (visitedBlocks, ARCOpt.getDeadEndBlocks ());
1909
1906
if (!checker.validateLifetime (access, endScopeUses,
@@ -1930,7 +1927,7 @@ class StorageGuaranteesLoadVisitor
1930
1927
1931
1928
return answer (true );
1932
1929
}
1933
-
1930
+
1934
1931
void visitArgumentAccess (SILFunctionArgument *arg) {
1935
1932
// If this load_copy is from an indirect in_guaranteed argument, then we
1936
1933
// know for sure that it will never be written to.
@@ -2007,15 +2004,15 @@ class StorageGuaranteesLoadVisitor
2007
2004
// able to also to promote load [copy] from such args to load_borrow.
2008
2005
return answer (true );
2009
2006
}
2010
-
2007
+
2011
2008
void visitGlobalAccess (SILValue global) {
2012
2009
return answer (!AccessedStorage (global, AccessedStorage::Global)
2013
- .isLetAccess (&ARCOpt.F ));
2010
+ .isLetAccess (&ARCOpt.F ));
2014
2011
}
2015
-
2012
+
2016
2013
void visitClassAccess (RefElementAddrInst *field) {
2017
2014
currentAddress = nullptr ;
2018
-
2015
+
2019
2016
// We know a let property won't be written to if the base object is
2020
2017
// guaranteed for the duration of the access.
2021
2018
// For non-let properties conservatively assume they may be written to.
@@ -2071,15 +2068,13 @@ class StorageGuaranteesLoadVisitor
2071
2068
baseObject, endScopeInsts, liveRange.getAllConsumingUses ());
2072
2069
return answer (foundError);
2073
2070
}
2074
-
2071
+
2075
2072
// TODO: Handle other access kinds?
2076
2073
void visitBase (SILValue base, AccessedStorage::Kind kind) {
2077
2074
return answer (true );
2078
2075
}
2079
2076
2080
- void visitNonAccess (SILValue addr) {
2081
- return answer (true );
2082
- }
2077
+ void visitNonAccess (SILValue addr) { return answer (true ); }
2083
2078
2084
2079
void visitCast (SingleValueInstruction *cast, Operand *parentAddr) {
2085
2080
return next (parentAddr->get ());
0 commit comments