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