-
Notifications
You must be signed in to change notification settings - Fork 10.5k
PerformanceInliner: protect against misuse of @inline(__always) #64635
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 |
Inline-always should only be used on relatively small functions. It must not be used on recursive functions. Add a check that prevents that inlining of large @inline(__always) functions. swiftlang#64319 rdar://106655649
2ae8fb3
to
0a4b0a8
Compare
@swift-ci test |
@swift-ci benchmark |
Is it possible for this to emit a diagnostic when |
This could potentially break one thing I've been using |
It's complicated. Inlining decisions are made in the optimizer pipeline based on heuristics. Such a diagnostic would be very brittle. For example, you wouldn't see it when building in debug configuration. Unrelated code changes could let the diagnostic appear/disappear.
|
Is this for performance reasons? If yes, are you sure that the There is a good reason that this attribute is underscored. The original intention of There are only very few cases in "regular" programs (outside the stdlib) where |
It is for performance reasons, and I should have tested my assumptions beforehand. No, it doesn't seem to make any significant difference in performance (maybe a 2% margin between Manually doing the operation I hoped Being able to say "I want you to copy and specialise this function body for each of these constant inputs" would be a useful operation (since maintaining four near-identical copies of the same function isn't ideal), but obviously I was wrong to assume |
The optimizer does specialize functions for certain kind of constants, including closures. But it's not configurable |
Inline-always should only be used on relatively small functions. It must not be used on recursive functions.
Add a check that prevents that inlining of large @inline(__always) functions.
Also, add a command line option for better debugging large pass runtimes.
#64319
rdar://106655649