diff options
| author | Aman Arora <me@aman-arora.com> | 2020-09-03 22:46:56 -0400 |
|---|---|---|
| committer | Joshua Nelson <joshua@yottadb.com> | 2020-09-07 10:07:40 -0400 |
| commit | 444512da34f5162f1d55085d70b2d5ed7a753f79 (patch) | |
| tree | b89b2d828a8ee84ce10173dc0a54c8a8c4ecefde /src/doc/rustc-dev-guide | |
| parent | 1bb94b708e325d665f6ac5517e4f5b504e1b1f73 (diff) | |
| download | rust-444512da34f5162f1d55085d70b2d5ed7a753f79.tar.gz rust-444512da34f5162f1d55085d70b2d5ed7a753f79.zip | |
Document CGU partioning in case of generic and inline functions
Diffstat (limited to 'src/doc/rustc-dev-guide')
| -rw-r--r-- | src/doc/rustc-dev-guide/src/backend/monomorph.md | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/doc/rustc-dev-guide/src/backend/monomorph.md b/src/doc/rustc-dev-guide/src/backend/monomorph.md index 47b41d4f6c9..e678b4f76c0 100644 --- a/src/doc/rustc-dev-guide/src/backend/monomorph.md +++ b/src/doc/rustc-dev-guide/src/backend/monomorph.md @@ -55,8 +55,28 @@ The monomorphization collector is run just before MIR lowering and codegen. collection and then partitions them into [codegen units](../appendix/glossary.md#codegen-unit). +## Codegen Unit (CGU) partitioning + +For better incremental build times, the CGU partitioner creates two CGU for each source level +modules. One is for "stable" i.e. non-generic code and the other is more volatile code i.e. +monoporphized/specialized instances. + +For depenencies, consider Crate A and Crate B, such that Crate B depends on Crate A. +The following table lists different scenarios for a function in Crate A that might be used by one +or more modules in Crate B. + +| Crate A function | Behavior | +| - | - | +| Non-generic function | Crate A function doesn't appear in any codegen units of Crate B | +| Non-generic `#[inline]` function | Crate A function appears with in a single CGU of Crate B, and exists even after post-inlining stage| +| Generic function | Regardless of inlining, all monoporphized (specialized) functions <br> from Crate A appear within a single codegen unit for Crate B. <br> The codegen unit exists even after the post inlining stage.| +| Generic `#[inline]` function | - same - | + +For more details about the partitioner read the module level [documentation]. + [mono]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir/monomorphize/partitioning/fn.collect_and_partition_mono_items.html [codegen1]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_codegen_ssa/base/fn.codegen_crate.html +[documentation]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir/monomorphize/partitioning/index.html ## Polymorphization |
