@@ -562,6 +562,9 @@ namespace {
562
562
struct UseState {
563
563
MarkMustCheckInst *address;
564
564
565
+ using InstToBitMap =
566
+ llvm::SmallMapVector<SILInstruction *, SmallBitVector, 4 >;
567
+
565
568
Optional<unsigned > cachedNumSubelements;
566
569
567
570
// / The blocks that consume fields of the value.
@@ -575,7 +578,7 @@ struct UseState {
575
578
576
579
// / A map from a liveness requiring use to the part of the type that it
577
580
// / requires liveness for.
578
- llvm::SmallMapVector<SILInstruction *, SmallBitVector, 4 > livenessUses;
581
+ InstToBitMap livenessUses;
579
582
580
583
// / A map from a load [copy] or load [take] that we determined must be
581
584
// / converted to a load_borrow to the part of the type tree that it needs to
@@ -625,7 +628,7 @@ struct UseState {
625
628
626
629
// / memInstMustReinitialize insts. Contains both insts like copy_addr/store
627
630
// / [assign] that are reinits that we will convert to inits and true reinits.
628
- llvm::SmallMapVector<SILInstruction *, SmallBitVector, 4 > reinitInsts;
631
+ InstToBitMap reinitInsts;
629
632
630
633
// / The set of drop_deinits of this mark_must_check
631
634
SmallSetVector<SILInstruction *, 2 > dropDeinitInsts;
@@ -652,32 +655,35 @@ struct UseState {
652
655
return *cachedNumSubelements;
653
656
}
654
657
655
- SmallBitVector &getOrCreateLivenessUse (SILInstruction *inst) {
656
- auto iter = livenessUses. find (inst);
657
- if ( iter == livenessUses. end ()) {
658
- iter = livenessUses. insert ({inst, SmallBitVector ( getNumSubelements ())})
659
- .first ;
658
+ SmallBitVector &getOrCreateAffectedBits (SILInstruction *inst,
659
+ InstToBitMap &map) {
660
+ auto iter = map. find (inst);
661
+ if ( iter == map. end ()) {
662
+ iter = map. insert ({inst, SmallBitVector ( getNumSubelements ())}) .first ;
660
663
}
661
664
return iter->second ;
662
665
}
663
666
667
+ void setAffectedBits (SILInstruction *inst, SmallBitVector const &bits,
668
+ InstToBitMap &map) {
669
+ getOrCreateAffectedBits (inst, map) |= bits;
670
+ }
671
+
672
+ void setAffectedBits (SILInstruction *inst, TypeTreeLeafTypeRange range,
673
+ InstToBitMap &map) {
674
+ range.setBits (getOrCreateAffectedBits (inst, map));
675
+ }
676
+
664
677
void recordLivenessUse (SILInstruction *inst, SmallBitVector const &bits) {
665
- getOrCreateLivenessUse (inst) |= bits;
678
+ setAffectedBits (inst, bits, livenessUses) ;
666
679
}
667
680
668
681
void recordLivenessUse (SILInstruction *inst, TypeTreeLeafTypeRange range) {
669
- auto &bits = getOrCreateLivenessUse (inst);
670
- range.setBits (bits);
682
+ setAffectedBits (inst, range, livenessUses);
671
683
}
672
684
673
685
void recordReinitUse (SILInstruction *inst, TypeTreeLeafTypeRange range) {
674
- auto iter = reinitInsts.find (inst);
675
- if (iter == reinitInsts.end ()) {
676
- iter =
677
- reinitInsts.insert ({inst, SmallBitVector (getNumSubelements ())}).first ;
678
- }
679
- auto &bits = iter->second ;
680
- range.setBits (bits);
686
+ setAffectedBits (inst, range, reinitInsts);
681
687
}
682
688
683
689
// / Returns true if this is a terminator instruction that although it doesn't
0 commit comments