Skip to content

Commit add3406

Browse files
committed
Move PrunedLiveness so it can be used as a lightweight OSSA helper.
For use in OwnershipUtils.
1 parent af4c2f4 commit add3406

File tree

8 files changed

+21
-16
lines changed

8 files changed

+21
-16
lines changed

include/swift/SILOptimizer/Utils/PrunedLiveness.h renamed to include/swift/SIL/PrunedLiveness.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
///
1313
/// Incrementally compute and represent basic block liveness of a single live
1414
/// range. The live range is defined by points in the CFG, independent of any
15-
/// particular SSA value. The client initializes liveness with a set of
15+
/// particular SSA value; however, it must be contiguous. Unlike traditional
16+
/// variable liveness, a definition within the live range does not create a
17+
/// "hole" in the live range. The client initializes liveness with a set of
1618
/// definition blocks, typically a single block. The client then incrementally
1719
/// updates liveness by providing a set of "interesting" uses one at a time.
1820
///
@@ -137,7 +139,10 @@ class PrunedLiveBlocks {
137139
public:
138140
bool empty() const { return liveBlocks.empty(); }
139141

140-
void clear() { liveBlocks.clear(); SWIFT_ASSERT_ONLY(seenUse = false); }
142+
void clear() {
143+
liveBlocks.clear();
144+
SWIFT_ASSERT_ONLY(seenUse = false);
145+
}
141146

142147
unsigned numLiveBlocks() const { return liveBlocks.size(); }
143148

include/swift/SILOptimizer/Utils/CanonicalOSSALifetime.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,11 @@
9898

9999
#include "swift/Basic/DAGNodeWorklist.h"
100100
#include "swift/Basic/SmallPtrSetVector.h"
101+
#include "swift/SIL/PrunedLiveness.h"
101102
#include "swift/SIL/SILInstruction.h"
102103
#include "swift/SILOptimizer/Analysis/DominanceAnalysis.h"
103104
#include "swift/SILOptimizer/Analysis/NonLocalAccessBlockAnalysis.h"
104105
#include "swift/SILOptimizer/Utils/InstOptUtils.h"
105-
#include "swift/SILOptimizer/Utils/PrunedLiveness.h"
106106
#include "llvm/ADT/DenseMap.h"
107107
#include "llvm/ADT/SetVector.h"
108108

include/swift/SILOptimizer/Utils/CanonicalizeBorrowScope.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@
3030
#include "swift/Basic/DAGNodeWorklist.h"
3131
#include "swift/Basic/SmallPtrSetVector.h"
3232
#include "swift/SIL/OwnershipUtils.h"
33+
#include "swift/SIL/PrunedLiveness.h"
3334
#include "swift/SIL/SILInstruction.h"
3435
#include "swift/SILOptimizer/Analysis/DominanceAnalysis.h"
3536
#include "swift/SILOptimizer/Analysis/NonLocalAccessBlockAnalysis.h"
3637
#include "swift/SILOptimizer/Utils/InstOptUtils.h"
37-
#include "swift/SILOptimizer/Utils/PrunedLiveness.h"
3838
#include "llvm/ADT/DenseMap.h"
3939
#include "llvm/ADT/SetVector.h"
4040

lib/SIL/Utils/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ target_sources(swiftSIL PRIVATE
1313
OwnershipUtils.cpp
1414
PrettyStackTrace.cpp
1515
Projection.cpp
16+
PrunedLiveness.cpp
1617
SILBridging.cpp
1718
SILInstructionWorklist.cpp
1819
SILRemarkStreamer.cpp

lib/SIL/Utils/OwnershipUtils.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@
1515
#include "swift/Basic/SmallPtrSetVector.h"
1616
#include "swift/SIL/InstructionUtils.h"
1717
#include "swift/SIL/LinearLifetimeChecker.h"
18-
#include "swift/SIL/Projection.h"
1918
#include "swift/SIL/MemAccessUtils.h"
19+
#include "swift/SIL/Projection.h"
20+
#include "swift/SIL/PrunedLiveness.h"
2021
#include "swift/SIL/SILArgument.h"
2122
#include "swift/SIL/SILInstruction.h"
2223

lib/SILOptimizer/Utils/PrunedLiveness.cpp renamed to lib/SIL/Utils/PrunedLiveness.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
#include "swift/SILOptimizer/Utils/PrunedLiveness.h"
13+
#include "swift/SIL/PrunedLiveness.h"
1414
#include "swift/SIL/OwnershipUtils.h"
1515

1616
using namespace swift;
@@ -105,14 +105,13 @@ bool PrunedLiveness::updateForBorrowingOperand(Operand *op) {
105105
// TODO: Handle reborrowed copies by considering the extended borrow
106106
// scope. Temporarily bail-out on reborrows because we can't handle uses
107107
// that aren't dominated by currentDef.
108-
if (!BorrowingOperand(op).visitScopeEndingUses(
109-
[this](Operand *end) {
110-
if (end->getOperandOwnership() == OperandOwnership::Reborrow) {
111-
return false;
112-
}
113-
updateForUse(end->getUser(), /*lifetimeEnding*/ false);
114-
return true;
115-
})) {
108+
if (!BorrowingOperand(op).visitScopeEndingUses([this](Operand *end) {
109+
if (end->getOperandOwnership() == OperandOwnership::Reborrow) {
110+
return false;
111+
}
112+
updateForUse(end->getUser(), /*lifetimeEnding*/ false);
113+
return true;
114+
})) {
116115
return false;
117116
}
118117
return true;

lib/SILOptimizer/Mandatory/DiagnoseLifetimeIssues.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
#include "swift/SIL/ApplySite.h"
3636
#include "swift/SIL/BasicBlockBits.h"
3737
#include "swift/SIL/OwnershipUtils.h"
38+
#include "swift/SIL/PrunedLiveness.h"
3839
#include "swift/SILOptimizer/PassManager/Transforms.h"
39-
#include "swift/SILOptimizer/Utils/PrunedLiveness.h"
4040
#include "clang/AST/DeclObjC.h"
4141
#include "llvm/ADT/DenseMap.h"
4242
#include "llvm/Support/Debug.h"

lib/SILOptimizer/Utils/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ target_sources(swiftSILOptimizer PRIVATE
2020
OptimizerStatsUtils.cpp
2121
PartialApplyCombiner.cpp
2222
PerformanceInlinerUtils.cpp
23-
PrunedLiveness.cpp
2423
SILInliner.cpp
2524
SILSSAUpdater.cpp
2625
SpecializationMangler.cpp

0 commit comments

Comments
 (0)