@@ -46,9 +46,6 @@ bool isRetainInstruction(SILInstruction *II);
46
46
// / Return true if this is a release instruction.
47
47
bool isReleaseInstruction (SILInstruction *II);
48
48
49
- using RetainList = TinyPtrVector<SILInstruction *>;
50
- using ReleaseList = TinyPtrVector<SILInstruction *>;
51
-
52
49
// / \returns True if the user \p User decrements the ref count of \p Ptr.
53
50
bool mayDecrementRefCount (SILInstruction *User, SILValue Ptr,
54
51
AliasAnalysis *AA);
@@ -145,7 +142,7 @@ class ConsumedResultToEpilogueRetainMatcher {
145
142
146
143
// We use a list of instructions for now so that we can keep the same interface
147
144
// and handle exploded retain_value later.
148
- RetainList EpilogueRetainInsts;
145
+ TinyPtrVector<SILInstruction *> EpilogueRetainInsts;
149
146
150
147
public:
151
148
// / Finds matching releases in the return block of the function \p F.
@@ -156,7 +153,9 @@ class ConsumedResultToEpilogueRetainMatcher {
156
153
// / Finds matching releases in the provided block \p BB.
157
154
void findMatchingRetains (SILBasicBlock *BB);
158
155
159
- RetainList getEpilogueRetains () { return EpilogueRetainInsts; }
156
+ ArrayRef<SILInstruction *> getEpilogueRetains () const {
157
+ return EpilogueRetainInsts;
158
+ }
160
159
161
160
// / Recompute the mapping from argument to consumed arg.
162
161
void recompute ();
@@ -202,7 +201,9 @@ class ConsumedArgToEpilogueReleaseMatcher {
202
201
RCIdentityFunctionInfo *RCFI;
203
202
ExitKind Kind;
204
203
ArrayRef<SILArgumentConvention> ArgumentConventions;
205
- llvm::SmallMapVector<SILArgument *, ReleaseList, 8 > ArgInstMap;
204
+
205
+ using InstListTy = TinyPtrVector<SILInstruction *>;
206
+ llvm::SmallMapVector<SILArgument *, InstListTy, 8 > ArgInstMap;
206
207
207
208
// / Set to true if we found some releases but not all for the argument.
208
209
llvm::DenseSet<SILArgument *> FoundSomeReleases;
@@ -267,33 +268,32 @@ class ConsumedArgToEpilogueReleaseMatcher {
267
268
return getSingleReleaseForArgument (Arg);
268
269
}
269
270
270
- ReleaseList getReleasesForArgument (SILArgument *Arg) {
271
- ReleaseList Releases;
271
+ ArrayRef<SILInstruction *> getReleasesForArgument (SILArgument *Arg) {
272
272
auto I = ArgInstMap.find (Arg);
273
273
if (I == ArgInstMap.end ())
274
- return Releases ;
275
- return I->second ;
274
+ return {} ;
275
+ return I->second ;
276
276
}
277
277
278
- ReleaseList getReleasesForArgument (SILValue V) {
279
- ReleaseList Releases;
278
+ ArrayRef<SILInstruction *> getReleasesForArgument (SILValue V) {
280
279
auto *Arg = dyn_cast<SILArgument>(V);
281
280
if (!Arg)
282
- return Releases ;
281
+ return {} ;
283
282
return getReleasesForArgument (Arg);
284
283
}
285
284
286
285
// / Recompute the mapping from argument to consumed arg.
287
286
void recompute ();
288
287
289
288
bool isSingleReleaseMatchedToArgument (SILInstruction *Inst) {
290
- auto Pred = [&Inst](const std::pair<SILArgument *,
291
- ReleaseList> &P) -> bool {
292
- if (P.second .size () > 1 )
293
- return false ;
294
- return *P.second .begin () == Inst;
295
- };
296
- return count_if (ArgInstMap, Pred);
289
+ return count_if (
290
+ ArgInstMap,
291
+ [&Inst](const std::pair<SILArgument *, ArrayRef<SILInstruction *>> &P)
292
+ -> bool {
293
+ if (P.second .size () > 1 )
294
+ return false ;
295
+ return *P.second .begin () == Inst;
296
+ });
297
297
}
298
298
299
299
using iterator = decltype (ArgInstMap)::iterator;
@@ -322,11 +322,12 @@ class ConsumedArgToEpilogueReleaseMatcher {
322
322
// / between the releases values in \p Insts and \p Derived, it also bails
323
323
// / out and return true if projection path can not be formed between Base
324
324
// / and any one the released values.
325
- bool isRedundantRelease (ReleaseList Insts, SILValue Base, SILValue Derived);
325
+ bool isRedundantRelease (ArrayRef<SILInstruction *> Insts, SILValue Base,
326
+ SILValue Derived);
326
327
327
328
// / Return true if we have a release instruction for all the reference
328
329
// / semantics part of \p Argument.
329
- bool releaseArgument (ReleaseList Insts, SILValue Argument);
330
+ bool releaseArgument (ArrayRef<SILInstruction *> Insts, SILValue Argument);
330
331
331
332
// / Walk the basic block and find all the releases that match to function
332
333
// / arguments.
0 commit comments