diff --git a/lib/SILOptimizer/FunctionSignatureTransforms/FunctionSignatureOpts.cpp b/lib/SILOptimizer/FunctionSignatureTransforms/FunctionSignatureOpts.cpp index 909b9fbd80956..fe78d40870192 100644 --- a/lib/SILOptimizer/FunctionSignatureTransforms/FunctionSignatureOpts.cpp +++ b/lib/SILOptimizer/FunctionSignatureTransforms/FunctionSignatureOpts.cpp @@ -641,18 +641,6 @@ bool FunctionSignatureTransform::run(bool hasCaller) { TransformDescriptor.hasOnlyDirectInModuleCallers; SILFunction *F = TransformDescriptor.OriginalFunction; - // Never repeat the same function signature optimization on the same function. - // Multiple function signature optimizations are composed by successively - // optmizing the newly created functions. Each optimization creates a new - // level of thunk. Those should all be ultimately inlined away. - // - // This happens, for example, when a new reference to the original function is - // discovered during devirtualization. That will cause the original function - // (now and FSO thunk) to be pushed back on the function pass pipeline. - if (F->isThunk() == IsSignatureOptimizedThunk) { - LLVM_DEBUG(llvm::dbgs() << " FSO already performed on this thunk\n"); - return false; - } // If we are asked to assume a caller for testing purposes, set the flag. hasCaller |= FSOOptimizeIfNotCalled; @@ -814,6 +802,19 @@ class FunctionSignatureOpts : public SILFunctionTransform { return; } + // Never repeat the same function signature optimization on the same + // function. Multiple function signature optimizations are composed by + // successively optmizing the newly created functions. Each optimization + // creates a new level of thunk which are all ultimately inlined away. + // + // This happens, for example, when a reference to the original function is + // discovered during devirtualization. That will cause the original function + // (now an FSO thunk) to be pushed back on the function pass pipeline. + if (F->isThunk() == IsSignatureOptimizedThunk) { + LLVM_DEBUG(llvm::dbgs() << " FSO already performed on this thunk\n"); + return; + } + // Ok, we think we can perform optimization. Now perform a quick check auto *RCIA = getAnalysis(); auto *EA = PM->getAnalysis();