File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed
Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -321,6 +321,10 @@ struct TypeTreeLeafTypeRange {
321321 SmallVectorImpl<std::pair<SILValue, TypeTreeLeafTypeRange>>
322322 &resultingProjections);
323323
324+ static void visitContiguousRanges (
325+ SmallBitVector const &bits,
326+ llvm::function_ref<void (TypeTreeLeafTypeRange)> callback);
327+
324328 bool operator ==(const TypeTreeLeafTypeRange &other) const {
325329 return startEltOffset == other.startEltOffset &&
326330 endEltOffset == other.endEltOffset ;
@@ -1217,6 +1221,11 @@ class FieldSensitiveMultiDefPrunedLiveRange
12171221 defBlocks.setFrozen ();
12181222 }
12191223
1224+ void initializeDef (SILInstruction *def, SmallBitVector const &bits) {
1225+ TypeTreeLeafTypeRange::visitContiguousRanges (
1226+ bits, [&](auto range) { initializeDef (def, range); });
1227+ }
1228+
12201229 void initializeDef (SILValue def, TypeTreeLeafTypeRange span) {
12211230 assert (Super::isInitialized ());
12221231 defs.insert (def, span);
Original file line number Diff line number Diff line change @@ -474,6 +474,29 @@ void TypeTreeLeafTypeRange::constructProjectionsForNeededElements(
474474 }
475475}
476476
477+ void TypeTreeLeafTypeRange::visitContiguousRanges (
478+ SmallBitVector const &bits,
479+ llvm::function_ref<void (TypeTreeLeafTypeRange)> callback) {
480+ if (bits.size () == 0 )
481+ return ;
482+
483+ llvm::Optional<unsigned > current = llvm::None;
484+ for (unsigned bit = 0 , size = bits.size (); bit < size; ++bit) {
485+ auto isSet = bits.test (bit);
486+ if (current) {
487+ if (!isSet) {
488+ callback (TypeTreeLeafTypeRange (*current, bit));
489+ current = llvm::None;
490+ }
491+ } else if (isSet) {
492+ current = bit;
493+ }
494+ }
495+ if (current) {
496+ callback (TypeTreeLeafTypeRange (*current, bits.size ()));
497+ }
498+ }
499+
477500// ===----------------------------------------------------------------------===//
478501// MARK: FieldSensitivePrunedLiveBlocks
479502// ===----------------------------------------------------------------------===//
You can’t perform that action at this time.
0 commit comments