Skip to content

Commit 8a3dc10

Browse files
committed
[CanonicalizeOSSABoundary] Used ::computeBoundary.
Previously, CanonicalizeOSSALifetime had its own copy of a variation of the code for computing the liveness boundary that PrunedLiveness has. Here, it is switched over to using PrunedLiveness' version. In order to do that without complicating the interface for PrunedLivness by adding a visitor, the extra bookkeeping that was being done for destroy_values and debug_values is dropped. Instead, after getting an original boundary from PrunedLiveness::computeBoundary, the boundary is extended out to preexisting destroys which are not separated from the original boundary by "interesting" instructions.
1 parent 91d530f commit 8a3dc10

File tree

3 files changed

+281
-226
lines changed

3 files changed

+281
-226
lines changed

include/swift/SILOptimizer/Utils/CanonicalOSSALifetime.h

Lines changed: 5 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -134,18 +134,10 @@ class CanonicalOSSAConsumeInfo {
134134
/// Map blocks on the lifetime boundary to the last consuming instruction.
135135
llvm::SmallDenseMap<SILBasicBlock *, SILInstruction *, 4> finalBlockConsumes;
136136

137-
/// Record any debug_value instructions found after a final consume.
138-
SmallVector<DebugValueInst *, 8> debugAfterConsume;
139-
140137
public:
141-
void clear() {
142-
finalBlockConsumes.clear();
143-
debugAfterConsume.clear();
144-
}
138+
void clear() { finalBlockConsumes.clear(); }
145139

146-
bool empty() {
147-
return finalBlockConsumes.empty() && debugAfterConsume.empty();
148-
}
140+
bool empty() { return finalBlockConsumes.empty(); }
149141

150142
bool hasUnclaimedConsumes() const { return !finalBlockConsumes.empty(); }
151143

@@ -167,21 +159,6 @@ class CanonicalOSSAConsumeInfo {
167159
return false;
168160
}
169161

170-
/// Record a debug_value that is known to be outside pruned liveness. Assumes
171-
/// that instructions are only visited once.
172-
void recordDebugAfterConsume(DebugValueInst *dvi) {
173-
debugAfterConsume.push_back(dvi);
174-
}
175-
176-
void popDebugAfterConsume(DebugValueInst *dvi) {
177-
if (!debugAfterConsume.empty() && debugAfterConsume.back() == dvi)
178-
debugAfterConsume.pop_back();
179-
}
180-
181-
ArrayRef<DebugValueInst *> getDebugInstsAfterConsume() const {
182-
return debugAfterConsume;
183-
}
184-
185162
SWIFT_ASSERT_ONLY_DECL(void dump() const LLVM_ATTRIBUTE_USED);
186163
};
187164

@@ -357,9 +334,7 @@ class CanonicalizeOSSALifetime {
357334
InstModCallbacks &getCallbacks() { return deleter.getCallbacks(); }
358335

359336
protected:
360-
void recordDebugValue(DebugValueInst *dvi) {
361-
debugValues.insert(dvi);
362-
}
337+
void recordDebugValue(DebugValueInst *dvi) { debugValues.insert(dvi); }
363338

364339
void recordConsumingUse(Operand *use) {
365340
consumingBlocks.insert(use->getUser()->getParent());
@@ -370,12 +345,9 @@ class CanonicalizeOSSALifetime {
370345

371346
void extendLivenessThroughOverlappingAccess();
372347

373-
void findOrInsertDestroyInBlock(SILBasicBlock *bb);
374-
375-
void findOrInsertDestroys();
348+
void findExtendedBoundary(PrunedLivenessBoundary &boundary);
376349

377-
void findOrInsertDestroyOnCFGEdge(SILBasicBlock *predBB,
378-
SILBasicBlock *succBB);
350+
void insertDestroysOnBoundary(PrunedLivenessBoundary &boundary);
379351

380352
void rewriteCopies();
381353
};

0 commit comments

Comments
 (0)