Open typesanitizer opened 3 years ago
@swift-ci create
Comment by Rajagopalan Gangadharan (JIRA)
theindigamer (JIRA User) This looks interesting, may I work on this? - if yes please do give me some pointer on where I can get started.
(I'm not sure if implementing this is a good idea right now but) The very high-level idea would be:
Figure out a place in the pipeline where the layouts are already computed. E.g. layout information is needed for LLVM IR, so this information should be available when the compiler mode corresponds to -emit-irgen
or later.
At this point, you need to somehow traverse the different nominal type declarations in the module, then I believe you'd need to do a mapping NominalTypeDecl -> Type -> SILType -> TypeInfo -> TypeLayoutEntry
. I believe the TypeLayoutEntry
values are the "final" form having all the details about layout, but not 100% sure about this.
You'll see some methods on TypeConverter
such as convertType
and methods on IRGenModule
such as getStorageType
, those seem to be relevant. You'll also see a TypeLayoutCache
which has methods doing the last part, mapping SILType
and TypeInfo
values to TypeLayoutEntry
} values.
That said, I'm not entirely sure what the cleanest way to get this information out would be.
cc aschwaighofer@apple.com (JIRA User) do you have suggestions here?
Comment by Rajagopalan Gangadharan (JIRA)
theindigamer (JIRA User) thank you for the info, looks a bit complicated for my current knowledge set I guess. Let me stick with few more starter bugs before doing this. Thank you and sorry!
No worries. 🙂 What I have written down could be potentially useful to someone else too in the future.
Additional Detail from JIRA
| | | |------------------|-----------------| |Votes | 1 | |Component/s | Compiler | |Labels | New Feature | |Assignee | None | |Priority | Medium | md5: 9ee01c76caeea20f34adfc65e4c6646bIssue Description:
https://eli.thegreenplace.net/2012/12/17/dumping-a-c-objects-memory-layout-with-clang
Having something similar for Swift would be helpful for people optimizing the code as well as people working on the later stages of the compiler.