Skip to content

Commit a12e981

Browse files
authored
Merge pull request #22029 from gottesmm/pr-3be965ec99f16110f8e0f98653dc11410bd754a8
2 parents 8cdb719 + f478305 commit a12e981

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

lib/SILOptimizer/Mandatory/PredictableMemOpt.cpp

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,12 @@ class AvailableValueAggregator;
162162
struct AvailableValue {
163163
friend class AvailableValueAggregator;
164164

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-
169165
SILValue Value;
170166
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;
172171

173172
/// Just for updating.
174173
SmallVectorImpl<PMOMemoryUse> *Uses;
@@ -181,7 +180,7 @@ struct AvailableValue {
181180
/// *NOTE* We assume that all available values start with a singular insertion
182181
/// point and insertion points are added by merging.
183182
AvailableValue(SILValue Value, unsigned SubElementNumber,
184-
SILInstruction *InsertPoint)
183+
StoreInst *InsertPoint)
185184
: Value(Value), SubElementNumber(SubElementNumber), InsertionPoints() {
186185
InsertionPoints.insert(InsertPoint);
187186
}
@@ -221,7 +220,7 @@ struct AvailableValue {
221220
SILValue getValue() const { return Value; }
222221
SILType getType() const { return Value->getType(); }
223222
unsigned getSubElementNumber() const { return SubElementNumber; }
224-
ArrayRef<SILInstruction *> getInsertionPoints() const {
223+
ArrayRef<StoreInst *> getInsertionPoints() const {
225224
return InsertionPoints.getArrayRef();
226225
}
227226

@@ -230,16 +229,14 @@ struct AvailableValue {
230229
InsertionPoints.set_union(Other.InsertionPoints);
231230
}
232231

233-
void addInsertionPoint(SILInstruction *I) & { InsertionPoints.insert(I); }
232+
void addInsertionPoint(StoreInst *I) & { InsertionPoints.insert(I); }
234233

235-
/// TODO: This needs a better name.
236234
AvailableValue emitStructExtract(SILBuilder &B, SILLocation Loc, VarDecl *D,
237235
unsigned SubElementNumber) const {
238236
SILValue NewValue = B.emitStructExtract(Loc, Value, D);
239237
return {NewValue, SubElementNumber, InsertionPoints};
240238
}
241239

242-
/// TODO: This needs a better name.
243240
AvailableValue emitTupleExtract(SILBuilder &B, SILLocation Loc,
244241
unsigned EltNo,
245242
unsigned SubElementNumber) const {
@@ -253,7 +250,7 @@ struct AvailableValue {
253250
private:
254251
/// Private constructor.
255252
AvailableValue(SILValue Value, unsigned SubElementNumber,
256-
const SetVector &InsertPoints)
253+
const decltype(InsertionPoints) &InsertPoints)
257254
: Value(Value), SubElementNumber(SubElementNumber),
258255
InsertionPoints(InsertPoints) {}
259256
};
@@ -524,7 +521,7 @@ SILValue AvailableValueAggregator::handlePrimitiveValue(SILType LoadTy,
524521
//
525522
// This saves us from having to spend compile time in the SSA updater in this
526523
// case.
527-
ArrayRef<SILInstruction *> InsertPts = Val.getInsertionPoints();
524+
ArrayRef<StoreInst *> InsertPts = Val.getInsertionPoints();
528525
if (InsertPts.size() == 1) {
529526
// Use the scope and location of the store at the insertion point.
530527
SILBuilderWithScope Builder(InsertPts[0]);
@@ -679,15 +676,15 @@ void AvailableValueDataflowContext::updateAvailableValues(
679676
// conflict, then we're ok.
680677
auto &Entry = Result[StartSubElt+i];
681678
if (!Entry) {
682-
Entry = {SI->getSrc(), i, Inst};
679+
Entry = {SI->getSrc(), i, SI};
683680
} else {
684681
// TODO: This is /really/, /really/, conservative. This basically means
685682
// that if we do not have an identical store, we will not promote.
686683
if (Entry.getValue() != SI->getSrc() ||
687684
Entry.getSubElementNumber() != i) {
688685
ConflictingValues[StartSubElt + i] = true;
689686
} else {
690-
Entry.addInsertionPoint(Inst);
687+
Entry.addInsertionPoint(SI);
691688
}
692689
}
693690

0 commit comments

Comments
 (0)