Skip to content

Move the FSO bailout to the beginning of the pass. #30466

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 18, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<RCIdentityAnalysis>();
auto *EA = PM->getAnalysis<EpilogueARCAnalysis>();
Expand Down