@@ -39,6 +39,7 @@ class SILFunction;
39
39
} // end namespace swift
40
40
41
41
namespace swift {
42
+
42
43
// / Return true if this is a retain instruction.
43
44
bool isRetainInstruction (SILInstruction *II);
44
45
@@ -141,16 +142,11 @@ class ConsumedResultToEpilogueRetainMatcher {
141
142
SILFunction *F;
142
143
RCIdentityFunctionInfo *RCFI;
143
144
AliasAnalysis *AA;
145
+
144
146
// We use a list of instructions for now so that we can keep the same interface
145
147
// and handle exploded retain_value later.
146
148
RetainList EpilogueRetainInsts;
147
149
148
- // / Return true if all the successors of the EpilogueRetainInsts do not have
149
- // / a retain.
150
- bool isTransitiveSuccessorsRetainFree (llvm::DenseSet<SILBasicBlock *> BBs);
151
-
152
- // / Finds matching releases in the provided block \p BB.
153
- RetainKindValue findMatchingRetainsInBasicBlock (SILBasicBlock *BB, SILValue V);
154
150
public:
155
151
// / Finds matching releases in the return block of the function \p F.
156
152
ConsumedResultToEpilogueRetainMatcher (RCIdentityFunctionInfo *RCFI,
@@ -182,6 +178,15 @@ class ConsumedResultToEpilogueRetainMatcher {
182
178
unsigned size () const { return EpilogueRetainInsts.size (); }
183
179
184
180
iterator_range<iterator> getRange () { return swift::make_range (begin (), end ()); }
181
+
182
+ private:
183
+ // / Return true if all the successors of the EpilogueRetainInsts do not have
184
+ // / a retain.
185
+ bool isTransitiveSuccessorsRetainFree (llvm::DenseSet<SILBasicBlock *> BBs);
186
+
187
+ // / Finds matching releases in the provided block \p BB.
188
+ RetainKindValue findMatchingRetainsInBasicBlock (SILBasicBlock *BB,
189
+ SILValue V);
185
190
};
186
191
187
192
// / A class that attempts to match owned arguments and corresponding epilogue
@@ -205,32 +210,6 @@ class ConsumedArgToEpilogueReleaseMatcher {
205
210
// / Eventually this will be used in place of HasBlock.
206
211
SILBasicBlock *ProcessedBlock;
207
212
208
- // / Return true if we have seen releases to part or all of \p Derived in
209
- // / \p Insts.
210
- // /
211
- // / NOTE: This function relies on projections to analyze the relation
212
- // / between the releases values in \p Insts and \p Derived, it also bails
213
- // / out and return true if projection path can not be formed between Base
214
- // / and any one the released values.
215
- bool isRedundantRelease (ReleaseList Insts, SILValue Base, SILValue Derived);
216
-
217
- // / Return true if we have a release instruction for all the reference
218
- // / semantics part of \p Argument.
219
- bool releaseArgument (ReleaseList Insts, SILValue Argument);
220
-
221
- // / Walk the basic block and find all the releases that match to function
222
- // / arguments.
223
- void collectMatchingReleases (SILBasicBlock *BB);
224
-
225
- // / Walk the function and find all the destroy_addr instructions that match
226
- // / to function arguments.
227
- void collectMatchingDestroyAddresses (SILBasicBlock *BB);
228
-
229
- // / For every argument in the function, check to see whether all epilogue
230
- // / releases are found. Clear all releases for the argument if not all
231
- // / epilogue releases are found.
232
- void processMatchingReleases ();
233
-
234
213
public:
235
214
// / Finds matching releases in the return block of the function \p F.
236
215
ConsumedArgToEpilogueReleaseMatcher (
@@ -334,6 +313,33 @@ class ConsumedArgToEpilogueReleaseMatcher {
334
313
unsigned size () const { return ArgInstMap.size (); }
335
314
336
315
iterator_range<iterator> getRange () { return swift::make_range (begin (), end ()); }
316
+
317
+ private:
318
+ // / Return true if we have seen releases to part or all of \p Derived in
319
+ // / \p Insts.
320
+ // /
321
+ // / NOTE: This function relies on projections to analyze the relation
322
+ // / between the releases values in \p Insts and \p Derived, it also bails
323
+ // / out and return true if projection path can not be formed between Base
324
+ // / and any one the released values.
325
+ bool isRedundantRelease (ReleaseList Insts, SILValue Base, SILValue Derived);
326
+
327
+ // / Return true if we have a release instruction for all the reference
328
+ // / semantics part of \p Argument.
329
+ bool releaseArgument (ReleaseList Insts, SILValue Argument);
330
+
331
+ // / Walk the basic block and find all the releases that match to function
332
+ // / arguments.
333
+ void collectMatchingReleases (SILBasicBlock *BB);
334
+
335
+ // / Walk the function and find all the destroy_addr instructions that match
336
+ // / to function arguments.
337
+ void collectMatchingDestroyAddresses (SILBasicBlock *BB);
338
+
339
+ // / For every argument in the function, check to see whether all epilogue
340
+ // / releases are found. Clear all releases for the argument if not all
341
+ // / epilogue releases are found.
342
+ void processMatchingReleases ();
337
343
};
338
344
339
345
class ReleaseTracker {
0 commit comments