-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Fix several problems with performance annotations #65820
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
Conversation
@swift-ci test |
@swift-ci benchmark |
1393816
to
52ac4d1
Compare
@swift-ci test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great based on a quick review. I mostly need to trust you on correctness. Too much to review in careful detail.
@@ -758,6 +758,11 @@ static void addLowLevelPassPipeline(SILPassPipelinePlan &P) { | |||
|
|||
addFunctionPasses(P, OptimizationLevelKind::LowLevel); | |||
|
|||
// The NamedReturnValueOptimization shouldn't be done before serialization, | |||
// because it might prevent predictable memory optimizations in the caller | |||
// after inlining. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for commenting this pipeline restriction. Pipeline comments are helpful, but I think we should also have a convention that pass dependencies are specified in the file that defines the pass. That's where people will see it when they are investigating the pass, and the information won't be lost as easily. I regularly see the pipeline comments get messed up as people hack on it. In the pass file, you can describe the dependency in more detail with examples. In this case, I'm not sure why NRVO interferes with predictable mem opts, but deferring it until after serialization seems reasonable. It doesn't seem needed for canonicalization and might not be useful if inlining happens.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍I added a comment
@@ -0,0 +1,132 @@ | |||
// RUN: %target-sil-opt -enable-sil-verify-all %s -mandatory-performance-optimizations | %FileCheck %s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: filename typo optimiations
…oves the self parameter of a method When dropping the self metatype parameter of a method, it must become a "thin" function. Fixes a crash when using performance annotations. rdar://107202455
The module doesn't necessarily need to be in a valid state when de-serializing a function
This was a leftover from the time we didn't use C++ interop
Performance annotations can now be used without specifying this option
…the `Deallocation` protocol
as a shortcut for `Instruction.setOperand`
…ng to a separate function pass This allows to run the NamedReturnValueOptimization only late in the pipeline. The optimization shouldn't be done before serialization, because it might prevent predictable memory optimizations in the caller after inlining.
…ries Instead bail when trying to deleted a dead closure or when performing the apply-of-partial_apply optimization. TODO: In OSSA this should be solvable without the need of copies to temporaries.
… partial_apply * move the apply of partial_apply transformation from simplify-apply to simplify-partial_apply * delete dead partial_apply instructions * devirtualize apply, try_apply and begin_apply
* `Options.assertConfiguration` * `Argument.isIndirectResult` * in `Function`: `selfArgument`, `isTransparent`, `performanceConstraints` and `inlineStrategy` * `BuiltinInst.substitutionMap` * `SubstitutionMap.replacementTypes` * `Type.canBeClass`
As a replacement for the old MandatoryGenericSpecializer The pass it not enabled yet in the pass pipeline
…PerformanceOptimizations in the pipeline
52ac4d1
to
13108d6
Compare
@swift-ci smoke test and merge |
And rewrite the MandatoryGenericSpecializer in Swift.
The new MandatoryPerformanceOptimizations pass is more powerful because it uses the existing instruction simplification infrastructure. This fixes some false alarms with the performance annotations
_noLocks
and_noAllocation
.This PR contains several other small fixes and improvements, like extracting the named-return-value optimization from CopyForwarding into its own pass.
For details see the commit messages.
rdar://107576739
rdar://107576844
rdar://107017103, #64511