-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[DebugInfo] Generate full debug info for generic structs #69902
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 smoke test |
lib/IRGen/IRGenDebugInfo.cpp
Outdated
auto memberTy = | ||
UnsubstitutedType->getTypeOfMember(IGM.getSwiftModule(), VD); | ||
llvm::DIType *DITy = nullptr; | ||
if (llvm::isa<swift::GenericTypeParamType>(memberTy)) { |
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.
Just isa<GenericTypeParamType>
should work. However, I don't see what is special about generic parameter types here. You can also have a member type (T.A), wouldn't that be the same as a generic parameter?
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.
You're right, this was incorrect.
e0f4f0d
to
f896e24
Compare
@swift-ci smoke test |
@swift-ci test macOS |
f896e24
to
6772489
Compare
@swift-ci smoke test |
1 similar comment
@swift-ci smoke test |
lib/IRGen/IRGenDebugInfo.cpp
Outdated
@@ -1037,6 +1046,48 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo { | |||
return DITy; | |||
} | |||
|
|||
/// Creates debug info for a generic struct with archetypes (eg.: |
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.
/// Creates debug info for a generic struct with archetypes (eg.: | |
/// Creates debug info for a generic struct with archetypes (e.g.: |
lib/IRGen/IRGenDebugInfo.cpp
Outdated
} | ||
// Force the creation of the unsubstituted type, don't create it | ||
// directly so it goes through all the caching/verification logic. | ||
getOrCreateType(DbgTy); |
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.
What holds on to this type so it stays alive in the IR?
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 thought getOrCreateType
storing it in the type cache would be enough to keep it alive?
DITypeCache.insert({DbgTy.getType(), llvm::TrackingMDNodeRef(DITy)});
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.
@adrian-prantl the type was only being retained because I happened to be using one of its method in the test program (for example, its init). I changed this to always forcibly retain the type instead.
6772489
to
634a02f
Compare
@swift-ci smoke test |
@swift-ci smoke test Windows |
1 similar comment
@swift-ci smoke test Windows |
Generate the full debug info for generic structs. The strategy is to emit one full entry for the generic type with archetypes, and one forward declaration per instantiation of the generic type. For example, given: ``` struct Pair<T, U> { let t: T let u: U } let p1 = Pair<Int, Double>(t: 1, u: 4.2) let p2 = Pair<String, Bool>(t: "Hello", u: true) ``` DebugInfo will have one entry for Pair<T, U> which includes descriptions of its fields, one forward declaration of Pair<Int, Double> and one forward declaration of Pair<String, Bool>. This information is enough for the algorithms of RemoteMirrors to reconstruct type information for the fully instantiated types.
634a02f
to
1bf6375
Compare
@swift-ci smoke test |
@swift-ci smoke test Windows |
No description provided.