1 use crate::back::lto::{LtoModuleCodegen, SerializedModule, ThinModule};
2 use crate::back::write::{CodegenContext, ModuleConfig};
3 use crate::{CompiledModule, ModuleCodegen};
5 use rustc::dep_graph::WorkProduct;
6 use rustc::util::time_graph::Timeline;
7 use rustc_errors::{FatalError, Handler};
9 pub trait WriteBackendMethods: 'static + Sized + Clone {
10 type Module: Send + Sync;
12 type ModuleBuffer: ModuleBufferMethods;
14 type ThinData: Send + Sync;
15 type ThinBuffer: ThinBufferMethods;
17 /// Performs fat LTO by merging all modules into a single one and returning it
18 /// for further optimization.
20 cgcx: &CodegenContext<Self>,
21 modules: Vec<ModuleCodegen<Self::Module>>,
22 timeline: &mut Timeline,
23 ) -> Result<LtoModuleCodegen<Self>, FatalError>;
24 /// Performs thin LTO by performing necessary global analysis and returning two
25 /// lists, one of the modules that need optimization and another for modules that
26 /// can simply be copied over from the incr. comp. cache.
28 cgcx: &CodegenContext<Self>,
29 modules: Vec<(String, Self::ThinBuffer)>,
30 cached_modules: Vec<(SerializedModule<Self::ModuleBuffer>, WorkProduct)>,
31 timeline: &mut Timeline,
32 ) -> Result<(Vec<LtoModuleCodegen<Self>>, Vec<WorkProduct>), FatalError>;
33 fn print_pass_timings(&self);
35 cgcx: &CodegenContext<Self>,
36 diag_handler: &Handler,
37 module: &ModuleCodegen<Self::Module>,
38 config: &ModuleConfig,
39 timeline: &mut Timeline,
40 ) -> Result<(), FatalError>;
41 unsafe fn optimize_thin(
42 cgcx: &CodegenContext<Self>,
43 thin: &mut ThinModule<Self>,
44 timeline: &mut Timeline,
45 ) -> Result<ModuleCodegen<Self::Module>, FatalError>;
47 cgcx: &CodegenContext<Self>,
48 diag_handler: &Handler,
49 module: ModuleCodegen<Self::Module>,
50 config: &ModuleConfig,
51 timeline: &mut Timeline,
52 ) -> Result<CompiledModule, FatalError>;
54 cgcx: &CodegenContext<Self>,
55 module: ModuleCodegen<Self::Module>
56 ) -> (String, Self::ThinBuffer);
57 fn run_lto_pass_manager(
58 cgcx: &CodegenContext<Self>,
59 llmod: &ModuleCodegen<Self::Module>,
60 config: &ModuleConfig,
65 pub trait ThinBufferMethods: Send + Sync {
66 fn data(&self) -> &[u8];
69 pub trait ModuleBufferMethods: Send + Sync {
70 fn data(&self) -> &[u8];