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