From 7c6ea65c925baa3a0632fe02a2ee0659271ea6cb Mon Sep 17 00:00:00 2001 From: klensy Date: Wed, 3 Jul 2024 16:59:43 +0300 Subject: [PATCH] rustc_codegen_llvm: less pubs --- compiler/rustc_codegen_llvm/src/abi.rs | 6 ++--- compiler/rustc_codegen_llvm/src/attributes.rs | 2 +- compiler/rustc_codegen_llvm/src/common.rs | 2 +- .../rustc_codegen_llvm/src/debuginfo/mod.rs | 4 ++-- compiler/rustc_codegen_llvm/src/lib.rs | 2 +- .../rustc_codegen_llvm/src/llvm/diagnostic.rs | 4 ++-- compiler/rustc_codegen_llvm/src/llvm/ffi.rs | 23 +++++++++++++++---- compiler/rustc_codegen_llvm/src/llvm/mod.rs | 12 ++++------ compiler/rustc_codegen_llvm/src/type_.rs | 2 +- compiler/rustc_codegen_llvm/src/value.rs | 2 +- 10 files changed, 35 insertions(+), 24 deletions(-) diff --git a/compiler/rustc_codegen_llvm/src/abi.rs b/compiler/rustc_codegen_llvm/src/abi.rs index a6a3f0f964611..aa91d4ce05fcb 100644 --- a/compiler/rustc_codegen_llvm/src/abi.rs +++ b/compiler/rustc_codegen_llvm/src/abi.rs @@ -13,12 +13,12 @@ use rustc_codegen_ssa::traits::*; use rustc_codegen_ssa::MemFlags; use rustc_middle::bug; use rustc_middle::ty::layout::LayoutOf; -pub use rustc_middle::ty::layout::{FAT_PTR_ADDR, FAT_PTR_EXTRA}; +pub(crate) use rustc_middle::ty::layout::{FAT_PTR_ADDR, FAT_PTR_EXTRA}; use rustc_middle::ty::Ty; use rustc_session::config; -pub use rustc_target::abi::call::*; +pub(crate) use rustc_target::abi::call::*; use rustc_target::abi::{self, HasDataLayout, Int, Size}; -pub use rustc_target::spec::abi::Abi; +pub(crate) use rustc_target::spec::abi::Abi; use rustc_target::spec::SanitizerSet; use libc::c_uint; diff --git a/compiler/rustc_codegen_llvm/src/attributes.rs b/compiler/rustc_codegen_llvm/src/attributes.rs index cd82894af18eb..ed3b29e0f9192 100644 --- a/compiler/rustc_codegen_llvm/src/attributes.rs +++ b/compiler/rustc_codegen_llvm/src/attributes.rs @@ -15,7 +15,7 @@ use crate::errors::{MissingFeatures, SanitizerMemtagRequiresMte, TargetFeatureDi use crate::llvm::AttributePlace::Function; use crate::llvm::{self, AllocKindFlags, Attribute, AttributeKind, AttributePlace, MemoryEffects}; use crate::llvm_util; -pub use rustc_attr::{InlineAttr, InstructionSetAttr, OptimizeAttr}; +pub(crate) use rustc_attr::{InlineAttr, InstructionSetAttr, OptimizeAttr}; use crate::context::CodegenCx; use crate::value::Value; diff --git a/compiler/rustc_codegen_llvm/src/common.rs b/compiler/rustc_codegen_llvm/src/common.rs index d42c6ed827aec..27231eeea2b82 100644 --- a/compiler/rustc_codegen_llvm/src/common.rs +++ b/compiler/rustc_codegen_llvm/src/common.rs @@ -1,7 +1,7 @@ //! Code that is useful in various codegen modules. use crate::consts::const_alloc_to_llvm; -pub use crate::context::CodegenCx; +pub(crate) use crate::context::CodegenCx; use crate::llvm::{self, BasicBlock, Bool, ConstantInt, False, OperandBundleDef, True}; use crate::type_::Type; use crate::value::Value; diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/mod.rs b/compiler/rustc_codegen_llvm/src/debuginfo/mod.rs index 3486ce4becb46..887588cb4986f 100644 --- a/compiler/rustc_codegen_llvm/src/debuginfo/mod.rs +++ b/compiler/rustc_codegen_llvm/src/debuginfo/mod.rs @@ -50,8 +50,8 @@ pub mod metadata; mod namespace; mod utils; -pub use self::create_scope_map::compute_mir_scopes; -pub use self::metadata::build_global_var_di_node; +pub(crate) use self::create_scope_map::compute_mir_scopes; +pub(crate) use self::metadata::build_global_var_di_node; #[allow(non_upper_case_globals)] const DW_TAG_auto_variable: c_uint = 0x100; diff --git a/compiler/rustc_codegen_llvm/src/lib.rs b/compiler/rustc_codegen_llvm/src/lib.rs index ed0989a0ba413..ff7a85fc1285d 100644 --- a/compiler/rustc_codegen_llvm/src/lib.rs +++ b/compiler/rustc_codegen_llvm/src/lib.rs @@ -21,7 +21,7 @@ use back::owned_target_machine::OwnedTargetMachine; use back::write::{create_informational_target_machine, create_target_machine}; use errors::ParseTargetMachineConfig; -pub use llvm_util::target_features; +pub(crate) use llvm_util::target_features; use rustc_ast::expand::allocator::AllocatorKind; use rustc_codegen_ssa::back::lto::{LtoModuleCodegen, SerializedModule, ThinModule}; use rustc_codegen_ssa::back::write::{ diff --git a/compiler/rustc_codegen_llvm/src/llvm/diagnostic.rs b/compiler/rustc_codegen_llvm/src/llvm/diagnostic.rs index f9b28178ddb97..53fad5c217378 100644 --- a/compiler/rustc_codegen_llvm/src/llvm/diagnostic.rs +++ b/compiler/rustc_codegen_llvm/src/llvm/diagnostic.rs @@ -1,7 +1,7 @@ //! LLVM diagnostic reports. -pub use self::Diagnostic::*; -pub use self::OptimizationDiagnosticKind::*; +pub(crate) use self::Diagnostic::*; +pub(crate) use self::OptimizationDiagnosticKind::*; use crate::value::Value; use libc::c_uint; diff --git a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs index 132e1f9e8fd93..f2750a2bd592d 100644 --- a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs +++ b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs @@ -161,6 +161,7 @@ pub enum DLLStorageClass { #[derive(Copy, Clone, Debug)] pub enum AttributeKind { AlwaysInline = 0, + #[allow(dead_code)] ByVal = 1, Cold = 2, InlineHint = 3, @@ -176,7 +177,9 @@ pub enum AttributeKind { OptimizeForSize = 13, ReadOnly = 14, SExt = 15, + #[allow(dead_code)] StructRet = 16, + #[allow(dead_code)] UWTable = 17, ZExt = 18, InReg = 19, @@ -184,7 +187,9 @@ pub enum AttributeKind { SanitizeAddress = 21, SanitizeMemory = 22, NonLazyBind = 23, + #[allow(dead_code)] OptimizeNone = 24, + #[allow(dead_code)] ReadNone = 26, SanitizeHWAddress = 28, WillReturn = 29, @@ -195,6 +200,7 @@ pub enum AttributeKind { SanitizeMemTag = 34, NoCfCheck = 35, ShadowCallStack = 36, + #[allow(dead_code)] AllocSize = 37, AllocatedPointer = 38, AllocAlign = 39, @@ -289,6 +295,7 @@ impl RealPredicate { /// LLVMTypeKind #[derive(Copy, Clone, PartialEq, Debug)] #[repr(C)] +#[allow(dead_code)] pub enum TypeKind { Void = 0, Half = 1, @@ -418,16 +425,24 @@ pub enum FileType { #[derive(Copy, Clone)] #[repr(C)] pub enum MetadataType { + #[allow(dead_code)] MD_dbg = 0, + #[allow(dead_code)] MD_tbaa = 1, + #[allow(dead_code)] MD_prof = 2, + #[allow(dead_code)] MD_fpmath = 3, MD_range = 4, + #[allow(dead_code)] MD_tbaa_struct = 5, MD_invariant_load = 6, + #[allow(dead_code)] MD_alias_scope = 7, + #[allow(dead_code)] MD_noalias = 8, MD_nontemporal = 9, + #[allow(dead_code)] MD_mem_parallel_loop_access = 10, MD_nonnull = 11, MD_align = 17, @@ -598,6 +613,7 @@ pub enum ThreadLocalMode { /// LLVMRustTailCallKind #[derive(Copy, Clone)] #[repr(C)] +#[allow(dead_code)] pub enum TailCallKind { None, Tail, @@ -662,9 +678,6 @@ extern "C" { pub struct Builder<'a>(InvariantOpaque<'a>); #[repr(C)] pub struct PassManager<'a>(InvariantOpaque<'a>); -extern "C" { - pub type Pass; -} extern "C" { pub type TargetMachine; } @@ -696,7 +709,6 @@ extern "C" { } pub type DiagnosticHandlerTy = unsafe extern "C" fn(&DiagnosticInfo, *mut c_void); -pub type InlineAsmDiagHandlerTy = unsafe extern "C" fn(&SMDiagnostic, *const c_void, c_uint); pub mod debuginfo { use super::{InvariantOpaque, Metadata}; @@ -804,6 +816,7 @@ pub mod debuginfo { #[repr(C)] pub enum DebugNameTableKind { Default, + #[allow(dead_code)] Gnu, None, } @@ -1563,6 +1576,8 @@ extern "C" { Name: *const c_char, NameLen: size_t, ) -> Option<&Value>; + + #[allow(dead_code)] pub fn LLVMRustSetTailCallKind(CallInst: &Value, TKC: TailCallKind); // Operations on attributes diff --git a/compiler/rustc_codegen_llvm/src/llvm/mod.rs b/compiler/rustc_codegen_llvm/src/llvm/mod.rs index 6ab1eea959761..628d03adb37fd 100644 --- a/compiler/rustc_codegen_llvm/src/llvm/mod.rs +++ b/compiler/rustc_codegen_llvm/src/llvm/mod.rs @@ -1,12 +1,8 @@ #![allow(non_snake_case)] -pub use self::AtomicRmwBinOp::*; -pub use self::CallConv::*; -pub use self::CodeGenOptSize::*; -pub use self::IntPredicate::*; -pub use self::Linkage::*; -pub use self::MetadataType::*; -pub use self::RealPredicate::*; +pub(crate) use self::CallConv::*; +pub(crate) use self::CodeGenOptSize::*; +pub(crate) use self::MetadataType::*; use libc::c_uint; use rustc_data_structures::small_c_str::SmallCStr; @@ -21,7 +17,7 @@ pub mod archive_ro; pub mod diagnostic; mod ffi; -pub use self::ffi::*; +pub(crate) use self::ffi::*; impl LLVMRustResult { pub fn into_result(self) -> Result<(), ()> { diff --git a/compiler/rustc_codegen_llvm/src/type_.rs b/compiler/rustc_codegen_llvm/src/type_.rs index f1141c57cedd7..131a026e52c52 100644 --- a/compiler/rustc_codegen_llvm/src/type_.rs +++ b/compiler/rustc_codegen_llvm/src/type_.rs @@ -1,4 +1,4 @@ -pub use crate::llvm::Type; +pub(crate) use crate::llvm::Type; use crate::abi::{FnAbiLlvmExt, LlvmType}; use crate::common; diff --git a/compiler/rustc_codegen_llvm/src/value.rs b/compiler/rustc_codegen_llvm/src/value.rs index 1338a229566c8..26de430d8a43c 100644 --- a/compiler/rustc_codegen_llvm/src/value.rs +++ b/compiler/rustc_codegen_llvm/src/value.rs @@ -1,4 +1,4 @@ -pub use crate::llvm::Value; +pub(crate) use crate::llvm::Value; use crate::llvm;