Skip to content

Commit 91f824b

Browse files
authored
Unrolled build for rust-lang#133752
Rollup merge of rust-lang#133752 - klensy:cp, r=davidtwco replace copypasted ModuleLlvm::parse replaced code same as in https://github.com/rust-lang/rust/blob/bd36e69d2533ee750e2d805915b8ca88d2825e0f/compiler/rustc_codegen_llvm/src/lib.rs#L426-L445 except before error message was emitted via `write::llvm_err`, which returned other error kind, but it still ok?
2 parents 2ae9916 + 694950d commit 91f824b

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;
@@ -706,18 +705,15 @@ pub(crate) unsafe fn optimize_thin_module(
706705
let dcx = dcx.handle();
707706

708707
let module_name = &thin_module.shared.module_names[thin_module.idx];
709-
let tm_factory_config = TargetMachineFactoryConfig::new(cgcx, module_name.to_str().unwrap());
710-
let tm = (cgcx.tm_factory)(tm_factory_config).map_err(|e| write::llvm_err(dcx, e))?;
711708

712709
// Right now the implementation we've got only works over serialized
713710
// modules, so we create a fresh new LLVM context and parse the module
714711
// into that context. One day, however, we may do this for upstream
715712
// crates but for locally codegened modules we may be able to reuse
716713
// that LLVM Context and Module.
717-
let llcx = unsafe { llvm::LLVMRustContextCreate(cgcx.fewer_names) };
718-
let llmod_raw = parse_module(llcx, module_name, thin_module.data(), dcx)? as *const _;
714+
let module_llvm = ModuleLlvm::parse(cgcx, module_name, thin_module.data(), dcx)?;
719715
let mut module = ModuleCodegen {
720-
module_llvm: ModuleLlvm { llmod_raw, llcx, tm: ManuallyDrop::new(tm) },
716+
module_llvm,
721717
name: thin_module.name().to_string(),
722718
kind: ModuleKind::Regular,
723719
};

0 commit comments

Comments
 (0)