@@ -625,7 +625,7 @@ struct UseState {
625
625
626
626
// / A map from an instruction that initializes memory to the description of
627
627
// / the part of the type tree that it initializes.
628
- llvm::SmallMapVector<SILInstruction *, TypeTreeLeafTypeRange, 4 > initInsts;
628
+ InstToBitMap initInsts;
629
629
630
630
// / memInstMustReinitialize insts. Contains both insts like copy_addr/store
631
631
// / [assign] that are reinits that we will convert to inits and true reinits.
@@ -687,6 +687,10 @@ struct UseState {
687
687
setAffectedBits (inst, range, reinitInsts);
688
688
}
689
689
690
+ void recordInitUse (SILInstruction *inst, TypeTreeLeafTypeRange range) {
691
+ setAffectedBits (inst, range, initInsts);
692
+ }
693
+
690
694
// / Returns true if this is a terminator instruction that although it doesn't
691
695
// / use our inout argument directly is used by the pass to ensure that we
692
696
// / reinit said argument if we consumed it in the body of the function.
@@ -881,7 +885,7 @@ struct UseState {
881
885
{
882
886
auto iter = initInsts.find (inst);
883
887
if (iter != initInsts.end ()) {
884
- if (span.setIntersection (iter->second ))
888
+ if (span.intersects (iter->second ))
885
889
return true ;
886
890
}
887
891
}
@@ -1026,7 +1030,7 @@ void UseState::initializeLiveness(
1026
1030
llvm::dbgs ()
1027
1031
<< " Found in/in_guaranteed/inout/inout_aliasable argument as "
1028
1032
" an init... adding mark_must_check as init!\n " );
1029
- initInsts. insert ({ address, liveness.getTopLevelSpan ()} );
1033
+ recordInitUse ( address, liveness.getTopLevelSpan ());
1030
1034
liveness.initializeDef (address, liveness.getTopLevelSpan ());
1031
1035
break ;
1032
1036
case swift::SILArgumentConvention::Indirect_Out:
@@ -1057,14 +1061,14 @@ void UseState::initializeLiveness(
1057
1061
// later invariants that we assert upon remain true.
1058
1062
LLVM_DEBUG (llvm::dbgs () << " Found move only arg closure box use... "
1059
1063
" adding mark_must_check as init!\n " );
1060
- initInsts. insert ({ address, liveness.getTopLevelSpan ()} );
1064
+ recordInitUse ( address, liveness.getTopLevelSpan ());
1061
1065
liveness.initializeDef (address, liveness.getTopLevelSpan ());
1062
1066
}
1063
1067
} else if (auto *box = dyn_cast<AllocBoxInst>(
1064
1068
lookThroughOwnershipInsts (projectBox->getOperand ()))) {
1065
1069
LLVM_DEBUG (llvm::dbgs () << " Found move only var allocbox use... "
1066
1070
" adding mark_must_check as init!\n " );
1067
- initInsts. insert ({ address, liveness.getTopLevelSpan ()} );
1071
+ recordInitUse ( address, liveness.getTopLevelSpan ());
1068
1072
liveness.initializeDef (address, liveness.getTopLevelSpan ());
1069
1073
}
1070
1074
}
@@ -1075,7 +1079,7 @@ void UseState::initializeLiveness(
1075
1079
stripAccessMarkers (address->getOperand ()))) {
1076
1080
LLVM_DEBUG (llvm::dbgs () << " Found ref_element_addr use... "
1077
1081
" adding mark_must_check as init!\n " );
1078
- initInsts. insert ({ address, liveness.getTopLevelSpan ()} );
1082
+ recordInitUse ( address, liveness.getTopLevelSpan ());
1079
1083
liveness.initializeDef (address, liveness.getTopLevelSpan ());
1080
1084
}
1081
1085
@@ -1085,7 +1089,7 @@ void UseState::initializeLiveness(
1085
1089
dyn_cast<GlobalAddrInst>(stripAccessMarkers (address->getOperand ()))) {
1086
1090
LLVM_DEBUG (llvm::dbgs () << " Found global_addr use... "
1087
1091
" adding mark_must_check as init!\n " );
1088
- initInsts. insert ({ address, liveness.getTopLevelSpan ()} );
1092
+ recordInitUse ( address, liveness.getTopLevelSpan ());
1089
1093
liveness.initializeDef (address, liveness.getTopLevelSpan ());
1090
1094
}
1091
1095
@@ -1758,8 +1762,7 @@ bool GatherUsesVisitor::visitUse(Operand *op) {
1758
1762
if (!leafRange)
1759
1763
return false ;
1760
1764
1761
- assert (!useState.initInsts .count (user));
1762
- useState.initInsts .insert ({user, *leafRange});
1765
+ useState.recordInitUse (user, *leafRange);
1763
1766
return true ;
1764
1767
}
1765
1768
0 commit comments