-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Sema] Add flag to optimize building swiftmodule files preserving type info for LLDB #34612
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 Please smoke 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.
Makes sense to me!
edf4098
to
526adc6
Compare
@swift-ci Please smoke test |
@swift-ci Please test |
Build failed |
Build failed |
@swift-ci Please smoke test |
1 similar comment
@swift-ci Please smoke 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.
LGTM
// %FileCheck %s --check-prefixes CHECK,CHECK-NONINLINE-ONLY < %t/Skip.noninlinable.sil | ||
// %FileCheck %s --check-prefixes CHECK,CHECK-ALL-ONLY < %t/Skip.all.sil |
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.
Ouch. Not sure how I missed that, thanks! I think I changed to outputting to a file quite late...
@@ -58,16 +62,14 @@ public class InlinableDeinit { | |||
@_fixed_layout | |||
public class InlineAlwaysDeinit { | |||
@inline(__always) deinit { | |||
let ALLNOTYPECHECK_local = 1 | |||
let INLINENOTYPECHECK_local = 1 | |||
let NEVERTYPECHECK_local = 1 |
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.
Didn't realise you could specify that arg multiple times, handy. Much nicer 👍
// %FileCheck %s --check-prefixes CHECK,CHECK-ALL-ONLY < %t/Skip.all.sil | ||
// RUN: %target-swift-frontend -emit-sil -emit-sorted-sil -experimental-skip-non-inlinable-function-bodies -debug-forbid-typecheck-prefix NEVERTYPECHECK -debug-forbid-typecheck-prefix INLINENOTYPECHECK %s -o %t/Skip.noninlinable.sil | ||
// RUN: %target-swift-frontend -emit-sil -emit-sorted-sil -experimental-skip-non-inlinable-function-bodies-without-types -debug-forbid-typecheck-prefix NEVERTYPECHECK -debug-forbid-typecheck-prefix TYPESNOTYPECHECK %s -o %t/Skip.withouttypes.sil | ||
// RUN: %target-swift-frontend -emit-sil -emit-sorted-sil -O -experimental-skip-all-function-bodies -debug-forbid-typecheck-prefix NEVERTYPECHECK -debug-forbid-typecheck-prefix ALLNOTYPECHECK %s -o %t/Skip.all.sil |
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.
If you do make any more changes feel free to remove the -O as well, but doesn't matter either way.
_blackHole("didSet body") // Do not check for "didSet body" as it's in | ||
// SIL but not the swiftinerface. |
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.
Could add a separate check for the swiftinterface?
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 just checked this locally - didSet body
isn't in the serialized SIL for me (CHECK fails, CHECK-NOT succeeds). Am I missing something here?
Also, just noticed typo - "swiftinerface" -> "swiftinterface"
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.
Right, I see a few issues if I set it to CHECK
. First, it fails to find the next string @_transparent method body
, which is probably an ordering issue, the test succeeded because it had already skipped over that string when looking ahead for the CHECK-NOT
. And then I see the string in Skip.noninlinable.sil
but not in Skip.all.sil
, is that expected?
Just to be clear on the terminology, I'd call this textual SIL or simply SIL, serialized SIL wouldn't be as readable.
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.
Sigh, sorry - I rushed this part of the test. Should have double checked the generated textual SIL. The ordering looks a little weird, the willSet is between publicFunc and privateFunc and the didSet is between the transparent init and inlinable init. Assuming that's stable (?) they should both be moved.
It's definitely expected that it's skipped for -experimental-skip-all-function-bodies - that option just skips outputting SIL entirely. I had thought it would be skipped for non-inlinable as well, but that looks like a misunderstanding on my part.
FWIW, the old "skip-noninline-function-bodies.swift" test had a CHECK prefix for SIL vs interface. I had removed it as it was being used, but this looks like a case for it.
@swift-ci Please smoke test Linux platform |
This frontend flag can be used as an alternative to -experimental-skip-non-inlinable-function-bodies that doesn’t skip functions defining nested types. We want to keep these types as they are used by LLDB. Other functions ares safe to skip parsing and type-checking. rdar://71130519
c4d9984
to
02c1343
Compare
@swift-ci Please smoke test |
Thanks for fixing that test up! |
@bnbarham Of course, and thanks for that previous PR, it made this one much cleaner. |
@swift-ci Please smoke test macOS platform |
Uses the newer `-experimental-skip-non-inlinable-function-bodies-without-types` which was introduced here: swiftlang/swift#34612. This should improve LLDB usage in some cases. When using WMO, it has two downsides in Swift 5.5, both introduced by swiftlang/swift#38939: - The swiftmodules will have swiftdeps info embedded in them, which is only needed for incremental compilation - Interface hashing is enabled, which again is only needed for incremental compilation This is because the swift compiler only expects `-experimental-skip-non-inlinable-function-bodies-without-types` to be used with the new `emit-module-separately` incremental build.
Add a new frontend flag
-experimental-skip-non-inlinable-function-bodies-without-types
to skip parsing and type-checking non-inlinable functions bodies that don't define nested types. This flag can be used as an alternative to-experimental-skip-non-inlinable-function-bodies
to keep all type info used by LLDB.rdar://problem/71130519