File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Expand file tree Collapse file tree 2 files changed +34
-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 ;
@@ -1216,6 +1220,11 @@ class FieldSensitiveMultiDefPrunedLiveRange
1216
1220
defBlocks.setFrozen ();
1217
1221
}
1218
1222
1223
+ void initializeDef (SILInstruction *def, SmallBitVector const &bits) {
1224
+ TypeTreeLeafTypeRange::visitContiguousRanges (
1225
+ bits, [&](auto range) { initializeDef (def, range); });
1226
+ }
1227
+
1219
1228
void initializeDef (SILValue def, TypeTreeLeafTypeRange span) {
1220
1229
assert (Super::isInitialized ());
1221
1230
defs.insert (def, span);
Original file line number Diff line number Diff line change @@ -465,6 +465,31 @@ void TypeTreeLeafTypeRange::constructProjectionsForNeededElements(
465
465
}
466
466
}
467
467
468
+ void TypeTreeLeafTypeRange::visitContiguousRanges (
469
+ SmallBitVector const &bits,
470
+ llvm::function_ref<void (TypeTreeLeafTypeRange)> callback) {
471
+ if (bits.size () == 0 )
472
+ return ;
473
+
474
+ Optional<std::pair<unsigned , /* isSet*/ bool >> current = llvm::None;
475
+ for (unsigned bit = 0 , size = bits.size (); bit < size; ++bit) {
476
+ auto isSet = bits.test (bit);
477
+ if (!current) {
478
+ current = {bit, isSet};
479
+ continue ;
480
+ }
481
+ if (current->second != isSet) {
482
+ if (current->second ) {
483
+ callback (TypeTreeLeafTypeRange (current->first , bit));
484
+ }
485
+ current = {bit, isSet};
486
+ }
487
+ }
488
+ if (current->second ) {
489
+ callback (TypeTreeLeafTypeRange (current->first , bits.size ()));
490
+ }
491
+ }
492
+
468
493
// ===----------------------------------------------------------------------===//
469
494
// MARK: FieldSensitivePrunedLiveBlocks
470
495
// ===----------------------------------------------------------------------===//
You can’t perform that action at this time.
0 commit comments