@@ -374,12 +374,16 @@ class SILCloner : protected SILInstructionVisitor<ImplClass> {
374
374
375
375
// / This is called by either of the top-level visitors, cloneReachableBlocks
376
376
// / or cloneSILFunction, after all other visitors are have been called.
377
+
378
+ // / `preFixUp` is called first.
379
+ void preFixUp (SILFunction *F) {}
380
+ // / After postFixUp, the SIL must be valid and semantically equivalent to the
381
+ // / SIL before cloning.
377
382
// /
378
- // / After fixUp, the SIL must be valid and semantically equivalent to the SIL
379
- // / before cloning.
380
- // /
381
- // / Common fix-ups are handled first in `doFixUp` and may not be overridden.
382
- void fixUp (SILFunction *F) {}
383
+ // / Common fix-ups are handled first in `commonFixUp` and may not be
384
+ // / overridden.
385
+ void postFixUp (SILFunction *F) {}
386
+
383
387
private:
384
388
// / MARK: SILCloner implementation details hidden from CRTP extensions.
385
389
@@ -388,8 +392,8 @@ class SILCloner : protected SILInstructionVisitor<ImplClass> {
388
392
void visitBlocksDepthFirst (SILBasicBlock *StartBB);
389
393
390
394
// / Also perform fundamental cleanup first, then call the CRTP extension,
391
- // / `fixUp `.
392
- void doFixUp (SILFunction *F);
395
+ // / `postFixUp `.
396
+ void commonFixUp (SILFunction *F);
393
397
};
394
398
395
399
// / A SILBuilder that automatically invokes postprocess on each
@@ -581,7 +585,7 @@ void SILCloner<ImplClass>::cloneReachableBlocks(
581
585
// Discover and map the region to be cloned.
582
586
visitBlocksDepthFirst (startBB);
583
587
584
- doFixUp (F);
588
+ commonFixUp (F);
585
589
}
586
590
587
591
template <typename ImplClass>
@@ -606,7 +610,7 @@ void SILCloner<ImplClass>::cloneFunctionBody(SILFunction *F,
606
610
// This will layout all newly cloned blocks immediate after clonedEntryBB.
607
611
visitBlocksDepthFirst (&*F->begin ());
608
612
609
- doFixUp (F);
613
+ commonFixUp (F);
610
614
}
611
615
612
616
template <typename ImplClass>
@@ -709,9 +713,11 @@ void SILCloner<ImplClass>::visitBlocksDepthFirst(SILBasicBlock *startBB) {
709
713
}
710
714
711
715
// / Clean-up after cloning.
712
- template <typename ImplClass>
713
- void
714
- SILCloner<ImplClass>::doFixUp(SILFunction *F) {
716
+ template <typename ImplClass>
717
+ void SILCloner<ImplClass>::commonFixUp(SILFunction *F) {
718
+ // Call any cleanup specific to the CRTP extensions.
719
+ asImpl ().preFixUp (F);
720
+
715
721
// If our source function is in ossa form, but the function into which we are
716
722
// cloning is not in ossa, after we clone, eliminate default arguments.
717
723
if (!getBuilder ().hasOwnership () && F->hasOwnership ()) {
@@ -745,7 +751,7 @@ SILCloner<ImplClass>::doFixUp(SILFunction *F) {
745
751
}
746
752
747
753
// Call any cleanup specific to the CRTP extensions.
748
- asImpl ().fixUp (F);
754
+ asImpl ().postFixUp (F);
749
755
}
750
756
751
757
template <typename ImplClass>
0 commit comments