Skip to content

Commit ae745cc

Browse files
committed
Split SignatureOptimzer::analyze(). NFC.
Do some preparations to split function signature into 3 function passes. analyze() has become a dumping ground for code to analyze parameters and result. Split it into 2 functions.
1 parent 6581eba commit ae745cc

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

lib/SILOptimizer/IPO/FunctionSignatureOpts.cpp

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,8 @@ class SignatureAnalyzer {
538538
Allocator(Allocator) {}
539539

540540
bool analyze();
541+
bool analyzeParameters();
542+
bool analyzeResult();
541543

542544
/// Returns the mangled name of the function that should be generated from
543545
/// this function analyzer.
@@ -598,10 +600,7 @@ class SignatureOptimizer {
598600

599601
} // end anonymous namespace
600602

601-
/// This function goes through the arguments of F and sees if we have anything
602-
/// to optimize in which case it returns true. If we have nothing to optimize,
603-
/// it returns false.
604-
bool SignatureAnalyzer::analyze() {
603+
bool SignatureAnalyzer::analyzeParameters() {
605604
// For now ignore functions with indirect results.
606605
if (F->getLoweredFunctionType()->hasIndirectResults())
607606
return false;
@@ -682,6 +681,17 @@ bool SignatureAnalyzer::analyze() {
682681
// Add the argument to our list.
683682
ArgDescList.push_back(std::move(A));
684683
}
684+
685+
return ShouldOptimize;
686+
}
687+
688+
bool SignatureAnalyzer::analyzeResult() {
689+
// For now ignore functions with indirect results.
690+
if (F->getLoweredFunctionType()->hasIndirectResults())
691+
return false;
692+
693+
// Did we decide we should optimize any parameter?
694+
bool ShouldOptimize = false;
685695

686696
// Analyze return result information.
687697
auto DirectResults = F->getLoweredFunctionType()->getDirectResults();
@@ -703,10 +713,18 @@ bool SignatureAnalyzer::analyze() {
703713
++NumOwnedConvertedToNotOwnedResult;
704714
}
705715
}
706-
707716
return ShouldOptimize;
708717
}
709718

719+
/// This function goes through the arguments of F and sees if we have anything
720+
/// to optimize in which case it returns true. If we have nothing to optimize,
721+
/// it returns false.
722+
bool SignatureAnalyzer::analyze() {
723+
bool OptimizedParams = analyzeParameters();
724+
bool OptimizedResult = analyzeResult();
725+
return OptimizedParams || OptimizedResult;
726+
}
727+
710728
//===----------------------------------------------------------------------===//
711729
// Mangling
712730
//===----------------------------------------------------------------------===//

0 commit comments

Comments
 (0)