12
12
// /
13
13
// / \file
14
14
// /
15
- // / This pass defines function signature related optimizations. Everytime a
16
- // / function signature optimization is performed, changes are made to the
17
- // / original function and after all function signature optimizations are
15
+ // / This pass defines function signature related optimizations.
16
+ // / When a function signature optimization is performed, changes are made to
17
+ // / the original function and after all function signature optimizations are
18
18
// / finished, a new function is created and the old function is turned into
19
19
// / a thunk.
20
20
// /
@@ -164,8 +164,9 @@ class FunctionSignatureTransform {
164
164
// / ----------------------------------------------------------///
165
165
// / Find any dead argument opportunities.
166
166
bool DeadArgumentAnalyzeParameters ();
167
- // / Do the actual dead argument transformations.
168
- void DeadArgumentTransformParameters ();
167
+ // / Modify the current function so that later function signature analysis
168
+ // / are more effective.
169
+ void DeadArgumentTransformFunction ();
169
170
// / Remove the dead argument once the new function is created.
170
171
void DeadArgumentFinalizeOptimizedFunction ();
171
172
@@ -174,8 +175,11 @@ class FunctionSignatureTransform {
174
175
// / ----------------------------------------------------------///
175
176
bool OwnedToGuaranteedAnalyzeResults ();
176
177
bool OwnedToGuaranteedAnalyzeParameters ();
177
- void OwnedToGuaranteedTransformResults ();
178
- void OwnedToGuaranteedTransformParameters ();
178
+
179
+ // / Modify the current function so that later function signature analysis
180
+ // / are more effective.
181
+ void OwnedToGuaranteedTransformFunctionResults ();
182
+ void OwnedToGuaranteedTransformFunctionParameters ();
179
183
180
184
// / Find any owned to guaranteed opportunities.
181
185
bool OwnedToGuaranteedAnalyze () {
@@ -186,8 +190,8 @@ class FunctionSignatureTransform {
186
190
187
191
// / Do the actual owned to guaranteeed transformations.
188
192
void OwnedToGuaranteedTransform () {
189
- OwnedToGuaranteedTransformResults ();
190
- OwnedToGuaranteedTransformParameters ();
193
+ OwnedToGuaranteedTransformFunctionResults ();
194
+ OwnedToGuaranteedTransformFunctionParameters ();
191
195
}
192
196
193
197
// / Set up epilogue work for the thunk result based in the given argument.
@@ -274,7 +278,7 @@ class FunctionSignatureTransform {
274
278
// already created a thunk.
275
279
if ((hasCaller || Changed) && DeadArgumentAnalyzeParameters ()) {
276
280
Changed = true ;
277
- DeadArgumentTransformParameters ();
281
+ DeadArgumentTransformFunction ();
278
282
}
279
283
280
284
// Run ArgumentExplosion transformation. We only specialize
@@ -551,7 +555,7 @@ bool FunctionSignatureTransform::DeadArgumentAnalyzeParameters() {
551
555
return SignatureOptimize;
552
556
}
553
557
554
- void FunctionSignatureTransform::DeadArgumentTransformParameters () {
558
+ void FunctionSignatureTransform::DeadArgumentTransformFunction () {
555
559
SILBasicBlock *BB = &*F->begin ();
556
560
for (const ArgumentDescriptor &AD : ArgumentDescList) {
557
561
if (!AD.IsEntirelyDead )
@@ -643,20 +647,22 @@ bool FunctionSignatureTransform::OwnedToGuaranteedAnalyzeResults() {
643
647
return SignatureOptimize;
644
648
}
645
649
646
- void FunctionSignatureTransform::OwnedToGuaranteedTransformParameters () {
650
+ void FunctionSignatureTransform::OwnedToGuaranteedTransformFunctionParameters () {
647
651
// And remove all Callee releases that we found and made redundant via owned
648
652
// to guaranteed conversion.
649
653
for (const ArgumentDescriptor &AD : ArgumentDescList) {
650
654
if (!AD.OwnedToGuaranteed )
651
655
continue ;
652
- for (auto &X : AD.CalleeRelease )
656
+ for (auto &X : AD.CalleeRelease ) {
653
657
X->eraseFromParent ();
654
- for (auto &X : AD.CalleeReleaseInThrowBlock )
658
+ }
659
+ for (auto &X : AD.CalleeReleaseInThrowBlock ) {
655
660
X->eraseFromParent ();
661
+ }
656
662
}
657
663
}
658
664
659
- void FunctionSignatureTransform::OwnedToGuaranteedTransformResults () {
665
+ void FunctionSignatureTransform::OwnedToGuaranteedTransformFunctionResults () {
660
666
// And remove all callee retains that we found and made redundant via owned
661
667
// to unowned conversion.
662
668
for (const ResultDescriptor &RD : ResultDescList) {
@@ -852,7 +858,6 @@ class FunctionSignatureOpts : public SILFunctionTransform {
852
858
if (!canSpecializeFunction (F))
853
859
return ;
854
860
855
- llvm::BumpPtrAllocator BPA;
856
861
auto *AA = PM->getAnalysis <AliasAnalysis>();
857
862
auto *RCIA = getAnalysis<RCIdentityAnalysis>();
858
863
@@ -876,7 +881,7 @@ class FunctionSignatureOpts : public SILFunctionTransform {
876
881
llvm::SmallVector<ResultDescriptor, 4 > ResultDescList;
877
882
ArrayRef<SILArgument *> Args = F->begin ()->getBBArgs ();
878
883
for (unsigned i = 0 , e = Args.size (); i != e; ++i) {
879
- ArgumentDescList.emplace_back (BPA, Args[i]);
884
+ ArgumentDescList.emplace_back (Args[i]);
880
885
}
881
886
for (SILResultInfo IR : F->getLoweredFunctionType ()->getAllResults ()) {
882
887
ResultDescList.emplace_back (IR);
0 commit comments