Rollup merge of #147322 - Zalathar:llvm-imports, r=jdonszelmann

cg_llvm: Consistently import `llvm::Type` and `llvm::Value`

We already have other modules that import these types and other types from `llvm`, so having the re-exports `type_::Type` and `value::Value` just distracts rust-analyzer and results in messier and less-consistent imports.

No functional change.
This commit is contained in:
Matthias Krüger
2025-10-07 19:39:07 +02:00
committed by GitHub
20 changed files with 28 additions and 52 deletions

View File

@@ -22,11 +22,9 @@ use smallvec::SmallVec;
use crate::attributes::{self, llfn_attrs_from_instance}; use crate::attributes::{self, llfn_attrs_from_instance};
use crate::builder::Builder; use crate::builder::Builder;
use crate::context::CodegenCx; use crate::context::CodegenCx;
use crate::llvm::{self, Attribute, AttributePlace}; use crate::llvm::{self, Attribute, AttributePlace, Type, Value};
use crate::llvm_util; use crate::llvm_util;
use crate::type_::Type;
use crate::type_of::LayoutLlvmExt; use crate::type_of::LayoutLlvmExt;
use crate::value::Value;
trait ArgAttributesExt { trait ArgAttributesExt {
fn apply_attrs_to_llfn(&self, idx: AttributePlace, cx: &CodegenCx<'_, '_>, llfn: &Value); fn apply_attrs_to_llfn(&self, idx: AttributePlace, cx: &CodegenCx<'_, '_>, llfn: &Value);

View File

@@ -13,14 +13,12 @@ use rustc_target::asm::*;
use smallvec::SmallVec; use smallvec::SmallVec;
use tracing::debug; use tracing::debug;
use crate::attributes;
use crate::builder::Builder; use crate::builder::Builder;
use crate::common::Funclet; use crate::common::Funclet;
use crate::context::CodegenCx; use crate::context::CodegenCx;
use crate::llvm::ToLlvmBool; use crate::llvm::{self, ToLlvmBool, Type, Value};
use crate::type_::Type;
use crate::type_of::LayoutLlvmExt; use crate::type_of::LayoutLlvmExt;
use crate::value::Value;
use crate::{attributes, llvm};
impl<'ll, 'tcx> AsmBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> { impl<'ll, 'tcx> AsmBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> {
fn codegen_inline_asm( fn codegen_inline_asm(

View File

@@ -13,8 +13,9 @@ use smallvec::SmallVec;
use crate::context::SimpleCx; use crate::context::SimpleCx;
use crate::errors::SanitizerMemtagRequiresMte; use crate::errors::SanitizerMemtagRequiresMte;
use crate::llvm::AttributePlace::Function; use crate::llvm::AttributePlace::Function;
use crate::llvm::{self, AllocKindFlags, Attribute, AttributeKind, AttributePlace, MemoryEffects}; use crate::llvm::{
use crate::value::Value; self, AllocKindFlags, Attribute, AttributeKind, AttributePlace, MemoryEffects, Value,
};
use crate::{Session, attributes, llvm_util}; use crate::{Session, attributes, llvm_util};
pub(crate) fn apply_to_llfn(llfn: &Value, idx: AttributePlace, attrs: &[&Attribute]) { pub(crate) fn apply_to_llfn(llfn: &Value, idx: AttributePlace, attrs: &[&Attribute]) {

View File

@@ -28,10 +28,10 @@ use rustc_span::Symbol;
use rustc_target::spec::SanitizerSet; use rustc_target::spec::SanitizerSet;
use super::ModuleLlvm; use super::ModuleLlvm;
use crate::attributes;
use crate::builder::Builder; use crate::builder::Builder;
use crate::context::CodegenCx; use crate::context::CodegenCx;
use crate::value::Value; use crate::llvm::{self, Value};
use crate::{attributes, llvm};
pub(crate) struct ValueIter<'ll> { pub(crate) struct ValueIter<'ll> {
cur: Option<&'ll Value>, cur: Option<&'ll Value>,

View File

@@ -37,11 +37,9 @@ use crate::common::Funclet;
use crate::context::{CodegenCx, FullCx, GenericCx, SCx}; use crate::context::{CodegenCx, FullCx, GenericCx, SCx};
use crate::llvm::{ use crate::llvm::{
self, AtomicOrdering, AtomicRmwBinOp, BasicBlock, FromGeneric, GEPNoWrapFlags, Metadata, TRUE, self, AtomicOrdering, AtomicRmwBinOp, BasicBlock, FromGeneric, GEPNoWrapFlags, Metadata, TRUE,
ToLlvmBool, ToLlvmBool, Type, Value,
}; };
use crate::type_::Type;
use crate::type_of::LayoutLlvmExt; use crate::type_of::LayoutLlvmExt;
use crate::value::Value;
#[must_use] #[must_use]
pub(crate) struct GenericBuilder<'a, 'll, CX: Borrow<SCx<'ll>>> { pub(crate) struct GenericBuilder<'a, 'll, CX: Borrow<SCx<'ll>>> {

View File

@@ -12,9 +12,7 @@ use tracing::debug;
use crate::builder::{Builder, PlaceRef, UNNAMED}; use crate::builder::{Builder, PlaceRef, UNNAMED};
use crate::context::SimpleCx; use crate::context::SimpleCx;
use crate::declare::declare_simple_fn; use crate::declare::declare_simple_fn;
use crate::llvm; use crate::llvm::{self, Metadata, TRUE, Type, Value};
use crate::llvm::{Metadata, TRUE, Type};
use crate::value::Value;
pub(crate) fn adjust_activity_to_abi<'tcx>( pub(crate) fn adjust_activity_to_abi<'tcx>(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,

View File

@@ -10,8 +10,7 @@ use rustc_middle::ty::{self, Instance, TypeVisitableExt};
use tracing::debug; use tracing::debug;
use crate::context::CodegenCx; use crate::context::CodegenCx;
use crate::llvm; use crate::llvm::{self, Value};
use crate::value::Value;
/// Codegens a reference to a fn/method item, monomorphizing and /// Codegens a reference to a fn/method item, monomorphizing and
/// inlining as it goes. /// inlining as it goes.

View File

@@ -20,9 +20,7 @@ use tracing::debug;
use crate::consts::const_alloc_to_llvm; use crate::consts::const_alloc_to_llvm;
pub(crate) use crate::context::CodegenCx; pub(crate) use crate::context::CodegenCx;
use crate::context::{GenericCx, SCx}; use crate::context::{GenericCx, SCx};
use crate::llvm::{self, BasicBlock, ConstantInt, FALSE, Metadata, TRUE, ToLlvmBool}; use crate::llvm::{self, BasicBlock, ConstantInt, FALSE, Metadata, TRUE, ToLlvmBool, Type, Value};
use crate::type_::Type;
use crate::value::Value;
/* /*
* A note on nomenclature of linking: "extern", "foreign", and "upcall". * A note on nomenclature of linking: "extern", "foreign", and "upcall".

View File

@@ -21,10 +21,9 @@ use tracing::{debug, instrument, trace};
use crate::common::CodegenCx; use crate::common::CodegenCx;
use crate::errors::SymbolAlreadyDefined; use crate::errors::SymbolAlreadyDefined;
use crate::type_::Type; use crate::llvm::{self, Type, Value};
use crate::type_of::LayoutLlvmExt; use crate::type_of::LayoutLlvmExt;
use crate::value::Value; use crate::{base, debuginfo};
use crate::{base, debuginfo, llvm};
pub(crate) fn const_alloc_to_llvm<'ll>( pub(crate) fn const_alloc_to_llvm<'ll>(
cx: &CodegenCx<'ll, '_>, cx: &CodegenCx<'ll, '_>,

View File

@@ -35,10 +35,8 @@ use crate::abi::to_llvm_calling_convention;
use crate::back::write::to_llvm_code_model; use crate::back::write::to_llvm_code_model;
use crate::callee::get_fn; use crate::callee::get_fn;
use crate::debuginfo::metadata::apply_vcall_visibility_metadata; use crate::debuginfo::metadata::apply_vcall_visibility_metadata;
use crate::llvm::{Metadata, MetadataKindId, Module}; use crate::llvm::{self, Metadata, MetadataKindId, Module, Type, Value};
use crate::type_::Type; use crate::{attributes, common, coverageinfo, debuginfo, llvm_util};
use crate::value::Value;
use crate::{attributes, common, coverageinfo, debuginfo, llvm, llvm_util};
/// `TyCtxt` (and related cache datastructures) can't be move between threads. /// `TyCtxt` (and related cache datastructures) can't be move between threads.
/// However, there are various cx related functions which we want to be available to the builder and /// However, there are various cx related functions which we want to be available to the builder and

View File

@@ -9,8 +9,7 @@ use rustc_session::config::{CrateType, DebugInfo};
use crate::builder::Builder; use crate::builder::Builder;
use crate::common::CodegenCx; use crate::common::CodegenCx;
use crate::llvm; use crate::llvm::{self, Value};
use crate::value::Value;
/// Inserts a side-effect free instruction sequence that makes sure that the /// Inserts a side-effect free instruction sequence that makes sure that the
/// .debug_gdb_scripts global is referenced, so it isn't removed by the linker. /// .debug_gdb_scripts global is referenced, so it isn't removed by the linker.

View File

@@ -41,8 +41,7 @@ use crate::llvm::debuginfo::{
DIBasicType, DIBuilder, DICompositeType, DIDescriptor, DIFile, DIFlags, DILexicalBlock, DIBasicType, DIBuilder, DICompositeType, DIDescriptor, DIFile, DIFlags, DILexicalBlock,
DIScope, DIType, DebugEmissionKind, DebugNameTableKind, DIScope, DIType, DebugEmissionKind, DebugNameTableKind,
}; };
use crate::llvm::{self, FromGeneric}; use crate::llvm::{self, FromGeneric, Value};
use crate::value::Value;
impl PartialEq for llvm::Metadata { impl PartialEq for llvm::Metadata {
fn eq(&self, other: &Self) -> bool { fn eq(&self, other: &Self) -> bool {

View File

@@ -35,12 +35,11 @@ use self::namespace::mangled_name_of_instance;
use self::utils::{DIB, create_DIArray, is_node_local_to_unit}; use self::utils::{DIB, create_DIArray, is_node_local_to_unit};
use crate::builder::Builder; use crate::builder::Builder;
use crate::common::{AsCCharPtr, CodegenCx}; use crate::common::{AsCCharPtr, CodegenCx};
use crate::llvm;
use crate::llvm::debuginfo::{ use crate::llvm::debuginfo::{
DIArray, DIBuilderBox, DIFile, DIFlags, DILexicalBlock, DILocation, DISPFlags, DIScope, DIArray, DIBuilderBox, DIFile, DIFlags, DILexicalBlock, DILocation, DISPFlags, DIScope,
DITemplateTypeParameter, DIType, DIVariable, DITemplateTypeParameter, DIType, DIVariable,
}; };
use crate::value::Value; use crate::llvm::{self, Value};
mod create_scope_map; mod create_scope_map;
mod dwarf_const; mod dwarf_const;

View File

@@ -23,13 +23,11 @@ use smallvec::SmallVec;
use tracing::debug; use tracing::debug;
use crate::abi::FnAbiLlvmExt; use crate::abi::FnAbiLlvmExt;
use crate::attributes;
use crate::common::AsCCharPtr; use crate::common::AsCCharPtr;
use crate::context::{CodegenCx, GenericCx, SCx, SimpleCx}; use crate::context::{CodegenCx, GenericCx, SCx, SimpleCx};
use crate::llvm::AttributePlace::Function; use crate::llvm::AttributePlace::Function;
use crate::llvm::{FromGeneric, Visibility}; use crate::llvm::{self, FromGeneric, Type, Value, Visibility};
use crate::type_::Type;
use crate::value::Value;
use crate::{attributes, llvm};
/// Declare a function with a SimpleCx. /// Declare a function with a SimpleCx.
/// ///

View File

@@ -25,11 +25,9 @@ use crate::builder::Builder;
use crate::builder::autodiff::{adjust_activity_to_abi, generate_enzyme_call}; use crate::builder::autodiff::{adjust_activity_to_abi, generate_enzyme_call};
use crate::context::CodegenCx; use crate::context::CodegenCx;
use crate::errors::AutoDiffWithoutEnable; use crate::errors::AutoDiffWithoutEnable;
use crate::llvm::{self, Metadata}; use crate::llvm::{self, Metadata, Type, Value};
use crate::type_::Type;
use crate::type_of::LayoutLlvmExt; use crate::type_of::LayoutLlvmExt;
use crate::va_arg::emit_va_arg; use crate::va_arg::emit_va_arg;
use crate::value::Value;
fn call_simple_intrinsic<'ll, 'tcx>( fn call_simple_intrinsic<'ll, 'tcx>(
bx: &mut Builder<'_, 'll, 'tcx>, bx: &mut Builder<'_, 'll, 'tcx>,

View File

@@ -6,7 +6,7 @@ use rustc_span::InnerSpan;
pub(crate) use self::Diagnostic::*; pub(crate) use self::Diagnostic::*;
use self::OptimizationDiagnosticKind::*; use self::OptimizationDiagnosticKind::*;
use super::{DiagnosticInfo, SMDiagnostic}; use super::{DiagnosticInfo, SMDiagnostic};
use crate::value::Value; use crate::llvm::Value;
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone, Debug)]
pub(crate) enum OptimizationDiagnosticKind { pub(crate) enum OptimizationDiagnosticKind {

View File

@@ -13,12 +13,10 @@ use rustc_middle::ty::{self, Ty};
use rustc_target::callconv::{CastTarget, FnAbi}; use rustc_target::callconv::{CastTarget, FnAbi};
use crate::abi::{FnAbiLlvmExt, LlvmType}; use crate::abi::{FnAbiLlvmExt, LlvmType};
use crate::common;
use crate::context::{CodegenCx, GenericCx, SCx}; use crate::context::{CodegenCx, GenericCx, SCx};
pub(crate) use crate::llvm::Type; use crate::llvm::{self, FALSE, Metadata, TRUE, ToLlvmBool, Type, Value};
use crate::llvm::{FALSE, Metadata, TRUE, ToLlvmBool};
use crate::type_of::LayoutLlvmExt; use crate::type_of::LayoutLlvmExt;
use crate::value::Value;
use crate::{common, llvm};
impl PartialEq for Type { impl PartialEq for Type {
fn eq(&self, other: &Self) -> bool { fn eq(&self, other: &Self) -> bool {

View File

@@ -11,7 +11,7 @@ use rustc_span::{DUMMY_SP, Span};
use tracing::debug; use tracing::debug;
use crate::common::*; use crate::common::*;
use crate::type_::Type; use crate::llvm::Type;
fn uncached_llvm_type<'a, 'tcx>( fn uncached_llvm_type<'a, 'tcx>(
cx: &CodegenCx<'a, 'tcx>, cx: &CodegenCx<'a, 'tcx>,

View File

@@ -9,9 +9,8 @@ use rustc_middle::ty::Ty;
use rustc_middle::ty::layout::{HasTyCtxt, LayoutOf}; use rustc_middle::ty::layout::{HasTyCtxt, LayoutOf};
use crate::builder::Builder; use crate::builder::Builder;
use crate::type_::Type; use crate::llvm::{Type, Value};
use crate::type_of::LayoutLlvmExt; use crate::type_of::LayoutLlvmExt;
use crate::value::Value;
fn round_up_to_alignment<'ll>( fn round_up_to_alignment<'ll>(
bx: &mut Builder<'_, 'll, '_>, bx: &mut Builder<'_, 'll, '_>,

View File

@@ -1,8 +1,7 @@
use std::hash::{Hash, Hasher}; use std::hash::{Hash, Hasher};
use std::{fmt, ptr}; use std::{fmt, ptr};
use crate::llvm; use crate::llvm::{self, Value};
pub(crate) use crate::llvm::Value;
impl PartialEq for Value { impl PartialEq for Value {
fn eq(&self, other: &Self) -> bool { fn eq(&self, other: &Self) -> bool {