-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DebugInfo][Split DWARF][LTO]: Ensure only a single CU is emitted
Split DWARF doesn't handle LTO of any form (roughly there's an assumption that each dwo file will have one CU - it's not explicitly documented, nor explicitly handled, so the ecosystem isn't really well understood/tested/etc). This had previously been handled by implementing (& disabling by default) the `-split-dwarf-cross-cu-references` flag, which would disable use of ref_addr across two dwo CUs. This worked for a while, at least in LTO (it didn't address Split DWARF+Full LTO, but that's an unlikely combination, as the benefits of Split DWARF are more limited in a full LTO build) - because the only source of cross-CU references was inlined functions, so by making those non-cross-CU (by moving the referenced inlined function DWARF description into the referencing CU) the result was one CU per dwo. But recently the Function Specialization pass was added to the ThinLTO pipeline, which caused imported functions that may not be inlined to be emitted by a backend compile. This meant foreign CU entities (not just abstract origins/cross-CU referenced entities)/standalone foreign CUs could be emitted by a backend compile. The end result was, due to a bug* in binutils dwp (I think basically it saw two CUs in a single dwo and reprocessed the offsets in the shared debug_str_offsets.dwo section) this situation lead to corrupted strings. So to make this more robust, I've generalized the definition of the `-split-dwarf-cross-cu-references` flag (perhaps it should be renamed at this point, but it's /really/ niche, doubt anyone's using it - more or less there for experimentation when we get around to figuring out spec'ing LTO+Split DWARF) to mean "single CU in a dwo file" and added more general handling for this. There's certainly some weird corner cases that could come up in terms of "how do we choose which CU to put everything in" - for now it's "first come, first served" which is probably going to be OK for ThinLTO - the base module will have the first functions and first CU, imported fragments will come after that. For LTO the choice will be fairly arbitrary - but, again, essentially whichever module comes first. * Arguably a bug in binutils dwp, but since the feature isn't well specified, I'd rather avoid dabbling in this uncertain area and ensure LLVM doesn't produce especially novel DWARF (dwos with multiple CUs) regardless of whether binutils dwp would/should be fixed. I'm not confident debuggers could read such a dwo file well, etc.
- Loading branch information
Showing
5 changed files
with
48 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters