Skip to content

Commit 48b913a

Browse files
committed
Optimizer: make the hasOwnershipOperandsOrResults utility available in OwnershipOptUtils
1 parent c58f04f commit 48b913a

File tree

3 files changed

+18
-15
lines changed

3 files changed

+18
-15
lines changed

include/swift/SILOptimizer/Utils/OwnershipOptUtils.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,8 @@ void updateGuaranteedPhis(SILPassManager *pm, ArrayRef<SILPhiArgument *> phis);
367367
/// Replaces phis with the unique incoming values if all incoming values are the same.
368368
void replacePhisWithIncomingValues(SILPassManager *pm, ArrayRef<SILPhiArgument *> phis);
369369

370+
bool hasOwnershipOperandsOrResults(SILInstruction *inst);
371+
370372
} // namespace swift
371373

372374
#endif

lib/SILOptimizer/LoopTransforms/LICM.cpp

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include "swift/SILOptimizer/PassManager/Transforms.h"
3333
#include "swift/SILOptimizer/Utils/CFGOptUtils.h"
3434
#include "swift/SILOptimizer/Utils/InstOptUtils.h"
35+
#include "swift/SILOptimizer/Utils/OwnershipOptUtils.h"
3536
#include "swift/SILOptimizer/Utils/SILSSAUpdater.h"
3637

3738
#include "llvm/ADT/DepthFirstIterator.h"
@@ -849,21 +850,6 @@ static bool analyzeBeginAccess(BeginAccessInst *BI,
849850
return true;
850851
}
851852

852-
static bool hasOwnershipOperandsOrResults(SILInstruction *inst) {
853-
if (!inst->getFunction()->hasOwnership())
854-
return false;
855-
856-
for (SILValue result : inst->getResults()) {
857-
if (result->getOwnershipKind() != OwnershipKind::None)
858-
return true;
859-
}
860-
for (Operand &op : inst->getAllOperands()) {
861-
if (op.get()->getOwnershipKind() != OwnershipKind::None)
862-
return true;
863-
}
864-
return false;
865-
}
866-
867853
// Analyzes current loop for hosting/sinking potential:
868854
// Computes set of instructions we may be able to move out of the loop
869855
// Important Note:

lib/SILOptimizer/Utils/OwnershipOptUtils.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1951,3 +1951,18 @@ void swift::replacePhisWithIncomingValues(SILPassManager *pm, ArrayRef<SILPhiArg
19511951
}
19521952
replacePhisWithIncomingValuesFunction({pm->getSwiftPassInvocation()}, ArrayRef(bridgedPhis));
19531953
}
1954+
1955+
bool swift::hasOwnershipOperandsOrResults(SILInstruction *inst) {
1956+
if (!inst->getFunction()->hasOwnership())
1957+
return false;
1958+
1959+
for (SILValue result : inst->getResults()) {
1960+
if (result->getOwnershipKind() != OwnershipKind::None)
1961+
return true;
1962+
}
1963+
for (Operand &op : inst->getAllOperands()) {
1964+
if (op.get()->getOwnershipKind() != OwnershipKind::None)
1965+
return true;
1966+
}
1967+
return false;
1968+
}

0 commit comments

Comments
 (0)