|
53 | 53 | //! - One for "stable", that is non-generic, code
|
54 | 54 | //! - One for more "volatile" code, i.e. monomorphized instances of functions
|
55 | 55 | //! defined in that module
|
56 |
| -//! - Code for monomorphized instances of functions from external crates gets |
57 |
| -//! placed into every codegen unit that uses that instance. |
58 | 56 | //!
|
59 | 57 | //! In order to see why this heuristic makes sense, let's take a look at when a
|
60 | 58 | //! codegen unit can get invalidated:
|
|
82 | 80 | //! side-effect of references a little by at least not touching the non-generic
|
83 | 81 | //! code of the module.
|
84 | 82 | //!
|
85 |
| -//! As another optimization, monomorphized functions from external crates get |
86 |
| -//! some special handling. Since we assume that the definition of such a |
87 |
| -//! function changes rather infrequently compared to local items, we can just |
88 |
| -//! instantiate external functions in every codegen unit where it is referenced |
89 |
| -//! -- without having to fear that doing this will cause a lot of unnecessary |
90 |
| -//! re-compilations. If such a reference is added or removed, the codegen unit |
91 |
| -//! has to be re-translated anyway. |
92 |
| -//! (Note that this only makes sense if external crates actually don't change |
93 |
| -//! frequently. For certain multi-crate projects this might not be a valid |
94 |
| -//! assumption). |
95 |
| -//! |
96 | 83 | //! A Note on Inlining
|
97 | 84 | //! ------------------
|
98 | 85 | //! As briefly mentioned above, in order for LLVM to be able to inline a
|
|
107 | 94 | //! inlined, so it can distribute function instantiations accordingly. Since
|
108 | 95 | //! there is no way of knowing for sure which functions LLVM will decide to
|
109 | 96 | //! inline in the end, we apply a heuristic here: Only functions marked with
|
110 |
| -//! #[inline] and (as stated above) functions from external crates are |
111 |
| -//! considered for inlining by the partitioner. The current implementation |
112 |
| -//! will not try to determine if a function is likely to be inlined by looking |
113 |
| -//! at the functions definition. |
| 97 | +//! #[inline] are considered for inlining by the partitioner. The current |
| 98 | +//! implementation will not try to determine if a function is likely to be |
| 99 | +//! inlined by looking at the functions definition. |
114 | 100 | //!
|
115 | 101 | //! Note though that as a side-effect of creating a codegen units per
|
116 | 102 | //! source-level module, functions from the same module will be available for
|
|
0 commit comments