|
1 | 1 | use std::collections::BTreeMap;
|
2 | 2 | use std::ffi::{CStr, CString};
|
3 | 3 | use std::fs::File;
|
4 |
| -use std::mem::ManuallyDrop; |
5 | 4 | use std::path::Path;
|
6 | 5 | use std::sync::Arc;
|
7 | 6 | use std::{io, iter, slice};
|
8 | 7 |
|
9 | 8 | use object::read::archive::ArchiveFile;
|
10 | 9 | use rustc_codegen_ssa::back::lto::{LtoModuleCodegen, SerializedModule, ThinModule, ThinShared};
|
11 | 10 | use rustc_codegen_ssa::back::symbol_export;
|
12 |
| -use rustc_codegen_ssa::back::write::{CodegenContext, FatLtoInput, TargetMachineFactoryConfig}; |
| 11 | +use rustc_codegen_ssa::back::write::{CodegenContext, FatLtoInput}; |
13 | 12 | use rustc_codegen_ssa::traits::*;
|
14 | 13 | use rustc_codegen_ssa::{ModuleCodegen, ModuleKind, looks_like_rust_object_file};
|
15 | 14 | use rustc_data_structures::fx::FxHashMap;
|
@@ -699,18 +698,15 @@ pub(crate) unsafe fn optimize_thin_module(
|
699 | 698 | let dcx = dcx.handle();
|
700 | 699 |
|
701 | 700 | let module_name = &thin_module.shared.module_names[thin_module.idx];
|
702 |
| - let tm_factory_config = TargetMachineFactoryConfig::new(cgcx, module_name.to_str().unwrap()); |
703 |
| - let tm = (cgcx.tm_factory)(tm_factory_config).map_err(|e| write::llvm_err(dcx, e))?; |
704 | 701 |
|
705 | 702 | // Right now the implementation we've got only works over serialized
|
706 | 703 | // modules, so we create a fresh new LLVM context and parse the module
|
707 | 704 | // into that context. One day, however, we may do this for upstream
|
708 | 705 | // crates but for locally codegened modules we may be able to reuse
|
709 | 706 | // that LLVM Context and Module.
|
710 |
| - let llcx = unsafe { llvm::LLVMRustContextCreate(cgcx.fewer_names) }; |
711 |
| - let llmod_raw = parse_module(llcx, module_name, thin_module.data(), dcx)? as *const _; |
| 707 | + let module_llvm = ModuleLlvm::parse(cgcx, module_name, thin_module.data(), dcx)?; |
712 | 708 | let mut module = ModuleCodegen {
|
713 |
| - module_llvm: ModuleLlvm { llmod_raw, llcx, tm: ManuallyDrop::new(tm) }, |
| 709 | + module_llvm, |
714 | 710 | name: thin_module.name().to_string(),
|
715 | 711 | kind: ModuleKind::Regular,
|
716 | 712 | };
|
|
0 commit comments