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
// / -------------------
@@ -178,7 +178,7 @@ struct BlockState {
178
178
179
179
// / CodeMotionContext - This is the base class which retain code motion and
180
180
// / release code motion inherits from. It defines an interface as to how the
181
- // / code motion precedure should be.
181
+ // / code motion procedure should be.
182
182
class CodeMotionContext {
183
183
protected:
184
184
// / Dataflow needs multiple iteration to converge. If this is false, then we
@@ -204,8 +204,8 @@ class CodeMotionContext {
204
204
// / All the unique refcount roots retained or released in the function.
205
205
llvm::SetVector<SILValue> RCRootVault;
206
206
207
- // / Contains a map between rc roots to their index in the RCRootVault.
208
- // / used to facilitate fast rc roots to index lookup.
207
+ // / Contains a map between RC roots to their index in the RCRootVault.
208
+ // / used to facilitate fast RC roots to index lookup.
209
209
llvm::DenseMap<SILValue, unsigned > RCRootIndex;
210
210
211
211
// / All the retains or releases originally in the function. Eventually
@@ -216,7 +216,7 @@ class CodeMotionContext {
216
216
using InsertPointList = llvm::SmallVector<SILInstruction *, 2 >;
217
217
llvm::SmallDenseMap<SILValue, InsertPointList> InsertPoints;
218
218
219
- // / These are the blocks that have a RC instruction to process or it blocks
219
+ // / These are the blocks that have an RC instruction to process or it blocks
220
220
// / some RC instructions. If the basic block has neither, we do not need to
221
221
// / process the block again in the last iteration. We populate this set when
222
222
// / we compute the genset and killset.
@@ -234,7 +234,7 @@ class CodeMotionContext {
234
234
return RCCache[R] = RCFI->getRCIdentityRoot (R);
235
235
}
236
236
237
- // / Return the rc-identity root of the rc instruction, i.e.
237
+ // / Return the rc-identity root of the RC instruction, i.e.
238
238
// / retain or release.
239
239
SILValue getRCRoot (SILInstruction *I) {
240
240
assert (isRetainInstruction (I) || isReleaseInstruction (I) &&
@@ -255,7 +255,7 @@ class CodeMotionContext {
255
255
// / Run the data flow to move retains and releases.
256
256
bool run ();
257
257
258
- // / Check whether we need to run an optimitic iteration data flow.
258
+ // / Check whether we need to run an optimistic iteration data flow.
259
259
// / or a pessimistic would suffice.
260
260
virtual bool requireIteration () = 0;
261
261
@@ -347,7 +347,7 @@ class RetainCodeMotionContext : public CodeMotionContext {
347
347
// These terminator instructions block.
348
348
if (isa<ReturnInst>(II) || isa<ThrowInst>(II) || isa<UnreachableInst>(II))
349
349
return true ;
350
- // Identical rc root blocks code motion, we will be able to move this retain
350
+ // Identical RC root blocks code motion, we will be able to move this retain
351
351
// further once we move the blocking retain.
352
352
if (isRetainInstruction (II) && getRCRoot (II) == Ptr)
353
353
return true ;
@@ -455,7 +455,7 @@ void RetainCodeMotionContext::initializeCodeMotionBBMaxSet() {
455
455
}
456
456
457
457
// Process the instructions in the basic block to find what refcounted
458
- // roots are retained. If we know that a rc root cant be retained at a
458
+ // roots are retained. If we know that an RC root cant be retained at a
459
459
// basic block, then we know we do not need to consider it for the killset.
460
460
// NOTE: this is a conservative approximation, because some retains may be
461
461
// blocked before it reaches this block.
@@ -491,7 +491,8 @@ void RetainCodeMotionContext::computeCodeMotionGenKillSet() {
491
491
}
492
492
}
493
493
494
- // Is this a block thats interesting to the last iteration of the data flow.
494
+ // Is this a block that is interesting to the last iteration of the data
495
+ // flow.
495
496
if (!InterestBlock)
496
497
continue ;
497
498
InterestBlocks.insert (BB);
@@ -652,7 +653,7 @@ class ReleaseBlockState : public BlockState {
652
653
}
653
654
};
654
655
655
- // / ReleaseCodeMotionContext - Context to peroform release code motion.
656
+ // / ReleaseCodeMotionContext - Context to perform release code motion.
656
657
class ReleaseCodeMotionContext : public CodeMotionContext {
657
658
// / All the release block state for all the basic blocks in the function.
658
659
llvm::SmallDenseMap<SILBasicBlock *, ReleaseBlockState *> BlockStates;
@@ -672,7 +673,7 @@ class ReleaseCodeMotionContext : public CodeMotionContext {
672
673
// released value.
673
674
if (II == Ptr)
674
675
return true ;
675
- // Identical rc root blocks code motion, we will be able to move this release
676
+ // Identical RC root blocks code motion, we will be able to move this release
676
677
// further once we move the blocking release.
677
678
if (isReleaseInstruction (II) && getRCRoot (II) == Ptr)
678
679
return true ;
@@ -791,7 +792,7 @@ void ReleaseCodeMotionContext::initializeCodeMotionBBMaxSet() {
791
792
}
792
793
793
794
// Process the instructions in the basic block to find what refcounted
794
- // roots are released. If we know that a rc root cant be released at a
795
+ // roots are released. If we know that an RC root cant be released at a
795
796
// basic block, then we know we do not need to consider it for the killset.
796
797
// NOTE: this is a conservative approximation, because some releases may be
797
798
// blocked before it reaches this block.
@@ -812,7 +813,7 @@ void ReleaseCodeMotionContext::computeCodeMotionGenKillSet() {
812
813
for (unsigned i = 0 ; i < RCRootVault.size (); ++i) {
813
814
if (!State->BBMaxSet .test (i) || !mayBlockCodeMotion (&*I, RCRootVault[i]))
814
815
continue ;
815
- // This instruction blocks this rc root.
816
+ // This instruction blocks this RC root.
816
817
InterestBlock = true ;
817
818
State->BBKillSet .set (i);
818
819
State->BBGenSet .reset (i);
@@ -925,7 +926,7 @@ void ReleaseCodeMotionContext::convergeCodeMotionDataFlow() {
925
926
926
927
void ReleaseCodeMotionContext::computeCodeMotionInsertPoints () {
927
928
// The BBSetIns have converged, run last iteration and figure out insertion
928
- // point for each rc root.
929
+ // point for each RC root.
929
930
for (SILBasicBlock *BB : PO->getPostOrder ()) {
930
931
// Intersect in the successor BBSetIns.
931
932
mergeBBDataFlowStates (BB);
@@ -951,7 +952,7 @@ void ReleaseCodeMotionContext::computeCodeMotionInsertPoints() {
951
952
continue ;
952
953
953
954
// Compute insertion point generated by MayUse terminator inst.
954
- // If terminator instruction can block the rc root. We will have no
955
+ // If terminator instruction can block the RC root. We will have no
955
956
// choice but to anchor the release instructions in the successor blocks.
956
957
for (unsigned i = 0 ; i < RCRootVault.size (); ++i) {
957
958
SILInstruction *Term = BB->getTerminator ();
0 commit comments