Skip to content

Commit 694950d

Browse files
committed
replace copypasted ModuleLlvm::parse
1 parent caa8172 commit 694950d

File tree

1 file changed

+3
-7
lines changed
  • compiler/rustc_codegen_llvm/src/back

1 file changed

+3
-7
lines changed

compiler/rustc_codegen_llvm/src/back/lto.rs

+3-7
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
use std::collections::BTreeMap;
22
use std::ffi::{CStr, CString};
33
use std::fs::File;
4-
use std::mem::ManuallyDrop;
54
use std::path::Path;
65
use std::sync::Arc;
76
use std::{io, iter, slice};
87

98
use object::read::archive::ArchiveFile;
109
use rustc_codegen_ssa::back::lto::{LtoModuleCodegen, SerializedModule, ThinModule, ThinShared};
1110
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};
1312
use rustc_codegen_ssa::traits::*;
1413
use rustc_codegen_ssa::{ModuleCodegen, ModuleKind, looks_like_rust_object_file};
1514
use rustc_data_structures::fx::FxHashMap;
@@ -699,18 +698,15 @@ pub(crate) unsafe fn optimize_thin_module(
699698
let dcx = dcx.handle();
700699

701700
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))?;
704701

705702
// Right now the implementation we've got only works over serialized
706703
// modules, so we create a fresh new LLVM context and parse the module
707704
// into that context. One day, however, we may do this for upstream
708705
// crates but for locally codegened modules we may be able to reuse
709706
// 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)?;
712708
let mut module = ModuleCodegen {
713-
module_llvm: ModuleLlvm { llmod_raw, llcx, tm: ManuallyDrop::new(tm) },
709+
module_llvm,
714710
name: thin_module.name().to_string(),
715711
kind: ModuleKind::Regular,
716712
};

0 commit comments

Comments
 (0)