Skip to content

Commit 3462935

Browse files
authored
Merge pull request #30466 from atrick/fix-fso-bailout
Move the FSO bailout to the beginning of the pass.
2 parents 9716fbb + 80d502c commit 3462935

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

lib/SILOptimizer/FunctionSignatureTransforms/FunctionSignatureOpts.cpp

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -641,18 +641,6 @@ bool FunctionSignatureTransform::run(bool hasCaller) {
641641
TransformDescriptor.hasOnlyDirectInModuleCallers;
642642
SILFunction *F = TransformDescriptor.OriginalFunction;
643643

644-
// Never repeat the same function signature optimization on the same function.
645-
// Multiple function signature optimizations are composed by successively
646-
// optmizing the newly created functions. Each optimization creates a new
647-
// level of thunk. Those should all be ultimately inlined away.
648-
//
649-
// This happens, for example, when a new reference to the original function is
650-
// discovered during devirtualization. That will cause the original function
651-
// (now and FSO thunk) to be pushed back on the function pass pipeline.
652-
if (F->isThunk() == IsSignatureOptimizedThunk) {
653-
LLVM_DEBUG(llvm::dbgs() << " FSO already performed on this thunk\n");
654-
return false;
655-
}
656644

657645
// If we are asked to assume a caller for testing purposes, set the flag.
658646
hasCaller |= FSOOptimizeIfNotCalled;
@@ -814,6 +802,19 @@ class FunctionSignatureOpts : public SILFunctionTransform {
814802
return;
815803
}
816804

805+
// Never repeat the same function signature optimization on the same
806+
// function. Multiple function signature optimizations are composed by
807+
// successively optmizing the newly created functions. Each optimization
808+
// creates a new level of thunk which are all ultimately inlined away.
809+
//
810+
// This happens, for example, when a reference to the original function is
811+
// discovered during devirtualization. That will cause the original function
812+
// (now an FSO thunk) to be pushed back on the function pass pipeline.
813+
if (F->isThunk() == IsSignatureOptimizedThunk) {
814+
LLVM_DEBUG(llvm::dbgs() << " FSO already performed on this thunk\n");
815+
return;
816+
}
817+
817818
// Ok, we think we can perform optimization. Now perform a quick check
818819
auto *RCIA = getAnalysis<RCIdentityAnalysis>();
819820
auto *EA = PM->getAnalysis<EpilogueARCAnalysis>();

0 commit comments

Comments
 (0)