diff options
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/back')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/back/archive.rs | 22 | ||||
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/back/lto.rs | 33 | ||||
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/back/owned_target_machine.rs | 13 | ||||
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/back/profiling.rs | 6 | ||||
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/back/write.rs | 48 |
5 files changed, 57 insertions, 65 deletions
diff --git a/compiler/rustc_codegen_llvm/src/back/archive.rs b/compiler/rustc_codegen_llvm/src/back/archive.rs index f46c6b1c498..9a28428cb62 100644 --- a/compiler/rustc_codegen_llvm/src/back/archive.rs +++ b/compiler/rustc_codegen_llvm/src/back/archive.rs @@ -1,27 +1,23 @@ //! A helper class for dealing with static archives -use std::env; use std::ffi::{c_char, c_void, CStr, CString, OsString}; -use std::io; -use std::mem; use std::path::{Path, PathBuf}; -use std::ptr; -use std::str; +use std::{env, io, mem, ptr, str}; -use crate::common; -use crate::errors::{ - DlltoolFailImportLibrary, ErrorCallingDllTool, ErrorCreatingImportLibrary, ErrorWritingDEFFile, -}; -use crate::llvm::archive_ro::{ArchiveRO, Child}; -use crate::llvm::{self, ArchiveKind, LLVMMachineType, LLVMRustCOFFShortExport}; use rustc_codegen_ssa::back::archive::{ try_extract_macho_fat_archive, ArArchiveBuilder, ArchiveBuildFailure, ArchiveBuilder, ArchiveBuilderBuilder, ObjectReader, UnknownArchiveKind, DEFAULT_OBJECT_READER, }; -use tracing::trace; - use rustc_session::cstore::DllImport; use rustc_session::Session; +use tracing::trace; + +use crate::common; +use crate::errors::{ + DlltoolFailImportLibrary, ErrorCallingDllTool, ErrorCreatingImportLibrary, ErrorWritingDEFFile, +}; +use crate::llvm::archive_ro::{ArchiveRO, Child}; +use crate::llvm::{self, ArchiveKind, LLVMMachineType, LLVMRustCOFFShortExport}; /// Helper for adding many files to an archive. #[must_use = "must call build() to finish building the archive"] diff --git a/compiler/rustc_codegen_llvm/src/back/lto.rs b/compiler/rustc_codegen_llvm/src/back/lto.rs index aef672631c8..f68155f523a 100644 --- a/compiler/rustc_codegen_llvm/src/back/lto.rs +++ b/compiler/rustc_codegen_llvm/src/back/lto.rs @@ -1,11 +1,11 @@ -use crate::back::write::{ - self, bitcode_section_name, save_temp_bitcode, CodegenDiagnosticsStage, DiagnosticHandlers, -}; -use crate::errors::{ - DynamicLinkingWithLTO, LlvmError, LtoBitcodeFromRlib, LtoDisallowed, LtoDylib, LtoProcMacro, -}; -use crate::llvm::{self, build_string}; -use crate::{LlvmCodegenBackend, ModuleLlvm}; +use std::collections::BTreeMap; +use std::ffi::{CStr, CString}; +use std::fs::File; +use std::mem::ManuallyDrop; +use std::path::Path; +use std::sync::Arc; +use std::{io, iter, slice}; + use object::read::archive::ArchiveFile; use rustc_codegen_ssa::back::lto::{LtoModuleCodegen, SerializedModule, ThinModule, ThinShared}; use rustc_codegen_ssa::back::symbol_export; @@ -22,15 +22,14 @@ use rustc_middle::middle::exported_symbols::{SymbolExportInfo, SymbolExportLevel use rustc_session::config::{self, CrateType, Lto}; use tracing::{debug, info}; -use std::collections::BTreeMap; -use std::ffi::{CStr, CString}; -use std::fs::File; -use std::io; -use std::iter; -use std::mem::ManuallyDrop; -use std::path::Path; -use std::slice; -use std::sync::Arc; +use crate::back::write::{ + self, bitcode_section_name, save_temp_bitcode, CodegenDiagnosticsStage, DiagnosticHandlers, +}; +use crate::errors::{ + DynamicLinkingWithLTO, LlvmError, LtoBitcodeFromRlib, LtoDisallowed, LtoDylib, LtoProcMacro, +}; +use crate::llvm::{self, build_string}; +use crate::{LlvmCodegenBackend, ModuleLlvm}; /// We keep track of the computed LTO cache keys from the previous /// session to determine which CGUs we can reuse. diff --git a/compiler/rustc_codegen_llvm/src/back/owned_target_machine.rs b/compiler/rustc_codegen_llvm/src/back/owned_target_machine.rs index b72636a6224..681ac75c877 100644 --- a/compiler/rustc_codegen_llvm/src/back/owned_target_machine.rs +++ b/compiler/rustc_codegen_llvm/src/back/owned_target_machine.rs @@ -1,13 +1,12 @@ -use std::{ - ffi::{c_char, CStr}, - marker::PhantomData, - ops::Deref, - ptr::NonNull, -}; +use std::ffi::{c_char, CStr}; +use std::marker::PhantomData; +use std::ops::Deref; +use std::ptr::NonNull; use rustc_data_structures::small_c_str::SmallCStr; -use crate::{errors::LlvmError, llvm}; +use crate::errors::LlvmError; +use crate::llvm; /// Responsible for safely creating and disposing llvm::TargetMachine via ffi functions. /// Not cloneable as there is no clone function for llvm::TargetMachine. diff --git a/compiler/rustc_codegen_llvm/src/back/profiling.rs b/compiler/rustc_codegen_llvm/src/back/profiling.rs index 2eee9f8c5a3..26fb4a96f84 100644 --- a/compiler/rustc_codegen_llvm/src/back/profiling.rs +++ b/compiler/rustc_codegen_llvm/src/back/profiling.rs @@ -1,9 +1,11 @@ -use measureme::{event_id::SEPARATOR_BYTE, EventId, StringComponent, StringId}; -use rustc_data_structures::profiling::{SelfProfiler, TimingGuard}; use std::ffi::{c_void, CStr}; use std::os::raw::c_char; use std::sync::Arc; +use measureme::event_id::SEPARATOR_BYTE; +use measureme::{EventId, StringComponent, StringId}; +use rustc_data_structures::profiling::{SelfProfiler, TimingGuard}; + fn llvm_args_to_string_id(profiler: &SelfProfiler, pass_name: &str, ir_name: &str) -> EventId { let pass_name = profiler.get_or_alloc_cached_string(pass_name); let mut components = vec![StringComponent::Ref(pass_name)]; diff --git a/compiler/rustc_codegen_llvm/src/back/write.rs b/compiler/rustc_codegen_llvm/src/back/write.rs index ddd52e80edf..5a7909d1511 100644 --- a/compiler/rustc_codegen_llvm/src/back/write.rs +++ b/compiler/rustc_codegen_llvm/src/back/write.rs @@ -1,19 +1,10 @@ -use crate::back::lto::ThinBuffer; -use crate::back::owned_target_machine::OwnedTargetMachine; -use crate::back::profiling::{ - selfprofile_after_pass_callback, selfprofile_before_pass_callback, LlvmSelfProfiler, -}; -use crate::base; -use crate::common; -use crate::errors::{ - CopyBitcode, FromLlvmDiag, FromLlvmOptimizationDiag, LlvmError, UnknownCompression, - WithLlvmError, WriteBytecode, -}; -use crate::llvm::{self, DiagnosticInfo, PassManager}; -use crate::llvm_util; -use crate::type_::Type; -use crate::LlvmCodegenBackend; -use crate::ModuleLlvm; +use std::ffi::CString; +use std::io::{self, Write}; +use std::path::{Path, PathBuf}; +use std::sync::Arc; +use std::{fs, slice, str}; + +use libc::{c_char, c_int, c_void, size_t}; use llvm::{ LLVMRustLLVMHasZlibCompressionForDebugSymbols, LLVMRustLLVMHasZstdCompressionForDebugSymbols, }; @@ -29,23 +20,28 @@ use rustc_data_structures::small_c_str::SmallCStr; use rustc_errors::{DiagCtxtHandle, FatalError, Level}; use rustc_fs_util::{link_or_copy, path_to_c_string}; use rustc_middle::ty::TyCtxt; -use rustc_session::config::{self, Lto, OutputType, Passes}; -use rustc_session::config::{RemapPathScopeComponents, SplitDwarfKind, SwitchWithOptPath}; +use rustc_session::config::{ + self, Lto, OutputType, Passes, RemapPathScopeComponents, SplitDwarfKind, SwitchWithOptPath, +}; use rustc_session::Session; use rustc_span::symbol::sym; use rustc_span::InnerSpan; use rustc_target::spec::{CodeModel, RelocModel, SanitizerSet, SplitDebuginfo, TlsModel}; use tracing::debug; +use crate::back::lto::ThinBuffer; +use crate::back::owned_target_machine::OwnedTargetMachine; +use crate::back::profiling::{ + selfprofile_after_pass_callback, selfprofile_before_pass_callback, LlvmSelfProfiler, +}; +use crate::errors::{ + CopyBitcode, FromLlvmDiag, FromLlvmOptimizationDiag, LlvmError, UnknownCompression, + WithLlvmError, WriteBytecode, +}; use crate::llvm::diagnostic::OptimizationDiagnosticKind; -use libc::{c_char, c_int, c_void, size_t}; -use std::ffi::CString; -use std::fs; -use std::io::{self, Write}; -use std::path::{Path, PathBuf}; -use std::slice; -use std::str; -use std::sync::Arc; +use crate::llvm::{self, DiagnosticInfo, PassManager}; +use crate::type_::Type; +use crate::{base, common, llvm_util, LlvmCodegenBackend, ModuleLlvm}; pub fn llvm_err<'a>(dcx: DiagCtxtHandle<'_>, err: LlvmError<'a>) -> FatalError { match llvm::last_error() { |
