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
[SR-7277] -Onone should inline @inline(__always) #49825
Comments
@swift-ci create |
Remember: as with "early inlining" in the -O pipeline, any additional -Onone inlining pass should never inline an |
@eeckstein, @airspeedswift, @milseman There are two kinds of stdlib functions that need to be annotated: (1) Macro-ish functions that should be inlined at -Onone, even when [I think this should be @inline(__always).] (2) Helpers (typically generic) that we need to heavily bias toward inlining when the
[I think this should be @inline(__optimized).] The behavior of @inline(__optimized) should be: inline whenever the @belkadan, the argument against my proposal is that @_transparent already serves So, why can't @transparent be used in those cases where we truly want Take for example: private var kCFStringEncodingASCII : _swift_shims_CFStringEncoding {
@inline(__always) get { return 0x0600 }
}
private var kCFStringEncodingUTF8 : _swift_shims_CFStringEncoding {
@inline(__always) get { return 0x8000100 }
}
extension Unicode.Scalar {
@inline(__always) // common fast-path
internal var _hasNormalizationBoundaryBefore: Bool {
// Fast-path: All scalars up through U+02FF are NFC and have boundaries
// before them
if self.value < 0x300 { return true }
_internalInvariant(Int32(exactly: self.value) != nil, "top bit shouldn't be set")
let value = Int32(bitPattern: self.value)
return 0 != __swift_stdlib_unorm2_hasBoundaryBefore(
_Normalization._nfcNormalizer, value)
}
} — |
_transparent is for diagnostics, which means it affects the speed of Live Issues. I don't think we want to pay the time inlining other things at that point. I think separating (1) and (2) is reasonable, but I still think there's a difference between (1) and _transparent. |
(Alternately, I'd be fine with not having (1), just (2) under its new name, but then I'm worried people will say "oh, this really needs to be inlined at -Onone" and start abusing _transparent for it.) |
I'm mainly advocating that we add |
To elaborate, I'm sure we will eventually need to do much more performance work for -Onone and |
The concern I have with adding more attribute variations is that it's hard to explain when to use which one. Even today people are confused about transparent vs inline(__always). |
The proposed naming eliminates the current confusion about which annotation to use. Anyone reaching for "always inline" will naturally use People will stop mistakenly using Most of the cases we have been adding to the stdlib recently are actually "try hard to inline this into optimized code". Naturally those should use |
Additional Detail from JIRA
md5: 5b473394d4161c33c60f34650a4dfd6d
relates to:
Issue Description:
There needs to be a way to force inlining at
-Onone
.@inline(__always)
is a fine way to do that for now.This probably has to be done as a separate -Onone inlining pass, because we don't want that inlining to affect diagnostics.
The text was updated successfully, but these errors were encountered: