@@ -162,13 +162,12 @@ class AvailableValueAggregator;
162
162
struct AvailableValue {
163
163
friend class AvailableValueAggregator ;
164
164
165
- // / If this gets too expensive in terms of copying, we can use an arena and a
166
- // / FrozenPtrSet like we do in ARC.
167
- using SetVector = llvm::SmallSetVector<SILInstruction *, 1 >;
168
-
169
165
SILValue Value;
170
166
unsigned SubElementNumber;
171
- SetVector InsertionPoints;
167
+
168
+ // / If this gets too expensive in terms of copying, we can use an arena and a
169
+ // / FrozenPtrSet like we do in ARC.
170
+ SmallSetVector<StoreInst *, 1 > InsertionPoints;
172
171
173
172
// / Just for updating.
174
173
SmallVectorImpl<PMOMemoryUse> *Uses;
@@ -181,7 +180,7 @@ struct AvailableValue {
181
180
// / *NOTE* We assume that all available values start with a singular insertion
182
181
// / point and insertion points are added by merging.
183
182
AvailableValue (SILValue Value, unsigned SubElementNumber,
184
- SILInstruction *InsertPoint)
183
+ StoreInst *InsertPoint)
185
184
: Value(Value), SubElementNumber(SubElementNumber), InsertionPoints() {
186
185
InsertionPoints.insert (InsertPoint);
187
186
}
@@ -221,7 +220,7 @@ struct AvailableValue {
221
220
SILValue getValue () const { return Value; }
222
221
SILType getType () const { return Value->getType (); }
223
222
unsigned getSubElementNumber () const { return SubElementNumber; }
224
- ArrayRef<SILInstruction *> getInsertionPoints () const {
223
+ ArrayRef<StoreInst *> getInsertionPoints () const {
225
224
return InsertionPoints.getArrayRef ();
226
225
}
227
226
@@ -230,16 +229,14 @@ struct AvailableValue {
230
229
InsertionPoints.set_union (Other.InsertionPoints );
231
230
}
232
231
233
- void addInsertionPoint (SILInstruction *I) & { InsertionPoints.insert (I); }
232
+ void addInsertionPoint (StoreInst *I) & { InsertionPoints.insert (I); }
234
233
235
- // / TODO: This needs a better name.
236
234
AvailableValue emitStructExtract (SILBuilder &B, SILLocation Loc, VarDecl *D,
237
235
unsigned SubElementNumber) const {
238
236
SILValue NewValue = B.emitStructExtract (Loc, Value, D);
239
237
return {NewValue, SubElementNumber, InsertionPoints};
240
238
}
241
239
242
- // / TODO: This needs a better name.
243
240
AvailableValue emitTupleExtract (SILBuilder &B, SILLocation Loc,
244
241
unsigned EltNo,
245
242
unsigned SubElementNumber) const {
@@ -253,7 +250,7 @@ struct AvailableValue {
253
250
private:
254
251
// / Private constructor.
255
252
AvailableValue (SILValue Value, unsigned SubElementNumber,
256
- const SetVector &InsertPoints)
253
+ const decltype (InsertionPoints) &InsertPoints)
257
254
: Value(Value), SubElementNumber(SubElementNumber),
258
255
InsertionPoints(InsertPoints) {}
259
256
};
@@ -524,7 +521,7 @@ SILValue AvailableValueAggregator::handlePrimitiveValue(SILType LoadTy,
524
521
//
525
522
// This saves us from having to spend compile time in the SSA updater in this
526
523
// case.
527
- ArrayRef<SILInstruction *> InsertPts = Val.getInsertionPoints ();
524
+ ArrayRef<StoreInst *> InsertPts = Val.getInsertionPoints ();
528
525
if (InsertPts.size () == 1 ) {
529
526
// Use the scope and location of the store at the insertion point.
530
527
SILBuilderWithScope Builder (InsertPts[0 ]);
@@ -679,15 +676,15 @@ void AvailableValueDataflowContext::updateAvailableValues(
679
676
// conflict, then we're ok.
680
677
auto &Entry = Result[StartSubElt+i];
681
678
if (!Entry) {
682
- Entry = {SI->getSrc (), i, Inst };
679
+ Entry = {SI->getSrc (), i, SI };
683
680
} else {
684
681
// TODO: This is /really/, /really/, conservative. This basically means
685
682
// that if we do not have an identical store, we will not promote.
686
683
if (Entry.getValue () != SI->getSrc () ||
687
684
Entry.getSubElementNumber () != i) {
688
685
ConflictingValues[StartSubElt + i] = true ;
689
686
} else {
690
- Entry.addInsertionPoint (Inst );
687
+ Entry.addInsertionPoint (SI );
691
688
}
692
689
}
693
690
0 commit comments