22
22
// /
23
23
// / This pass is more sophisticated than SILCodeMotion, as arc optimizations
24
24
// / can be very beneficial, use an optimistic global data flow to achieve
25
- // / optimiality .
25
+ // / optimality .
26
26
// /
27
27
// / Proof of Correctness:
28
28
// / -------------------
@@ -180,7 +180,7 @@ struct BlockState {
180
180
181
181
// / CodeMotionContext - This is the base class which retain code motion and
182
182
// / release code motion inherits from. It defines an interface as to how the
183
- // / code motion precedure should be.
183
+ // / code motion procedure should be.
184
184
class CodeMotionContext {
185
185
protected:
186
186
// / Dataflow needs multiple iteration to converge. If this is false, then we
@@ -206,8 +206,8 @@ class CodeMotionContext {
206
206
// / All the unique refcount roots retained or released in the function.
207
207
llvm::SetVector<SILValue> RCRootVault;
208
208
209
- // / Contains a map between rc roots to their index in the RCRootVault.
210
- // / used to facilitate fast rc roots to index lookup.
209
+ // / Contains a map between RC roots to their index in the RCRootVault.
210
+ // / used to facilitate fast RC roots to index lookup.
211
211
llvm::DenseMap<SILValue, unsigned > RCRootIndex;
212
212
213
213
// / All the retains or releases originally in the function. Eventually
@@ -218,7 +218,7 @@ class CodeMotionContext {
218
218
using InsertPointList = llvm::SmallVector<SILInstruction *, 2 >;
219
219
llvm::SmallDenseMap<SILValue, InsertPointList> InsertPoints;
220
220
221
- // / These are the blocks that have a RC instruction to process or it blocks
221
+ // / These are the blocks that have an RC instruction to process or it blocks
222
222
// / some RC instructions. If the basic block has neither, we do not need to
223
223
// / process the block again in the last iteration. We populate this set when
224
224
// / we compute the genset and killset.
@@ -236,7 +236,7 @@ class CodeMotionContext {
236
236
return RCCache[R] = RCFI->getRCIdentityRoot (R);
237
237
}
238
238
239
- // / Return the rc-identity root of the rc instruction, i.e.
239
+ // / Return the rc-identity root of the RC instruction, i.e.
240
240
// / retain or release.
241
241
SILValue getRCRoot (SILInstruction *I) {
242
242
assert (isRetainInstruction (I) || isReleaseInstruction (I) &&
@@ -257,7 +257,7 @@ class CodeMotionContext {
257
257
// / Run the data flow to move retains and releases.
258
258
bool run ();
259
259
260
- // / Check whether we need to run an optimitic iteration data flow.
260
+ // / Check whether we need to run an optimistic iteration data flow.
261
261
// / or a pessimistic would suffice.
262
262
virtual bool requireIteration () = 0;
263
263
@@ -349,7 +349,7 @@ class RetainCodeMotionContext : public CodeMotionContext {
349
349
// These terminator instructions block.
350
350
if (isa<ReturnInst>(II) || isa<ThrowInst>(II) || isa<UnreachableInst>(II))
351
351
return true ;
352
- // Identical rc root blocks code motion, we will be able to move this retain
352
+ // Identical RC root blocks code motion, we will be able to move this retain
353
353
// further once we move the blocking retain.
354
354
if (isRetainInstruction (II) && getRCRoot (II) == Ptr)
355
355
return true ;
@@ -457,7 +457,7 @@ void RetainCodeMotionContext::initializeCodeMotionBBMaxSet() {
457
457
}
458
458
459
459
// Process the instructions in the basic block to find what refcounted
460
- // roots are retained. If we know that a rc root cant be retained at a
460
+ // roots are retained. If we know that an RC root cant be retained at a
461
461
// basic block, then we know we do not need to consider it for the killset.
462
462
// NOTE: this is a conservative approximation, because some retains may be
463
463
// blocked before it reaches this block.
@@ -493,7 +493,8 @@ void RetainCodeMotionContext::computeCodeMotionGenKillSet() {
493
493
}
494
494
}
495
495
496
- // Is this a block thats interesting to the last iteration of the data flow.
496
+ // Is this a block that is interesting to the last iteration of the data
497
+ // flow.
497
498
if (!InterestBlock)
498
499
continue ;
499
500
InterestBlocks.insert (BB);
@@ -657,7 +658,7 @@ class ReleaseBlockState : public BlockState {
657
658
}
658
659
};
659
660
660
- // / ReleaseCodeMotionContext - Context to peroform release code motion.
661
+ // / ReleaseCodeMotionContext - Context to perform release code motion.
661
662
class ReleaseCodeMotionContext : public CodeMotionContext {
662
663
// / All the release block state for all the basic blocks in the function.
663
664
llvm::SmallDenseMap<SILBasicBlock *, ReleaseBlockState *> BlockStates;
@@ -677,7 +678,7 @@ class ReleaseCodeMotionContext : public CodeMotionContext {
677
678
// released value.
678
679
if (II == Ptr)
679
680
return true ;
680
- // Identical rc root blocks code motion, we will be able to move this release
681
+ // Identical RC root blocks code motion, we will be able to move this release
681
682
// further once we move the blocking release.
682
683
if (isReleaseInstruction (II) && getRCRoot (II) == Ptr)
683
684
return true ;
@@ -795,7 +796,7 @@ void ReleaseCodeMotionContext::initializeCodeMotionBBMaxSet() {
795
796
}
796
797
797
798
// Process the instructions in the basic block to find what refcounted
798
- // roots are released. If we know that a rc root cant be released at a
799
+ // roots are released. If we know that an RC root cant be released at a
799
800
// basic block, then we know we do not need to consider it for the killset.
800
801
// NOTE: this is a conservative approximation, because some releases may be
801
802
// blocked before it reaches this block.
@@ -816,7 +817,7 @@ void ReleaseCodeMotionContext::computeCodeMotionGenKillSet() {
816
817
for (unsigned i = 0 ; i < RCRootVault.size (); ++i) {
817
818
if (!State->BBMaxSet .test (i) || !mayBlockCodeMotion (&*I, RCRootVault[i]))
818
819
continue ;
819
- // This instruction blocks this rc root.
820
+ // This instruction blocks this RC root.
820
821
InterestBlock = true ;
821
822
State->BBKillSet .set (i);
822
823
State->BBGenSet .reset (i);
@@ -932,7 +933,7 @@ void ReleaseCodeMotionContext::convergeCodeMotionDataFlow() {
932
933
933
934
void ReleaseCodeMotionContext::computeCodeMotionInsertPoints () {
934
935
// The BBSetIns have converged, run last iteration and figure out insertion
935
- // point for each rc root.
936
+ // point for each RC root.
936
937
for (SILBasicBlock *BB : PO->getPostOrder ()) {
937
938
// Intersect in the successor BBSetIns.
938
939
mergeBBDataFlowStates (BB);
@@ -958,7 +959,7 @@ void ReleaseCodeMotionContext::computeCodeMotionInsertPoints() {
958
959
continue ;
959
960
960
961
// Compute insertion point generated by MayUse terminator inst.
961
- // If terminator instruction can block the rc root. We will have no
962
+ // If terminator instruction can block the RC root. We will have no
962
963
// choice but to anchor the release instructions in the successor blocks.
963
964
for (unsigned i = 0 ; i < RCRootVault.size (); ++i) {
964
965
SILInstruction *Term = BB->getTerminator ();
0 commit comments