Skip to content

Commit b757b2e

Browse files
committed
[FSPrunedLiveness] Return bitfield from isDefBlock
1 parent 22a5a39 commit b757b2e

File tree

2 files changed

+27
-12
lines changed

2 files changed

+27
-12
lines changed

include/swift/SIL/FieldSensitivePrunedLiveness.h

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1325,24 +1325,32 @@ class FieldSensitiveMultiDefPrunedLiveRange
13251325
*iter, [&](TypeTreeLeafTypeRange span) { return span.contains(bit); });
13261326
}
13271327

1328-
bool isDefBlock(SILBasicBlock *block, TypeTreeLeafTypeRange span) const {
1328+
void isDefBlock(SILBasicBlock *block, TypeTreeLeafTypeRange span,
1329+
SmallBitVector &bitsOut) const {
13291330
assert(isInitialized());
1331+
assert(bitsOut.none());
13301332
auto iter = defBlocks.find(block);
13311333
if (!iter)
1332-
return false;
1333-
return llvm::any_of(*iter, [&](TypeTreeLeafTypeRange storedSpan) {
1334-
return span.setIntersection(storedSpan).has_value();
1335-
});
1334+
return;
1335+
for (auto defSpan : *iter) {
1336+
auto intersection = span.setIntersection(defSpan);
1337+
if (!intersection.has_value())
1338+
continue;
1339+
intersection.value().setBits(bitsOut);
1340+
}
13361341
}
13371342

1338-
bool isDefBlock(SILBasicBlock *block, SmallBitVector const &bits) const {
1343+
void isDefBlock(SILBasicBlock *block, SmallBitVector const &bits,
1344+
SmallBitVector &bitsOut) const {
13391345
assert(isInitialized());
1346+
assert(bitsOut.none());
13401347
auto iter = defBlocks.find(block);
13411348
if (!iter)
1342-
return false;
1343-
return llvm::any_of(*iter, [&](TypeTreeLeafTypeRange storedSpan) {
1344-
return storedSpan.intersects(bits);
1345-
});
1349+
return;
1350+
for (auto defSpan : *iter) {
1351+
defSpan.setBits(bitsOut);
1352+
}
1353+
bitsOut &= bits;
13461354
}
13471355

13481356
/// Return true if \p user occurs before the first def in the same basic

lib/SILOptimizer/Mandatory/MoveOnlyAddressCheckerUtils.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2688,12 +2688,19 @@ bool GlobalLivenessChecker::testInstVectorLiveness(
26882688
// This can happen for instance along an exit block of a loop where
26892689
// the error use is within the loop.
26902690
continue;
2691-
case IsLive::LiveOut:
2691+
case IsLive::LiveOut: {
26922692
LLVM_DEBUG(llvm::dbgs() << " Live out block!\n");
26932693
// If we see a live out block that is also a def block, we need to fa
2694-
assert(!liveness.isDefBlock(block, errorSpan) &&
2694+
#ifndef NDEBUG
2695+
SmallBitVector defBits(addressUseState.getNumSubelements());
2696+
liveness.isDefBlock(block, errorSpan, defBits);
2697+
SmallBitVector errorSpanBits(addressUseState.getNumSubelements());
2698+
errorSpan.setBits(errorSpanBits);
2699+
assert((defBits & errorSpanBits).none() &&
26952700
"If in def block... we are in liveness block");
2701+
#endif
26962702
[[clang::fallthrough]];
2703+
}
26972704
case IsLive::LiveWithin:
26982705
if (isLive == IsLive::LiveWithin)
26992706
LLVM_DEBUG(llvm::dbgs() << " Live within block!\n");

0 commit comments

Comments
 (0)