Skip to content

Commit c99f12f

Browse files
committed
[SILOptimizer] Added option to force FSO for uncalled functions.
The new flag -sil-fso-optimize-if-not-called forced function signature optimization to run even on functions which are not called. Doing so is helpful for tests to alleviate the burden of writing code to actually call a function in whose function signature optimization we are interested.
1 parent 0038761 commit c99f12f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lib/SILOptimizer/FunctionSignatureTransforms/FunctionSignatureOpts.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ static llvm::cl::opt<bool>
7070
llvm::cl::desc("Support function signature optimization "
7171
"of generic functions"));
7272

73+
static llvm::cl::opt<bool>
74+
FSOOptimizeIfNotCalled("sil-fso-optimize-if-not-called",
75+
llvm::cl::init(false),
76+
llvm::cl::desc("Optimize even if a function isn't "
77+
"called. For testing only!"));
78+
7379
static bool isSpecializableRepresentation(SILFunctionTypeRepresentation Rep,
7480
bool OptForPartialApply) {
7581
switch (Rep) {
@@ -632,6 +638,9 @@ bool FunctionSignatureTransform::run(bool hasCaller) {
632638
return false;
633639
}
634640

641+
// If we are asked to assume a caller for testing purposes, set the flag.
642+
hasCaller |= FSOOptimizeIfNotCalled;
643+
635644
if (!hasCaller && (F->getDynamicallyReplacedFunction() ||
636645
canBeCalledIndirectly(F->getRepresentation()))) {
637646
LLVM_DEBUG(llvm::dbgs() << " function has no caller -> abort\n");

0 commit comments

Comments
 (0)