File tree 2 files changed +32
-0
lines changed
2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -321,6 +321,10 @@ struct TypeTreeLeafTypeRange {
321
321
SmallVectorImpl<std::pair<SILValue, TypeTreeLeafTypeRange>>
322
322
&resultingProjections);
323
323
324
+ static void visitContiguousRanges (
325
+ SmallBitVector const &bits,
326
+ llvm::function_ref<void (TypeTreeLeafTypeRange)> callback);
327
+
324
328
bool operator ==(const TypeTreeLeafTypeRange &other) const {
325
329
return startEltOffset == other.startEltOffset &&
326
330
endEltOffset == other.endEltOffset ;
@@ -1217,6 +1221,11 @@ class FieldSensitiveMultiDefPrunedLiveRange
1217
1221
defBlocks.setFrozen ();
1218
1222
}
1219
1223
1224
+ void initializeDef (SILInstruction *def, SmallBitVector const &bits) {
1225
+ TypeTreeLeafTypeRange::visitContiguousRanges (
1226
+ bits, [&](auto range) { initializeDef (def, range); });
1227
+ }
1228
+
1220
1229
void initializeDef (SILValue def, TypeTreeLeafTypeRange span) {
1221
1230
assert (Super::isInitialized ());
1222
1231
defs.insert (def, span);
Original file line number Diff line number Diff line change @@ -474,6 +474,29 @@ void TypeTreeLeafTypeRange::constructProjectionsForNeededElements(
474
474
}
475
475
}
476
476
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
+
477
500
// ===----------------------------------------------------------------------===//
478
501
// MARK: FieldSensitivePrunedLiveBlocks
479
502
// ===----------------------------------------------------------------------===//
You can’t perform that action at this time.
0 commit comments