Move the FSO bailout to the beginning of the pass.

This way we catch the DeadFunctionArgs optimization too, which is a
separate sub-pass.
This commit is contained in:
Andrew Trick
2019-02-07 10:09:14 -08:00
parent 85c4e01e4d
commit 80d502c8ef

View File

@@ -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 @@ public:
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<RCIdentityAnalysis>();
auto *EA = PM->getAnalysis<EpilogueARCAnalysis>();