diff --git a/Cargo.lock b/Cargo.lock index a170ece0a0ddc..3cc57502ae8cc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3434,7 +3434,6 @@ dependencies = [ name = "rustc_codegen_llvm" version = "0.0.0" dependencies = [ - "bitflags", "gimli", "itertools", "libc", @@ -4014,8 +4013,14 @@ dependencies = [ name = "rustc_llvm" version = "0.0.0" dependencies = [ + "bitflags", "cc", "libc", + "rustc_codegen_ssa", + "rustc_macros", + "rustc_middle", + "rustc_session", + "rustc_target", ] [[package]] diff --git a/compiler/rustc_codegen_llvm/Cargo.toml b/compiler/rustc_codegen_llvm/Cargo.toml index 88efc8ac96b57..25e64da05b43a 100644 --- a/compiler/rustc_codegen_llvm/Cargo.toml +++ b/compiler/rustc_codegen_llvm/Cargo.toml @@ -8,7 +8,6 @@ test = false [dependencies] # tidy-alphabetical-start -bitflags = "2.4.1" # To avoid duplicate dependencies, this should match the version of gimli used # by `rustc_codegen_ssa` via its `thorin-dwp` dependency. gimli = "0.31" @@ -38,7 +37,7 @@ rustc_session = { path = "../rustc_session" } rustc_span = { path = "../rustc_span" } rustc_symbol_mangling = { path = "../rustc_symbol_mangling" } rustc_target = { path = "../rustc_target" } -serde = { version = "1", features = [ "derive" ]} +serde = { version = "1", features = ["derive"] } serde_json = "1" smallvec = { version = "1.8.1", features = ["union", "may_dangle"] } tracing = "0.1" diff --git a/compiler/rustc_codegen_llvm/src/abi.rs b/compiler/rustc_codegen_llvm/src/abi.rs index 4b07c8aef915b..b42e1b96c5c63 100644 --- a/compiler/rustc_codegen_llvm/src/abi.rs +++ b/compiler/rustc_codegen_llvm/src/abi.rs @@ -23,10 +23,9 @@ use smallvec::SmallVec; use crate::attributes::{self, llfn_attrs_from_instance}; use crate::builder::Builder; use crate::context::CodegenCx; -use crate::llvm::{self, Attribute, AttributePlace}; +use crate::llvm::{self, Attribute, AttributeExt as _, AttributePlace, Value}; use crate::type_::Type; use crate::type_of::LayoutLlvmExt; -use crate::value::Value; trait ArgAttributesExt { fn apply_attrs_to_llfn(&self, idx: AttributePlace, cx: &CodegenCx<'_, '_>, llfn: &Value); @@ -644,8 +643,12 @@ impl AbiBuilderMethods for Builder<'_, '_, '_> { } } -impl llvm::CallConv { - pub(crate) fn from_conv(conv: CanonAbi, arch: &str) -> Self { +pub(crate) trait CallConvExt { + fn from_conv(conv: CanonAbi, arch: &str) -> llvm::CallConv; +} + +impl CallConvExt for llvm::CallConv { + fn from_conv(conv: CanonAbi, arch: &str) -> Self { match conv { CanonAbi::C | CanonAbi::Rust => llvm::CCallConv, CanonAbi::RustCold => llvm::PreserveMost, diff --git a/compiler/rustc_codegen_llvm/src/allocator.rs b/compiler/rustc_codegen_llvm/src/allocator.rs index 9dca63cfc8d4f..13c361af31a30 100644 --- a/compiler/rustc_codegen_llvm/src/allocator.rs +++ b/compiler/rustc_codegen_llvm/src/allocator.rs @@ -11,7 +11,7 @@ use rustc_symbol_mangling::mangle_internal_symbol; use crate::builder::SBuilder; use crate::declare::declare_simple_fn; -use crate::llvm::{self, False, True, Type}; +use crate::llvm::{self, AttributeExt as _, False, True, Type}; use crate::{SimpleCx, attributes, debuginfo}; pub(crate) unsafe fn codegen( diff --git a/compiler/rustc_codegen_llvm/src/asm.rs b/compiler/rustc_codegen_llvm/src/asm.rs index 9ddadcf16aa3d..8d4fcc686177e 100644 --- a/compiler/rustc_codegen_llvm/src/asm.rs +++ b/compiler/rustc_codegen_llvm/src/asm.rs @@ -16,9 +16,9 @@ use tracing::debug; use crate::builder::Builder; use crate::common::Funclet; use crate::context::CodegenCx; +use crate::llvm::{AttributeExt as _, Value}; use crate::type_::Type; use crate::type_of::LayoutLlvmExt; -use crate::value::Value; use crate::{attributes, llvm}; impl<'ll, 'tcx> AsmBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> { diff --git a/compiler/rustc_codegen_llvm/src/attributes.rs b/compiler/rustc_codegen_llvm/src/attributes.rs index 27fd09745ff08..f9e0b3ac159b8 100644 --- a/compiler/rustc_codegen_llvm/src/attributes.rs +++ b/compiler/rustc_codegen_llvm/src/attributes.rs @@ -12,8 +12,10 @@ use smallvec::SmallVec; use crate::context::CodegenCx; use crate::errors::SanitizerMemtagRequiresMte; use crate::llvm::AttributePlace::Function; -use crate::llvm::{self, AllocKindFlags, Attribute, AttributeKind, AttributePlace, MemoryEffects}; -use crate::value::Value; +use crate::llvm::{ + self, AllocKindFlags, Attribute, AttributeExt as _, AttributeKind, AttributePlace, + MemoryEffects, Value, +}; use crate::{attributes, llvm_util}; pub(crate) fn apply_to_llfn(llfn: &Value, idx: AttributePlace, attrs: &[&Attribute]) { diff --git a/compiler/rustc_codegen_llvm/src/back/archive.rs b/compiler/rustc_codegen_llvm/src/back/archive.rs index 0a161442933ab..03f992686dd67 100644 --- a/compiler/rustc_codegen_llvm/src/back/archive.rs +++ b/compiler/rustc_codegen_llvm/src/back/archive.rs @@ -11,7 +11,7 @@ use rustc_codegen_ssa::back::archive::{ use rustc_session::Session; use crate::llvm::archive_ro::{ArchiveRO, Child}; -use crate::llvm::{self, ArchiveKind, last_error}; +use crate::llvm::{self, LLVMRustResultExt as _, last_error, parse_archive_kind}; /// Helper for adding many files to an archive. #[must_use = "must call build() to finish building the archive"] @@ -182,8 +182,7 @@ fn llvm_is_ec_object_file(buf: &[u8]) -> bool { impl<'a> LlvmArchiveBuilder<'a> { fn build_with_llvm(&mut self, output: &Path) -> io::Result { let kind = &*self.sess.target.archive_format; - let kind = kind - .parse::() + let kind = parse_archive_kind(kind) .map_err(|_| kind) .unwrap_or_else(|kind| self.sess.dcx().emit_fatal(UnknownArchiveKind { kind })); diff --git a/compiler/rustc_codegen_llvm/src/back/lto.rs b/compiler/rustc_codegen_llvm/src/back/lto.rs index ee46b49a094c6..aae2bbf830341 100644 --- a/compiler/rustc_codegen_llvm/src/back/lto.rs +++ b/compiler/rustc_codegen_llvm/src/back/lto.rs @@ -29,7 +29,7 @@ use crate::errors::{ DynamicLinkingWithLTO, LlvmError, LtoBitcodeFromRlib, LtoDisallowed, LtoDylib, LtoProcMacro, }; use crate::llvm::AttributePlace::Function; -use crate::llvm::{self, build_string}; +use crate::llvm::{self, AttributeExt as _, build_string}; use crate::{LlvmCodegenBackend, ModuleLlvm, SimpleCx, attributes}; /// We keep track of the computed LTO cache keys from the previous diff --git a/compiler/rustc_codegen_llvm/src/back/write.rs b/compiler/rustc_codegen_llvm/src/back/write.rs index bde6a9cf4bc61..af87495b2a8b9 100644 --- a/compiler/rustc_codegen_llvm/src/back/write.rs +++ b/compiler/rustc_codegen_llvm/src/back/write.rs @@ -41,8 +41,8 @@ use crate::errors::{ WithLlvmError, WriteBytecode, }; use crate::llvm::diagnostic::OptimizationDiagnosticKind::*; -use crate::llvm::{self, DiagnosticInfo}; -use crate::type_::Type; +use crate::llvm::{self, DiagnosticInfo, LLVMRustResultExt as _}; +use crate::type_::type_ptr_llcx; use crate::{LlvmCodegenBackend, ModuleLlvm, base, common, llvm_util}; pub(crate) fn llvm_err<'a>(dcx: DiagCtxtHandle<'_>, err: LlvmError<'a>) -> FatalError { @@ -1174,7 +1174,7 @@ fn create_msvc_imps( // underscores added in front). let prefix = if cgcx.target_arch == "x86" { "\x01__imp__" } else { "\x01__imp_" }; - let ptr_ty = Type::ptr_llcx(llcx); + let ptr_ty = type_ptr_llcx(llcx); let globals = base::iter_globals(llmod) .filter(|&val| { llvm::get_linkage(val) == llvm::Linkage::ExternalLinkage && !llvm::is_declaration(val) diff --git a/compiler/rustc_codegen_llvm/src/base.rs b/compiler/rustc_codegen_llvm/src/base.rs index 5dda836988c81..6bf6ba32bd964 100644 --- a/compiler/rustc_codegen_llvm/src/base.rs +++ b/compiler/rustc_codegen_llvm/src/base.rs @@ -29,7 +29,7 @@ use rustc_target::spec::SanitizerSet; use super::ModuleLlvm; use crate::builder::Builder; use crate::context::CodegenCx; -use crate::value::Value; +use crate::llvm::Value; use crate::{attributes, llvm}; pub(crate) struct ValueIter<'ll> { diff --git a/compiler/rustc_codegen_llvm/src/builder.rs b/compiler/rustc_codegen_llvm/src/builder.rs index 5e9594dd06bb7..90a00cd92df65 100644 --- a/compiler/rustc_codegen_llvm/src/builder.rs +++ b/compiler/rustc_codegen_llvm/src/builder.rs @@ -33,11 +33,11 @@ use crate::attributes; use crate::common::Funclet; use crate::context::{CodegenCx, FullCx, GenericCx, SCx}; use crate::llvm::{ - self, AtomicOrdering, AtomicRmwBinOp, BasicBlock, False, GEPNoWrapFlags, Metadata, True, + self, AtomicOrdering, AtomicRmwBinOp, AttributeExt as _, BasicBlock, False, GEPNoWrapFlags, + Metadata, True, Value, }; use crate::type_::Type; use crate::type_of::LayoutLlvmExt; -use crate::value::Value; #[must_use] pub(crate) struct GenericBuilder<'a, 'll, CX: Borrow>> { diff --git a/compiler/rustc_codegen_llvm/src/builder/autodiff.rs b/compiler/rustc_codegen_llvm/src/builder/autodiff.rs index b07d9a5cfca8c..567c6985c16f4 100644 --- a/compiler/rustc_codegen_llvm/src/builder/autodiff.rs +++ b/compiler/rustc_codegen_llvm/src/builder/autodiff.rs @@ -15,8 +15,7 @@ use crate::context::SimpleCx; use crate::declare::declare_simple_fn; use crate::errors::{AutoDiffWithoutEnable, LlvmError}; use crate::llvm::AttributePlace::Function; -use crate::llvm::{Metadata, True}; -use crate::value::Value; +use crate::llvm::{AttributeExt as _, Metadata, True, Value}; use crate::{CodegenContext, LlvmCodegenBackend, ModuleLlvm, attributes, llvm}; fn get_params(fnc: &Value) -> Vec<&Value> { diff --git a/compiler/rustc_codegen_llvm/src/callee.rs b/compiler/rustc_codegen_llvm/src/callee.rs index 6d68eca60afc1..719770365b875 100644 --- a/compiler/rustc_codegen_llvm/src/callee.rs +++ b/compiler/rustc_codegen_llvm/src/callee.rs @@ -11,7 +11,7 @@ use tracing::debug; use crate::context::CodegenCx; use crate::llvm; -use crate::value::Value; +use crate::llvm::Value; /// Codegens a reference to a fn/method item, monomorphizing and /// inlining as it goes. diff --git a/compiler/rustc_codegen_llvm/src/common.rs b/compiler/rustc_codegen_llvm/src/common.rs index ae5add59322fe..3617dabf04601 100644 --- a/compiler/rustc_codegen_llvm/src/common.rs +++ b/compiler/rustc_codegen_llvm/src/common.rs @@ -21,9 +21,8 @@ use tracing::debug; use crate::consts::const_alloc_to_llvm; pub(crate) use crate::context::CodegenCx; use crate::context::{GenericCx, SCx}; -use crate::llvm::{self, BasicBlock, Bool, ConstantInt, False, Metadata, True}; +use crate::llvm::{self, BasicBlock, Bool, ConstantInt, False, Metadata, True, Value}; use crate::type_::Type; -use crate::value::Value; /* * A note on nomenclature of linking: "extern", "foreign", and "upcall". diff --git a/compiler/rustc_codegen_llvm/src/consts.rs b/compiler/rustc_codegen_llvm/src/consts.rs index a4492d76c3c59..ce6f076f63e04 100644 --- a/compiler/rustc_codegen_llvm/src/consts.rs +++ b/compiler/rustc_codegen_llvm/src/consts.rs @@ -19,10 +19,9 @@ use tracing::{debug, instrument, trace}; use crate::common::{AsCCharPtr, CodegenCx}; use crate::errors::SymbolAlreadyDefined; -use crate::llvm::{self, True}; +use crate::llvm::{self, True, Value}; use crate::type_::Type; use crate::type_of::LayoutLlvmExt; -use crate::value::Value; use crate::{base, debuginfo}; pub(crate) fn const_alloc_to_llvm<'ll>( diff --git a/compiler/rustc_codegen_llvm/src/context.rs b/compiler/rustc_codegen_llvm/src/context.rs index 0324dff6ff256..03f9d594c6876 100644 --- a/compiler/rustc_codegen_llvm/src/context.rs +++ b/compiler/rustc_codegen_llvm/src/context.rs @@ -32,13 +32,13 @@ use rustc_symbol_mangling::mangle_internal_symbol; use rustc_target::spec::{HasTargetSpec, RelocModel, SmallDataThresholdSupport, Target, TlsModel}; use smallvec::SmallVec; +use crate::abi::CallConvExt as _; use crate::back::write::to_llvm_code_model; use crate::callee::get_fn; use crate::common::AsCCharPtr; use crate::debuginfo::metadata::apply_vcall_visibility_metadata; -use crate::llvm::Metadata; -use crate::type_::Type; -use crate::value::Value; +use crate::llvm::{Metadata, Value}; +use crate::type_::{Type, type_ix_llcx}; use crate::{attributes, common, coverageinfo, debuginfo, llvm, llvm_util}; /// `TyCtxt` (and related cache datastructures) can't be move between threads. @@ -669,7 +669,7 @@ impl<'ll> SimpleCx<'ll> { llcx: &'ll llvm::Context, pointer_size: Size, ) -> Self { - let isize_ty = llvm::Type::ix_llcx(llcx, pointer_size.bits()); + let isize_ty = type_ix_llcx(llcx, pointer_size.bits()); Self(SCx { llmod, llcx, isize_ty }, PhantomData) } } diff --git a/compiler/rustc_codegen_llvm/src/coverageinfo/llvm_cov.rs b/compiler/rustc_codegen_llvm/src/coverageinfo/llvm_cov.rs index 907d6d41a1fb5..89cdc312a80d6 100644 --- a/compiler/rustc_codegen_llvm/src/coverageinfo/llvm_cov.rs +++ b/compiler/rustc_codegen_llvm/src/coverageinfo/llvm_cov.rs @@ -2,8 +2,9 @@ use std::ffi::CString; +use rustc_llvm::ffi; + use crate::common::AsCCharPtr; -use crate::coverageinfo::ffi; use crate::llvm; pub(crate) fn covmap_var_name() -> CString { @@ -60,10 +61,10 @@ pub(crate) fn write_filenames_to_buffer(filenames: &[impl AsRef]) -> Vec Vec { - let ffi::Regions { + let ffi::coverageinfo::Regions { code_regions, expansion_regions, branch_regions, diff --git a/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen/covfun.rs b/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen/covfun.rs index b704cf2b1cd46..a099b808f56de 100644 --- a/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen/covfun.rs +++ b/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen/covfun.rs @@ -9,6 +9,7 @@ use std::sync::Arc; use rustc_abi::Align; use rustc_codegen_ssa::traits::{BaseTypeCodegenMethods as _, ConstCodegenMethods}; +use rustc_llvm::ffi; use rustc_middle::mir::coverage::{ BasicCoverageBlock, CovTerm, CoverageIdsInfo, Expression, FunctionCoverageInfo, Mapping, MappingKind, Op, @@ -19,8 +20,8 @@ use rustc_target::spec::HasTargetSpec; use tracing::debug; use crate::common::CodegenCx; +use crate::coverageinfo::llvm_cov; use crate::coverageinfo::mapgen::{GlobalFileTable, VirtualFileMapping, spans}; -use crate::coverageinfo::{ffi, llvm_cov}; use crate::llvm; /// Intermediate coverage metadata for a single function, used to help build @@ -32,8 +33,8 @@ pub(crate) struct CovfunRecord<'tcx> { is_used: bool, virtual_file_mapping: VirtualFileMapping, - expressions: Vec, - regions: ffi::Regions, + expressions: Vec, + regions: ffi::coverageinfo::Regions, } impl<'tcx> CovfunRecord<'tcx> { @@ -60,7 +61,7 @@ pub(crate) fn prepare_covfun_record<'tcx>( is_used, virtual_file_mapping: VirtualFileMapping::default(), expressions, - regions: ffi::Regions::default(), + regions: ffi::coverageinfo::Regions::default(), }; fill_region_tables(tcx, fn_cov_info, ids_info, &mut covfun); @@ -74,8 +75,8 @@ pub(crate) fn prepare_covfun_record<'tcx>( } /// Convert the function's coverage-counter expressions into a form suitable for FFI. -fn prepare_expressions(ids_info: &CoverageIdsInfo) -> Vec { - let counter_for_term = ffi::Counter::from_term; +fn prepare_expressions(ids_info: &CoverageIdsInfo) -> Vec { + let counter_for_term = ffi::coverageinfo::Counter::from_term; // We know that LLVM will optimize out any unused expressions before // producing the final coverage map, so there's no need to do the same @@ -84,11 +85,11 @@ fn prepare_expressions(ids_info: &CoverageIdsInfo) -> Vec ffi::ExprKind::Add, - Op::Subtract => ffi::ExprKind::Subtract, + Op::Add => ffi::coverageinfo::ExprKind::Add, + Op::Subtract => ffi::coverageinfo::ExprKind::Subtract, }, rhs: counter_for_term(rhs), }) @@ -122,7 +123,7 @@ fn fill_region_tables<'tcx>( if discard_all { None } else { spans::make_coords(source_map, &source_file, span) } }; - let ffi::Regions { + let ffi::coverageinfo::Regions { code_regions, expansion_regions: _, // FIXME(Zalathar): Fill out support for expansion regions branch_regions, @@ -134,13 +135,13 @@ fn fill_region_tables<'tcx>( // form suitable for FFI. for &Mapping { ref kind, span } in &fn_cov_info.mappings { // If this function is unused, replace all counters with zero. - let counter_for_bcb = |bcb: BasicCoverageBlock| -> ffi::Counter { + let counter_for_bcb = |bcb: BasicCoverageBlock| -> ffi::coverageinfo::Counter { let term = if covfun.is_used { ids_info.term_for_bcb[bcb].expect("every BCB in a mapping was given a term") } else { CovTerm::Zero }; - ffi::Counter::from_term(term) + ffi::coverageinfo::Counter::from_term(term) }; let Some(coords) = make_coords(span) else { continue }; @@ -148,27 +149,34 @@ fn fill_region_tables<'tcx>( match *kind { MappingKind::Code { bcb } => { - code_regions.push(ffi::CodeRegion { cov_span, counter: counter_for_bcb(bcb) }); + code_regions.push(ffi::coverageinfo::CodeRegion { + cov_span, + counter: counter_for_bcb(bcb), + }); } MappingKind::Branch { true_bcb, false_bcb } => { - branch_regions.push(ffi::BranchRegion { + branch_regions.push(ffi::coverageinfo::BranchRegion { cov_span, true_counter: counter_for_bcb(true_bcb), false_counter: counter_for_bcb(false_bcb), }); } MappingKind::MCDCBranch { true_bcb, false_bcb, mcdc_params } => { - mcdc_branch_regions.push(ffi::MCDCBranchRegion { + mcdc_branch_regions.push(ffi::coverageinfo::MCDCBranchRegion { cov_span, true_counter: counter_for_bcb(true_bcb), false_counter: counter_for_bcb(false_bcb), - mcdc_branch_params: ffi::mcdc::BranchParameters::from(mcdc_params), + mcdc_branch_params: ffi::coverageinfo::mcdc::BranchParameters::from( + mcdc_params, + ), }); } MappingKind::MCDCDecision(mcdc_decision_params) => { - mcdc_decision_regions.push(ffi::MCDCDecisionRegion { + mcdc_decision_regions.push(ffi::coverageinfo::MCDCDecisionRegion { cov_span, - mcdc_decision_params: ffi::mcdc::DecisionParameters::from(mcdc_decision_params), + mcdc_decision_params: ffi::coverageinfo::mcdc::DecisionParameters::from( + mcdc_decision_params, + ), }); } } diff --git a/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen/spans.rs b/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen/spans.rs index 39a59560c9d3e..9933b194e7baa 100644 --- a/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen/spans.rs +++ b/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen/spans.rs @@ -1,8 +1,8 @@ +use rustc_llvm::ffi; use rustc_span::source_map::SourceMap; use rustc_span::{BytePos, Pos, SourceFile, Span}; use tracing::debug; -use crate::coverageinfo::ffi; use crate::coverageinfo::mapgen::LocalFileId; /// Line and byte-column coordinates of a source code span within some file. @@ -20,11 +20,14 @@ pub(crate) struct Coords { } impl Coords { - /// Attaches a local file ID to these coordinates to produce an `ffi::CoverageSpan`. - pub(crate) fn make_coverage_span(&self, local_file_id: LocalFileId) -> ffi::CoverageSpan { + /// Attaches a local file ID to these coordinates to produce an `ffi::coverageinfo::CoverageSpan`. + pub(crate) fn make_coverage_span( + &self, + local_file_id: LocalFileId, + ) -> ffi::coverageinfo::CoverageSpan { let &Self { start_line, start_col, end_line, end_col } = self; let file_id = local_file_id.as_u32(); - ffi::CoverageSpan { file_id, start_line, start_col, end_line, end_col } + ffi::coverageinfo::CoverageSpan { file_id, start_line, start_col, end_line, end_col } } } diff --git a/compiler/rustc_codegen_llvm/src/coverageinfo/mod.rs b/compiler/rustc_codegen_llvm/src/coverageinfo/mod.rs index eefbd7cf6c48b..1fc13619d17ea 100644 --- a/compiler/rustc_codegen_llvm/src/coverageinfo/mod.rs +++ b/compiler/rustc_codegen_llvm/src/coverageinfo/mod.rs @@ -14,7 +14,6 @@ use crate::builder::Builder; use crate::common::CodegenCx; use crate::llvm; -pub(crate) mod ffi; mod llvm_cov; mod mapgen; diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/gdb.rs b/compiler/rustc_codegen_llvm/src/debuginfo/gdb.rs index 8f0948b8183bf..3118834b22d21 100644 --- a/compiler/rustc_codegen_llvm/src/debuginfo/gdb.rs +++ b/compiler/rustc_codegen_llvm/src/debuginfo/gdb.rs @@ -12,7 +12,7 @@ use rustc_span::sym; use crate::builder::Builder; use crate::common::CodegenCx; use crate::llvm; -use crate::value::Value; +use crate::llvm::Value; /// 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. diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs b/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs index 7f3e486ca310d..18971acc9fe74 100644 --- a/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs +++ b/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs @@ -1,6 +1,5 @@ use std::borrow::Cow; -use std::fmt::{self, Write}; -use std::hash::{Hash, Hasher}; +use std::fmt::Write; use std::path::{Path, PathBuf}; use std::sync::Arc; use std::{iter, ptr}; @@ -38,31 +37,11 @@ use crate::debuginfo::dwarf_const; use crate::debuginfo::metadata::type_map::build_type_with_children; use crate::debuginfo::utils::{WidePtrKind, wide_pointer_kind}; use crate::llvm; +use crate::llvm::Value; use crate::llvm::debuginfo::{ DIBasicType, DIBuilder, DICompositeType, DIDescriptor, DIFile, DIFlags, DILexicalBlock, DIScope, DIType, DebugEmissionKind, DebugNameTableKind, }; -use crate::value::Value; - -impl PartialEq for llvm::Metadata { - fn eq(&self, other: &Self) -> bool { - ptr::eq(self, other) - } -} - -impl Eq for llvm::Metadata {} - -impl Hash for llvm::Metadata { - fn hash(&self, hasher: &mut H) { - (self as *const Self).hash(hasher); - } -} - -impl fmt::Debug for llvm::Metadata { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - (self as *const Self).fmt(f) - } -} pub(super) const UNKNOWN_LINE_NUMBER: c_uint = 0; pub(super) const UNKNOWN_COLUMN_NUMBER: c_uint = 0; diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/mod.rs b/compiler/rustc_codegen_llvm/src/debuginfo/mod.rs index 5ca2505cec43b..19c892ebc6d45 100644 --- a/compiler/rustc_codegen_llvm/src/debuginfo/mod.rs +++ b/compiler/rustc_codegen_llvm/src/debuginfo/mod.rs @@ -34,11 +34,11 @@ use self::utils::{DIB, create_DIArray, is_node_local_to_unit}; use crate::builder::Builder; use crate::common::{AsCCharPtr, CodegenCx}; use crate::llvm; +use crate::llvm::Value; use crate::llvm::debuginfo::{ DIArray, DIBuilderBox, DIFile, DIFlags, DILexicalBlock, DILocation, DISPFlags, DIScope, DITemplateTypeParameter, DIType, DIVariable, }; -use crate::value::Value; mod create_scope_map; mod dwarf_const; diff --git a/compiler/rustc_codegen_llvm/src/declare.rs b/compiler/rustc_codegen_llvm/src/declare.rs index 2419ec1f88854..0487c87b67051 100644 --- a/compiler/rustc_codegen_llvm/src/declare.rs +++ b/compiler/rustc_codegen_llvm/src/declare.rs @@ -26,9 +26,8 @@ use crate::abi::FnAbiLlvmExt; use crate::common::AsCCharPtr; use crate::context::{CodegenCx, GenericCx, SCx, SimpleCx}; use crate::llvm::AttributePlace::Function; -use crate::llvm::Visibility; +use crate::llvm::{AttributeExt as _, Value, Visibility}; use crate::type_::Type; -use crate::value::Value; use crate::{attributes, llvm}; /// Declare a function with a SimpleCx. diff --git a/compiler/rustc_codegen_llvm/src/intrinsic.rs b/compiler/rustc_codegen_llvm/src/intrinsic.rs index f7f062849a8b5..be7ed376eb7fb 100644 --- a/compiler/rustc_codegen_llvm/src/intrinsic.rs +++ b/compiler/rustc_codegen_llvm/src/intrinsic.rs @@ -21,11 +21,10 @@ use tracing::debug; use crate::abi::FnAbiLlvmExt; use crate::builder::Builder; use crate::context::CodegenCx; -use crate::llvm::{self, Metadata}; +use crate::llvm::{self, Metadata, Value}; use crate::type_::Type; use crate::type_of::LayoutLlvmExt; use crate::va_arg::emit_va_arg; -use crate::value::Value; fn call_simple_intrinsic<'ll, 'tcx>( bx: &mut Builder<'_, 'll, 'tcx>, diff --git a/compiler/rustc_codegen_llvm/src/lib.rs b/compiler/rustc_codegen_llvm/src/lib.rs index cdfffbe47bfa5..929c17714c00c 100644 --- a/compiler/rustc_codegen_llvm/src/lib.rs +++ b/compiler/rustc_codegen_llvm/src/lib.rs @@ -75,7 +75,6 @@ mod mono_item; mod type_; mod type_of; mod va_arg; -mod value; rustc_fluent_macro::fluent_messages! { "../messages.ftl" } diff --git a/compiler/rustc_codegen_llvm/src/llvm/diagnostic.rs b/compiler/rustc_codegen_llvm/src/llvm/diagnostic.rs index 0e0f2b0eab016..59b2cd329ae76 100644 --- a/compiler/rustc_codegen_llvm/src/llvm/diagnostic.rs +++ b/compiler/rustc_codegen_llvm/src/llvm/diagnostic.rs @@ -6,7 +6,7 @@ use rustc_span::InnerSpan; pub(crate) use self::Diagnostic::*; use self::OptimizationDiagnosticKind::*; use super::{DiagnosticInfo, SMDiagnostic}; -use crate::value::Value; +use crate::llvm::Value; #[derive(Copy, Clone, Debug)] pub(crate) enum OptimizationDiagnosticKind { diff --git a/compiler/rustc_codegen_llvm/src/llvm/enzyme_ffi.rs b/compiler/rustc_codegen_llvm/src/llvm/enzyme_ffi.rs deleted file mode 100644 index 2ad39fc853819..0000000000000 --- a/compiler/rustc_codegen_llvm/src/llvm/enzyme_ffi.rs +++ /dev/null @@ -1,147 +0,0 @@ -#![allow(non_camel_case_types)] -#![expect(dead_code)] - -use libc::{c_char, c_uint}; - -use super::MetadataKindId; -use super::ffi::{AttributeKind, BasicBlock, Metadata, Module, Type, Value}; -use crate::llvm::Bool; - -#[link(name = "llvm-wrapper", kind = "static")] -unsafe extern "C" { - // Enzyme - pub(crate) safe fn LLVMRustHasMetadata(I: &Value, KindID: MetadataKindId) -> bool; - pub(crate) fn LLVMRustEraseInstUntilInclusive(BB: &BasicBlock, I: &Value); - pub(crate) fn LLVMRustGetLastInstruction<'a>(BB: &BasicBlock) -> Option<&'a Value>; - pub(crate) fn LLVMRustDIGetInstMetadata(I: &Value) -> Option<&Metadata>; - pub(crate) fn LLVMRustEraseInstFromParent(V: &Value); - pub(crate) fn LLVMRustGetTerminator<'a>(B: &BasicBlock) -> &'a Value; - pub(crate) fn LLVMRustVerifyFunction(V: &Value, action: LLVMRustVerifierFailureAction) -> Bool; - pub(crate) fn LLVMRustHasAttributeAtIndex(V: &Value, i: c_uint, Kind: AttributeKind) -> bool; - pub(crate) fn LLVMRustGetArrayNumElements(Ty: &Type) -> u64; - pub(crate) fn LLVMRustHasFnAttribute( - F: &Value, - Name: *const c_char, - NameLen: libc::size_t, - ) -> bool; - pub(crate) fn LLVMRustRemoveFnAttribute(F: &Value, Name: *const c_char, NameLen: libc::size_t); - pub(crate) fn LLVMGetFirstFunction(M: &Module) -> Option<&Value>; - pub(crate) fn LLVMGetNextFunction(Fn: &Value) -> Option<&Value>; - pub(crate) fn LLVMRustRemoveEnumAttributeAtIndex( - Fn: &Value, - index: c_uint, - kind: AttributeKind, - ); -} - -unsafe extern "C" { - // Enzyme - pub(crate) fn LLVMDumpModule(M: &Module); - pub(crate) fn LLVMDumpValue(V: &Value); - pub(crate) fn LLVMGetFunctionCallConv(F: &Value) -> c_uint; - pub(crate) fn LLVMGetReturnType(T: &Type) -> &Type; - pub(crate) fn LLVMGetParams(Fnc: &Value, parms: *mut &Value); - pub(crate) fn LLVMGetNamedFunction(M: &Module, Name: *const c_char) -> Option<&Value>; -} - -#[repr(C)] -#[derive(Copy, Clone, PartialEq)] -pub(crate) enum LLVMRustVerifierFailureAction { - LLVMAbortProcessAction = 0, - LLVMPrintMessageAction = 1, - LLVMReturnStatusAction = 2, -} - -#[cfg(llvm_enzyme)] -pub(crate) use self::Enzyme_AD::*; - -#[cfg(llvm_enzyme)] -pub(crate) mod Enzyme_AD { - use libc::c_void; - unsafe extern "C" { - pub(crate) fn EnzymeSetCLBool(arg1: *mut ::std::os::raw::c_void, arg2: u8); - } - unsafe extern "C" { - static mut EnzymePrintPerf: c_void; - static mut EnzymePrintActivity: c_void; - static mut EnzymePrintType: c_void; - static mut EnzymePrint: c_void; - static mut EnzymeStrictAliasing: c_void; - static mut looseTypeAnalysis: c_void; - static mut EnzymeInline: c_void; - static mut RustTypeRules: c_void; - } - pub(crate) fn set_print_perf(print: bool) { - unsafe { - EnzymeSetCLBool(std::ptr::addr_of_mut!(EnzymePrintPerf), print as u8); - } - } - pub(crate) fn set_print_activity(print: bool) { - unsafe { - EnzymeSetCLBool(std::ptr::addr_of_mut!(EnzymePrintActivity), print as u8); - } - } - pub(crate) fn set_print_type(print: bool) { - unsafe { - EnzymeSetCLBool(std::ptr::addr_of_mut!(EnzymePrintType), print as u8); - } - } - pub(crate) fn set_print(print: bool) { - unsafe { - EnzymeSetCLBool(std::ptr::addr_of_mut!(EnzymePrint), print as u8); - } - } - pub(crate) fn set_strict_aliasing(strict: bool) { - unsafe { - EnzymeSetCLBool(std::ptr::addr_of_mut!(EnzymeStrictAliasing), strict as u8); - } - } - pub(crate) fn set_loose_types(loose: bool) { - unsafe { - EnzymeSetCLBool(std::ptr::addr_of_mut!(looseTypeAnalysis), loose as u8); - } - } - pub(crate) fn set_inline(val: bool) { - unsafe { - EnzymeSetCLBool(std::ptr::addr_of_mut!(EnzymeInline), val as u8); - } - } - pub(crate) fn set_rust_rules(val: bool) { - unsafe { - EnzymeSetCLBool(std::ptr::addr_of_mut!(RustTypeRules), val as u8); - } - } -} - -#[cfg(not(llvm_enzyme))] -pub(crate) use self::Fallback_AD::*; - -#[cfg(not(llvm_enzyme))] -pub(crate) mod Fallback_AD { - #![allow(unused_variables)] - - pub(crate) fn set_inline(val: bool) { - unimplemented!() - } - pub(crate) fn set_print_perf(print: bool) { - unimplemented!() - } - pub(crate) fn set_print_activity(print: bool) { - unimplemented!() - } - pub(crate) fn set_print_type(print: bool) { - unimplemented!() - } - pub(crate) fn set_print(print: bool) { - unimplemented!() - } - pub(crate) fn set_strict_aliasing(strict: bool) { - unimplemented!() - } - pub(crate) fn set_loose_types(loose: bool) { - unimplemented!() - } - pub(crate) fn set_rust_rules(val: bool) { - unimplemented!() - } -} diff --git a/compiler/rustc_codegen_llvm/src/llvm/mod.rs b/compiler/rustc_codegen_llvm/src/llvm/mod.rs index 661174a80dfbd..fc2caa519a17d 100644 --- a/compiler/rustc_codegen_llvm/src/llvm/mod.rs +++ b/compiler/rustc_codegen_llvm/src/llvm/mod.rs @@ -3,12 +3,11 @@ use std::ffi::{CStr, CString}; use std::num::NonZero; use std::ptr; -use std::str::FromStr; use std::string::FromUtf8Error; use libc::c_uint; use rustc_abi::{Align, Size, WrappingRange}; -use rustc_llvm::RustString; +use rustc_llvm::{RustString, ffi}; pub(crate) use self::CallConv::*; pub(crate) use self::CodeGenOptSize::*; @@ -18,13 +17,13 @@ use crate::common::AsCCharPtr; pub(crate) mod archive_ro; pub(crate) mod diagnostic; -pub(crate) mod enzyme_ffi; -mod ffi; -pub(crate) use self::enzyme_ffi::*; +pub(crate) trait LLVMRustResultExt { + fn into_result(self) -> Result<(), ()>; +} -impl LLVMRustResult { - pub(crate) fn into_result(self) -> Result<(), ()> { +impl LLVMRustResultExt for LLVMRustResult { + fn into_result(self) -> Result<(), ()> { match self { LLVMRustResult::Success => Ok(()), LLVMRustResult::Failure => Err(()), @@ -178,18 +177,14 @@ pub(crate) enum CodeGenOptSize { CodeGenOptSizeAggressive = 2, } -impl FromStr for ArchiveKind { - type Err = (); - - fn from_str(s: &str) -> Result { - match s { - "gnu" => Ok(ArchiveKind::K_GNU), - "bsd" => Ok(ArchiveKind::K_BSD), - "darwin" => Ok(ArchiveKind::K_DARWIN), - "coff" => Ok(ArchiveKind::K_COFF), - "aix_big" => Ok(ArchiveKind::K_AIXBIG), - _ => Err(()), - } +pub(crate) fn parse_archive_kind(s: &str) -> Result { + match s { + "gnu" => Ok(ArchiveKind::K_GNU), + "bsd" => Ok(ArchiveKind::K_BSD), + "darwin" => Ok(ArchiveKind::K_DARWIN), + "coff" => Ok(ArchiveKind::K_COFF), + "aix_big" => Ok(ArchiveKind::K_AIXBIG), + _ => Err(()), } } @@ -229,16 +224,19 @@ pub(crate) fn set_thread_local_mode(global: &Value, mode: ThreadLocalMode) { } } -impl AttributeKind { +pub(crate) trait AttributeExt { + fn create_attr(self, llcx: &Context) -> &Attribute; +} +impl AttributeExt for AttributeKind { /// Create an LLVM Attribute with no associated value. - pub(crate) fn create_attr(self, llcx: &Context) -> &Attribute { + fn create_attr(self, llcx: &Context) -> &Attribute { unsafe { LLVMRustCreateAttrNoValue(llcx, self) } } } -impl MemoryEffects { +impl AttributeExt for MemoryEffects { /// Create an LLVM Attribute with these memory effects. - pub(crate) fn create_attr(self, llcx: &Context) -> &Attribute { + fn create_attr(self, llcx: &Context) -> &Attribute { unsafe { LLVMRustCreateMemoryEffectsAttr(llcx, self) } } } diff --git a/compiler/rustc_codegen_llvm/src/type_.rs b/compiler/rustc_codegen_llvm/src/type_.rs index 453eca2bbe173..e6d8d13522ab3 100644 --- a/compiler/rustc_codegen_llvm/src/type_.rs +++ b/compiler/rustc_codegen_llvm/src/type_.rs @@ -1,6 +1,4 @@ use std::borrow::Borrow; -use std::hash::{Hash, Hasher}; -use std::{fmt, ptr}; use libc::{c_char, c_uint}; use rustc_abi::{AddressSpace, Align, Integer, Reg, Size}; @@ -15,36 +13,10 @@ use rustc_target::callconv::{CastTarget, FnAbi}; use crate::abi::{FnAbiLlvmExt, LlvmType}; use crate::context::{CodegenCx, GenericCx, SCx}; pub(crate) use crate::llvm::Type; -use crate::llvm::{Bool, False, Metadata, True}; +use crate::llvm::{Bool, False, Metadata, True, Value}; use crate::type_of::LayoutLlvmExt; -use crate::value::Value; use crate::{common, llvm}; -impl PartialEq for Type { - fn eq(&self, other: &Self) -> bool { - ptr::eq(self, other) - } -} - -impl Eq for Type {} - -impl Hash for Type { - fn hash(&self, state: &mut H) { - ptr::hash(self, state); - } -} - -impl fmt::Debug for Type { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.write_str( - &llvm::build_string(|s| unsafe { - llvm::LLVMRustWriteTypeToString(self, s); - }) - .expect("non-UTF8 type description from LLVM"), - ) - } -} - impl<'ll> CodegenCx<'ll, '_> {} impl<'ll, CX: Borrow>> GenericCx<'ll, CX> { pub(crate) fn type_named_struct(&self, name: &str) -> &'ll Type { @@ -251,15 +223,13 @@ impl<'ll, CX: Borrow>> BaseTypeCodegenMethods for GenericCx<'ll, CX> { } } -impl Type { - /// Creates an integer type with the given number of bits, e.g., i24 - pub(crate) fn ix_llcx(llcx: &llvm::Context, num_bits: u64) -> &Type { - unsafe { llvm::LLVMIntTypeInContext(llcx, num_bits as c_uint) } - } +/// Creates an integer type with the given number of bits, e.g., i24 +pub(crate) fn type_ix_llcx(llcx: &llvm::Context, num_bits: u64) -> &Type { + unsafe { llvm::LLVMIntTypeInContext(llcx, num_bits as c_uint) } +} - pub(crate) fn ptr_llcx(llcx: &llvm::Context) -> &Type { - unsafe { llvm::LLVMPointerTypeInContext(llcx, AddressSpace::DATA.0) } - } +pub(crate) fn type_ptr_llcx(llcx: &llvm::Context) -> &Type { + unsafe { llvm::LLVMPointerTypeInContext(llcx, AddressSpace::DATA.0) } } impl<'ll, 'tcx> LayoutTypeCodegenMethods<'tcx> for CodegenCx<'ll, 'tcx> { diff --git a/compiler/rustc_codegen_llvm/src/va_arg.rs b/compiler/rustc_codegen_llvm/src/va_arg.rs index 236568590be19..6c94906e67d8b 100644 --- a/compiler/rustc_codegen_llvm/src/va_arg.rs +++ b/compiler/rustc_codegen_llvm/src/va_arg.rs @@ -9,9 +9,9 @@ use rustc_middle::ty::Ty; use rustc_middle::ty::layout::{HasTyCtxt, LayoutOf}; use crate::builder::Builder; +use crate::llvm::Value; use crate::type_::Type; use crate::type_of::LayoutLlvmExt; -use crate::value::Value; fn round_up_to_alignment<'ll>( bx: &mut Builder<'_, 'll, '_>, diff --git a/compiler/rustc_codegen_llvm/src/value.rs b/compiler/rustc_codegen_llvm/src/value.rs deleted file mode 100644 index 2eabac3be8c56..0000000000000 --- a/compiler/rustc_codegen_llvm/src/value.rs +++ /dev/null @@ -1,30 +0,0 @@ -use std::hash::{Hash, Hasher}; -use std::{fmt, ptr}; - -use crate::llvm; -pub(crate) use crate::llvm::Value; - -impl PartialEq for Value { - fn eq(&self, other: &Self) -> bool { - ptr::eq(self, other) - } -} - -impl Eq for Value {} - -impl Hash for Value { - fn hash(&self, hasher: &mut H) { - (self as *const Self).hash(hasher); - } -} - -impl fmt::Debug for Value { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.write_str( - &llvm::build_string(|s| unsafe { - llvm::LLVMRustWriteValueToString(self, s); - }) - .expect("non-UTF8 value description from LLVM"), - ) - } -} diff --git a/compiler/rustc_llvm/Cargo.toml b/compiler/rustc_llvm/Cargo.toml index 061562b2ec5ed..3c67ce7232d1d 100644 --- a/compiler/rustc_llvm/Cargo.toml +++ b/compiler/rustc_llvm/Cargo.toml @@ -5,7 +5,13 @@ edition = "2024" [dependencies] # tidy-alphabetical-start +bitflags = "2.4.1" libc = "0.2.73" +rustc_codegen_ssa = { path = "../rustc_codegen_ssa" } +rustc_macros = { path = "../rustc_macros" } +rustc_middle = { path = "../rustc_middle" } +rustc_session = { path = "../rustc_session" } +rustc_target = { path = "../rustc_target" } # tidy-alphabetical-end [build-dependencies] diff --git a/compiler/rustc_codegen_llvm/src/coverageinfo/ffi.rs b/compiler/rustc_llvm/src/ffi/coverageinfo/mod.rs similarity index 74% rename from compiler/rustc_codegen_llvm/src/coverageinfo/ffi.rs rename to compiler/rustc_llvm/src/ffi/coverageinfo/mod.rs index f6000e7284002..65cd58ce47e81 100644 --- a/compiler/rustc_codegen_llvm/src/coverageinfo/ffi.rs +++ b/compiler/rustc_llvm/src/ffi/coverageinfo/mod.rs @@ -3,7 +3,7 @@ use rustc_middle::mir::coverage::{CounterId, CovTerm, ExpressionId}; /// Must match the layout of `LLVMRustCounterKind`. #[derive(Copy, Clone, Debug)] #[repr(C)] -pub(crate) enum CounterKind { +pub enum CounterKind { Zero = 0, CounterValueReference = 1, Expression = 2, @@ -23,27 +23,27 @@ pub(crate) enum CounterKind { /// Must match the layout of `LLVMRustCounter`. #[derive(Copy, Clone, Debug)] #[repr(C)] -pub(crate) struct Counter { +pub struct Counter { // Important: The layout (order and types of fields) must match its C++ counterpart. - pub(crate) kind: CounterKind, + pub kind: CounterKind, id: u32, } impl Counter { /// A `Counter` of kind `Zero`. For this counter kind, the `id` is not used. - pub(crate) const ZERO: Self = Self { kind: CounterKind::Zero, id: 0 }; + pub const ZERO: Self = Self { kind: CounterKind::Zero, id: 0 }; /// Constructs a new `Counter` of kind `CounterValueReference`. - pub(crate) fn counter_value_reference(counter_id: CounterId) -> Self { + pub fn counter_value_reference(counter_id: CounterId) -> Self { Self { kind: CounterKind::CounterValueReference, id: counter_id.as_u32() } } /// Constructs a new `Counter` of kind `Expression`. - pub(crate) fn expression(expression_id: ExpressionId) -> Self { + pub fn expression(expression_id: ExpressionId) -> Self { Self { kind: CounterKind::Expression, id: expression_id.as_u32() } } - pub(crate) fn from_term(term: CovTerm) -> Self { + pub fn from_term(term: CovTerm) -> Self { match term { CovTerm::Zero => Self::ZERO, CovTerm::Counter(id) => Self::counter_value_reference(id), @@ -57,7 +57,7 @@ impl Counter { /// Must match the layout of `LLVMRustCounterExprKind`. #[derive(Copy, Clone, Debug)] #[repr(C)] -pub(crate) enum ExprKind { +pub enum ExprKind { Subtract = 0, Add = 1, } @@ -67,19 +67,19 @@ pub(crate) enum ExprKind { /// Must match the layout of `LLVMRustCounterExpression`. #[derive(Copy, Clone, Debug)] #[repr(C)] -pub(crate) struct CounterExpression { - pub(crate) kind: ExprKind, - pub(crate) lhs: Counter, - pub(crate) rhs: Counter, +pub struct CounterExpression { + pub kind: ExprKind, + pub lhs: Counter, + pub rhs: Counter, } -pub(crate) mod mcdc { +pub mod mcdc { use rustc_middle::mir::coverage::{ConditionId, ConditionInfo, DecisionInfo}; /// Must match the layout of `LLVMRustMCDCDecisionParameters`. #[repr(C)] #[derive(Clone, Copy, Debug, Default)] - pub(crate) struct DecisionParameters { + pub struct DecisionParameters { bitmap_idx: u32, num_conditions: u16, } @@ -89,7 +89,7 @@ pub(crate) mod mcdc { /// Must match the layout of `LLVMRustMCDCBranchParameters`. #[repr(C)] #[derive(Clone, Copy, Debug, Default)] - pub(crate) struct BranchParameters { + pub struct BranchParameters { condition_id: LLVMConditionId, condition_ids: [LLVMConditionId; 2], } @@ -120,20 +120,20 @@ pub(crate) mod mcdc { /// Must match the layout of `LLVMRustCoverageSpan`. #[derive(Clone, Debug)] #[repr(C)] -pub(crate) struct CoverageSpan { +pub struct CoverageSpan { /// Local index into the function's local-to-global file ID table. /// The value at that index is itself an index into the coverage filename /// table in the CGU's `__llvm_covmap` section. - pub(crate) file_id: u32, + pub file_id: u32, /// 1-based starting line of the source code span. - pub(crate) start_line: u32, + pub start_line: u32, /// 1-based starting column of the source code span. - pub(crate) start_col: u32, + pub start_col: u32, /// 1-based ending line of the source code span. - pub(crate) end_line: u32, + pub end_line: u32, /// 1-based ending column of the source code span. High bit must be unset. - pub(crate) end_col: u32, + pub end_col: u32, } /// Holds tables of the various region types in one struct. @@ -144,17 +144,17 @@ pub(crate) struct CoverageSpan { /// Each field name has a `_regions` suffix for improved readability after /// exhaustive destructing, which ensures that all region types are handled. #[derive(Clone, Debug, Default)] -pub(crate) struct Regions { - pub(crate) code_regions: Vec, - pub(crate) expansion_regions: Vec, - pub(crate) branch_regions: Vec, - pub(crate) mcdc_branch_regions: Vec, - pub(crate) mcdc_decision_regions: Vec, +pub struct Regions { + pub code_regions: Vec, + pub expansion_regions: Vec, + pub branch_regions: Vec, + pub mcdc_branch_regions: Vec, + pub mcdc_decision_regions: Vec, } impl Regions { /// Returns true if none of this structure's tables contain any regions. - pub(crate) fn has_no_regions(&self) -> bool { + pub fn has_no_regions(&self) -> bool { let Self { code_regions, expansion_regions, @@ -174,42 +174,42 @@ impl Regions { /// Must match the layout of `LLVMRustCoverageCodeRegion`. #[derive(Clone, Debug)] #[repr(C)] -pub(crate) struct CodeRegion { - pub(crate) cov_span: CoverageSpan, - pub(crate) counter: Counter, +pub struct CodeRegion { + pub cov_span: CoverageSpan, + pub counter: Counter, } /// Must match the layout of `LLVMRustCoverageExpansionRegion`. #[derive(Clone, Debug)] #[repr(C)] -pub(crate) struct ExpansionRegion { - pub(crate) cov_span: CoverageSpan, - pub(crate) expanded_file_id: u32, +pub struct ExpansionRegion { + pub cov_span: CoverageSpan, + pub expanded_file_id: u32, } /// Must match the layout of `LLVMRustCoverageBranchRegion`. #[derive(Clone, Debug)] #[repr(C)] -pub(crate) struct BranchRegion { - pub(crate) cov_span: CoverageSpan, - pub(crate) true_counter: Counter, - pub(crate) false_counter: Counter, +pub struct BranchRegion { + pub cov_span: CoverageSpan, + pub true_counter: Counter, + pub false_counter: Counter, } /// Must match the layout of `LLVMRustCoverageMCDCBranchRegion`. #[derive(Clone, Debug)] #[repr(C)] -pub(crate) struct MCDCBranchRegion { - pub(crate) cov_span: CoverageSpan, - pub(crate) true_counter: Counter, - pub(crate) false_counter: Counter, - pub(crate) mcdc_branch_params: mcdc::BranchParameters, +pub struct MCDCBranchRegion { + pub cov_span: CoverageSpan, + pub true_counter: Counter, + pub false_counter: Counter, + pub mcdc_branch_params: mcdc::BranchParameters, } /// Must match the layout of `LLVMRustCoverageMCDCDecisionRegion`. #[derive(Clone, Debug)] #[repr(C)] -pub(crate) struct MCDCDecisionRegion { - pub(crate) cov_span: CoverageSpan, - pub(crate) mcdc_decision_params: mcdc::DecisionParameters, +pub struct MCDCDecisionRegion { + pub cov_span: CoverageSpan, + pub mcdc_decision_params: mcdc::DecisionParameters, } diff --git a/compiler/rustc_llvm/src/ffi/enzyme/mod.rs b/compiler/rustc_llvm/src/ffi/enzyme/mod.rs new file mode 100644 index 0000000000000..e2116a9a53e9d --- /dev/null +++ b/compiler/rustc_llvm/src/ffi/enzyme/mod.rs @@ -0,0 +1,136 @@ +#![allow(non_camel_case_types)] + +use libc::{c_char, c_uint}; + +use super::{AttributeKind, BasicBlock, Bool, Metadata, MetadataKindId, Module, Type, Value}; + +#[link(name = "llvm-wrapper", kind = "static")] +unsafe extern "C" { + // Enzyme + pub safe fn LLVMRustHasMetadata(I: &Value, KindID: MetadataKindId) -> bool; + pub fn LLVMRustEraseInstUntilInclusive(BB: &BasicBlock, I: &Value); + pub fn LLVMRustGetLastInstruction<'a>(BB: &BasicBlock) -> Option<&'a Value>; + pub fn LLVMRustDIGetInstMetadata(I: &Value) -> Option<&Metadata>; + pub fn LLVMRustEraseInstFromParent(V: &Value); + pub fn LLVMRustGetTerminator<'a>(B: &BasicBlock) -> &'a Value; + pub fn LLVMRustVerifyFunction(V: &Value, action: LLVMRustVerifierFailureAction) -> Bool; + pub fn LLVMRustHasAttributeAtIndex(V: &Value, i: c_uint, Kind: AttributeKind) -> bool; + pub fn LLVMRustGetArrayNumElements(Ty: &Type) -> u64; + pub fn LLVMRustHasFnAttribute(F: &Value, Name: *const c_char, NameLen: libc::size_t) -> bool; + pub fn LLVMRustRemoveFnAttribute(F: &Value, Name: *const c_char, NameLen: libc::size_t); + pub fn LLVMGetFirstFunction(M: &Module) -> Option<&Value>; + pub fn LLVMGetNextFunction(Fn: &Value) -> Option<&Value>; + pub fn LLVMRustRemoveEnumAttributeAtIndex(Fn: &Value, index: c_uint, kind: AttributeKind); +} + +unsafe extern "C" { + // Enzyme + pub fn LLVMDumpModule(M: &Module); + pub fn LLVMDumpValue(V: &Value); + pub fn LLVMGetFunctionCallConv(F: &Value) -> c_uint; + pub fn LLVMGetReturnType(T: &Type) -> &Type; + pub fn LLVMGetParams(Fnc: &Value, parms: *mut &Value); + pub fn LLVMGetNamedFunction(M: &Module, Name: *const c_char) -> Option<&Value>; +} + +#[repr(C)] +#[derive(Copy, Clone, PartialEq)] +pub enum LLVMRustVerifierFailureAction { + LLVMAbortProcessAction = 0, + LLVMPrintMessageAction = 1, + LLVMReturnStatusAction = 2, +} + +#[cfg(llvm_enzyme)] +pub use self::enzyme_ad::*; + +#[cfg(llvm_enzyme)] +pub mod enzyme_ad { + use libc::c_void; + unsafe extern "C" { + pub fn EnzymeSetCLBool(arg1: *mut ::std::os::raw::c_void, arg2: u8); + } + unsafe extern "C" { + static mut EnzymePrintPerf: c_void; + static mut EnzymePrintActivity: c_void; + static mut EnzymePrintType: c_void; + static mut EnzymePrint: c_void; + static mut EnzymeStrictAliasing: c_void; + static mut looseTypeAnalysis: c_void; + static mut EnzymeInline: c_void; + static mut RustTypeRules: c_void; + } + pub fn set_print_perf(print: bool) { + unsafe { + EnzymeSetCLBool(std::ptr::addr_of_mut!(EnzymePrintPerf), print as u8); + } + } + pub fn set_print_activity(print: bool) { + unsafe { + EnzymeSetCLBool(std::ptr::addr_of_mut!(EnzymePrintActivity), print as u8); + } + } + pub fn set_print_type(print: bool) { + unsafe { + EnzymeSetCLBool(std::ptr::addr_of_mut!(EnzymePrintType), print as u8); + } + } + pub fn set_print(print: bool) { + unsafe { + EnzymeSetCLBool(std::ptr::addr_of_mut!(EnzymePrint), print as u8); + } + } + pub fn set_strict_aliasing(strict: bool) { + unsafe { + EnzymeSetCLBool(std::ptr::addr_of_mut!(EnzymeStrictAliasing), strict as u8); + } + } + pub fn set_loose_types(loose: bool) { + unsafe { + EnzymeSetCLBool(std::ptr::addr_of_mut!(looseTypeAnalysis), loose as u8); + } + } + pub fn set_inline(val: bool) { + unsafe { + EnzymeSetCLBool(std::ptr::addr_of_mut!(EnzymeInline), val as u8); + } + } + pub fn set_rust_rules(val: bool) { + unsafe { + EnzymeSetCLBool(std::ptr::addr_of_mut!(RustTypeRules), val as u8); + } + } +} + +#[cfg(not(llvm_enzyme))] +pub use self::fallback_ad::*; + +#[cfg(not(llvm_enzyme))] +pub mod fallback_ad { + #![allow(unused_variables)] + + pub fn set_inline(val: bool) { + unimplemented!() + } + pub fn set_print_perf(print: bool) { + unimplemented!() + } + pub fn set_print_activity(print: bool) { + unimplemented!() + } + pub fn set_print_type(print: bool) { + unimplemented!() + } + pub fn set_print(print: bool) { + unimplemented!() + } + pub fn set_strict_aliasing(strict: bool) { + unimplemented!() + } + pub fn set_loose_types(loose: bool) { + unimplemented!() + } + pub fn set_rust_rules(val: bool) { + unimplemented!() + } +} diff --git a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs b/compiler/rustc_llvm/src/ffi/mod.rs similarity index 63% rename from compiler/rustc_codegen_llvm/src/llvm/ffi.rs rename to compiler/rustc_llvm/src/ffi/mod.rs index 91ada856d5977..dfac4af0f6215 100644 --- a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs +++ b/compiler/rustc_llvm/src/ffi/mod.rs @@ -19,24 +19,28 @@ use std::num::NonZero; use std::ptr; use bitflags::bitflags; +use debuginfo::{ + DIArray, DIBasicType, DIBuilder, DICompositeType, DIDerivedType, DIDescriptor, DIEnumerator, + DIFile, DIFlags, DIGlobalVariableExpression, DILocation, DISPFlags, DIScope, DISubprogram, + DISubrange, DITemplateTypeParameter, DIType, DIVariable, DebugEmissionKind, DebugNameTableKind, +}; use libc::{c_char, c_int, c_uchar, c_uint, c_ulonglong, c_void, size_t}; use rustc_macros::TryFromU32; use rustc_target::spec::SymbolVisibility; use super::RustString; -use super::debuginfo::{ - DIArray, DIBasicType, DIBuilder, DICompositeType, DIDerivedType, DIDescriptor, DIEnumerator, - DIFile, DIFlags, DIGlobalVariableExpression, DILocation, DISPFlags, DIScope, DISubprogram, - DISubrange, DITemplateTypeParameter, DIType, DIVariable, DebugEmissionKind, DebugNameTableKind, -}; -use crate::llvm; + +pub mod coverageinfo; +mod enzyme; + +pub use enzyme::*; /// In the LLVM-C API, boolean values are passed as `typedef int LLVMBool`, /// which has a different ABI from Rust or C++ `bool`. -pub(crate) type Bool = c_int; +pub type Bool = c_int; -pub(crate) const True: Bool = 1 as Bool; -pub(crate) const False: Bool = 0 as Bool; +pub const True: Bool = 1 as Bool; +pub const False: Bool = 0 as Bool; /// Wrapper for a raw enum value returned from LLVM's C APIs. /// @@ -45,7 +49,7 @@ pub(crate) const False: Bool = 0 as Bool; /// value and returns it. Instead, return this raw wrapper, then convert to the /// Rust-side enum explicitly. #[repr(transparent)] -pub(crate) struct RawEnum { +pub struct RawEnum { value: u32, /// We don't own or consume a `T`, but we can produce one. _rust_side_type: PhantomData T>, @@ -53,7 +57,7 @@ pub(crate) struct RawEnum { impl> RawEnum { #[track_caller] - pub(crate) fn to_rust(self) -> T + pub fn to_rust(self) -> T where T::Error: Debug, { @@ -64,8 +68,7 @@ impl> RawEnum { #[derive(Copy, Clone, PartialEq)] #[repr(C)] -#[allow(dead_code)] // Variants constructed by C++. -pub(crate) enum LLVMRustResult { +pub enum LLVMRustResult { Success, Failure, } @@ -84,7 +87,7 @@ pub(crate) enum LLVMRustResult { /// C++ API. #[derive(Copy, Clone, PartialEq)] #[repr(C)] -pub(crate) enum ModuleFlagMergeBehavior { +pub enum ModuleFlagMergeBehavior { Error = 1, Warning = 2, Require = 3, @@ -102,7 +105,7 @@ pub(crate) enum ModuleFlagMergeBehavior { /// See #[derive(Copy, Clone, PartialEq, Debug, TryFromU32)] #[repr(C)] -pub(crate) enum CallConv { +pub enum CallConv { CCallConv = 0, FastCallConv = 8, ColdCallConv = 9, @@ -127,7 +130,7 @@ pub(crate) enum CallConv { /// Must match the layout of `LLVMLinkage`. #[derive(Copy, Clone, PartialEq, TryFromU32)] #[repr(C)] -pub(crate) enum Linkage { +pub enum Linkage { ExternalLinkage = 0, AvailableExternallyLinkage = 1, LinkOnceAnyLinkage = 2, @@ -154,14 +157,14 @@ pub(crate) enum Linkage { /// Must match the layout of `LLVMVisibility`. #[repr(C)] #[derive(Copy, Clone, PartialEq, TryFromU32)] -pub(crate) enum Visibility { +pub enum Visibility { Default = 0, Hidden = 1, Protected = 2, } impl Visibility { - pub(crate) fn from_generic(visibility: SymbolVisibility) -> Self { + pub fn from_generic(visibility: SymbolVisibility) -> Self { match visibility { SymbolVisibility::Hidden => Visibility::Hidden, SymbolVisibility::Protected => Visibility::Protected, @@ -172,9 +175,8 @@ impl Visibility { /// LLVMUnnamedAddr #[repr(C)] -pub(crate) enum UnnamedAddr { +pub enum UnnamedAddr { No, - #[expect(dead_code)] Local, Global, } @@ -182,21 +184,18 @@ pub(crate) enum UnnamedAddr { /// LLVMDLLStorageClass #[derive(Copy, Clone)] #[repr(C)] -pub(crate) enum DLLStorageClass { - #[allow(dead_code)] +pub enum DLLStorageClass { Default = 0, DllImport = 1, // Function to be imported from DLL. - #[allow(dead_code)] DllExport = 2, // Function to be accessible from DLL. } /// Must match the layout of `LLVMRustAttributeKind`. -/// Semantically a subset of the C++ enum llvm::Attribute::AttrKind, +/// Semantically a subset of the C++ enum super::Attribute::AttrKind, /// though it is not ABI compatible (since it's a C++ enum) #[repr(C)] #[derive(Copy, Clone, Debug)] -#[expect(dead_code, reason = "Some variants are unused, but are kept to match the C++")] -pub(crate) enum AttributeKind { +pub enum AttributeKind { AlwaysInline = 0, ByVal = 1, Cold = 2, @@ -244,7 +243,7 @@ pub(crate) enum AttributeKind { /// LLVMIntPredicate #[derive(Copy, Clone)] #[repr(C)] -pub(crate) enum IntPredicate { +pub enum IntPredicate { IntEQ = 32, IntNE = 33, IntUGT = 34, @@ -258,7 +257,7 @@ pub(crate) enum IntPredicate { } impl IntPredicate { - pub(crate) fn from_generic(intpre: rustc_codegen_ssa::common::IntPredicate) -> Self { + pub fn from_generic(intpre: rustc_codegen_ssa::common::IntPredicate) -> Self { use rustc_codegen_ssa::common::IntPredicate as Common; match intpre { Common::IntEQ => Self::IntEQ, @@ -278,7 +277,7 @@ impl IntPredicate { /// LLVMRealPredicate #[derive(Copy, Clone)] #[repr(C)] -pub(crate) enum RealPredicate { +pub enum RealPredicate { RealPredicateFalse = 0, RealOEQ = 1, RealOGT = 2, @@ -298,7 +297,7 @@ pub(crate) enum RealPredicate { } impl RealPredicate { - pub(crate) fn from_generic(realp: rustc_codegen_ssa::common::RealPredicate) -> Self { + pub fn from_generic(realp: rustc_codegen_ssa::common::RealPredicate) -> Self { use rustc_codegen_ssa::common::RealPredicate as Common; match realp { Common::RealPredicateFalse => Self::RealPredicateFalse, @@ -324,8 +323,7 @@ impl RealPredicate { /// LLVMTypeKind #[derive(Copy, Clone, PartialEq, Debug)] #[repr(C)] -#[expect(dead_code, reason = "Some variants are unused, but are kept to match LLVM-C")] -pub(crate) enum TypeKind { +pub enum TypeKind { Void = 0, Half = 1, Float = 2, @@ -348,7 +346,7 @@ pub(crate) enum TypeKind { } impl TypeKind { - pub(crate) fn to_generic(self) -> rustc_codegen_ssa::common::TypeKind { + pub fn to_generic(self) -> rustc_codegen_ssa::common::TypeKind { use rustc_codegen_ssa::common::TypeKind as Common; match self { Self::Void => Common::Void, @@ -377,7 +375,7 @@ impl TypeKind { /// LLVMAtomicRmwBinOp #[derive(Copy, Clone)] #[repr(C)] -pub(crate) enum AtomicRmwBinOp { +pub enum AtomicRmwBinOp { AtomicXchg = 0, AtomicAdd = 1, AtomicSub = 2, @@ -392,7 +390,7 @@ pub(crate) enum AtomicRmwBinOp { } impl AtomicRmwBinOp { - pub(crate) fn from_generic(op: rustc_codegen_ssa::common::AtomicRmwBinOp) -> Self { + pub fn from_generic(op: rustc_codegen_ssa::common::AtomicRmwBinOp) -> Self { use rustc_codegen_ssa::common::AtomicRmwBinOp as Common; match op { Common::AtomicXchg => Self::AtomicXchg, @@ -413,10 +411,8 @@ impl AtomicRmwBinOp { /// LLVMAtomicOrdering #[derive(Copy, Clone)] #[repr(C)] -pub(crate) enum AtomicOrdering { - #[allow(dead_code)] +pub enum AtomicOrdering { NotAtomic = 0, - #[allow(dead_code)] Unordered = 1, Monotonic = 2, // Consume = 3, // Not specified yet. @@ -427,7 +423,7 @@ pub(crate) enum AtomicOrdering { } impl AtomicOrdering { - pub(crate) fn from_generic(ao: rustc_middle::ty::AtomicOrdering) -> Self { + pub fn from_generic(ao: rustc_middle::ty::AtomicOrdering) -> Self { use rustc_middle::ty::AtomicOrdering as Common; match ao { Common::Relaxed => Self::Monotonic, @@ -442,7 +438,7 @@ impl AtomicOrdering { /// LLVMRustFileType #[derive(Copy, Clone)] #[repr(C)] -pub(crate) enum FileType { +pub enum FileType { AssemblyFile, ObjectFile, } @@ -450,8 +446,7 @@ pub(crate) enum FileType { /// LLVMMetadataType #[derive(Copy, Clone)] #[repr(C)] -#[expect(dead_code, reason = "Some variants are unused, but are kept to match LLVM-C")] -pub(crate) enum MetadataType { +pub enum MetadataType { MD_dbg = 0, MD_tbaa = 1, MD_prof = 2, @@ -475,7 +470,7 @@ pub(crate) enum MetadataType { /// Must match the layout of `LLVMInlineAsmDialect`. #[derive(Copy, Clone, PartialEq)] #[repr(C)] -pub(crate) enum AsmDialect { +pub enum AsmDialect { Att, Intel, } @@ -483,7 +478,7 @@ pub(crate) enum AsmDialect { /// LLVMRustCodeGenOptLevel #[derive(Copy, Clone, PartialEq)] #[repr(C)] -pub(crate) enum CodeGenOptLevel { +pub enum CodeGenOptLevel { None, Less, Default, @@ -492,7 +487,7 @@ pub(crate) enum CodeGenOptLevel { /// LLVMRustPassBuilderOptLevel #[repr(C)] -pub(crate) enum PassBuilderOptLevel { +pub enum PassBuilderOptLevel { O0, O1, O2, @@ -504,7 +499,7 @@ pub(crate) enum PassBuilderOptLevel { /// LLVMRustOptStage #[derive(PartialEq)] #[repr(C)] -pub(crate) enum OptStage { +pub enum OptStage { PreLinkNoLTO, PreLinkThinLTO, PreLinkFatLTO, @@ -514,7 +509,7 @@ pub(crate) enum OptStage { /// LLVMRustSanitizerOptions #[repr(C)] -pub(crate) struct SanitizerOptions { +pub struct SanitizerOptions { pub sanitize_address: bool, pub sanitize_address_recover: bool, pub sanitize_cfi: bool, @@ -535,7 +530,7 @@ pub(crate) struct SanitizerOptions { /// LLVMRustRelocModel #[derive(Copy, Clone, PartialEq)] #[repr(C)] -pub(crate) enum RelocModel { +pub enum RelocModel { Static, PIC, DynamicNoPic, @@ -547,7 +542,7 @@ pub(crate) enum RelocModel { /// LLVMRustFloatABI #[derive(Copy, Clone, PartialEq)] #[repr(C)] -pub(crate) enum FloatAbi { +pub enum FloatAbi { Default, Soft, Hard, @@ -556,7 +551,7 @@ pub(crate) enum FloatAbi { /// LLVMRustCodeModel #[derive(Copy, Clone)] #[repr(C)] -pub(crate) enum CodeModel { +pub enum CodeModel { Tiny, Small, Kernel, @@ -568,8 +563,7 @@ pub(crate) enum CodeModel { /// LLVMRustDiagnosticKind #[derive(Copy, Clone)] #[repr(C)] -#[allow(dead_code)] // Variants constructed by C++. -pub(crate) enum DiagnosticKind { +pub enum DiagnosticKind { Other, InlineAsm, StackSize, @@ -591,8 +585,7 @@ pub(crate) enum DiagnosticKind { /// LLVMRustDiagnosticLevel #[derive(Copy, Clone)] #[repr(C)] -#[allow(dead_code)] // Variants constructed by C++. -pub(crate) enum DiagnosticLevel { +pub enum DiagnosticLevel { Error, Warning, Note, @@ -602,7 +595,7 @@ pub(crate) enum DiagnosticLevel { /// LLVMRustArchiveKind #[derive(Copy, Clone)] #[repr(C)] -pub(crate) enum ArchiveKind { +pub enum ArchiveKind { K_GNU, K_BSD, K_DARWIN, @@ -612,15 +605,15 @@ pub(crate) enum ArchiveKind { unsafe extern "C" { // LLVMRustThinLTOData - pub(crate) type ThinLTOData; + pub type ThinLTOData; // LLVMRustThinLTOBuffer - pub(crate) type ThinLTOBuffer; + pub type ThinLTOBuffer; } /// LLVMRustThinLTOModule #[repr(C)] -pub(crate) struct ThinLTOModule { +pub struct ThinLTOModule { pub identifier: *const c_char, pub data: *const u8, pub len: usize, @@ -629,8 +622,7 @@ pub(crate) struct ThinLTOModule { /// LLVMThreadLocalMode #[derive(Copy, Clone)] #[repr(C)] -pub(crate) enum ThreadLocalMode { - #[expect(dead_code)] +pub enum ThreadLocalMode { NotThreadLocal, GeneralDynamic, LocalDynamic, @@ -641,7 +633,7 @@ pub(crate) enum ThreadLocalMode { /// LLVMRustChecksumKind #[derive(Copy, Clone)] #[repr(C)] -pub(crate) enum ChecksumKind { +pub enum ChecksumKind { None, MD5, SHA1, @@ -651,7 +643,7 @@ pub(crate) enum ChecksumKind { /// LLVMRustMemoryEffects #[derive(Copy, Clone)] #[repr(C)] -pub(crate) enum MemoryEffects { +pub enum MemoryEffects { None, ReadOnly, InaccessibleMemOnly, @@ -660,8 +652,7 @@ pub(crate) enum MemoryEffects { /// LLVMOpcode #[derive(Copy, Clone, PartialEq, Eq)] #[repr(C)] -#[expect(dead_code, reason = "Some variants are unused, but are kept to match LLVM-C")] -pub(crate) enum Opcode { +pub enum Opcode { Ret = 1, Br = 2, Switch = 3, @@ -742,54 +733,53 @@ struct InvariantOpaque<'a> { // Opaque pointer types unsafe extern "C" { - pub(crate) type Module; - pub(crate) type Context; - pub(crate) type Type; - pub(crate) type Value; - pub(crate) type ConstantInt; - pub(crate) type Attribute; - pub(crate) type Metadata; - pub(crate) type BasicBlock; - pub(crate) type Comdat; + pub type Module; + pub type Context; + pub type Type; + pub type Value; + pub type ConstantInt; + pub type Attribute; + pub type Metadata; + pub type BasicBlock; + pub type Comdat; } #[repr(C)] -pub(crate) struct Builder<'a>(InvariantOpaque<'a>); +pub struct Builder<'a>(InvariantOpaque<'a>); #[repr(C)] -pub(crate) struct PassManager<'a>(InvariantOpaque<'a>); +pub struct PassManager<'a>(InvariantOpaque<'a>); unsafe extern "C" { pub type TargetMachine; - pub(crate) type Archive; + pub type Archive; } #[repr(C)] -pub(crate) struct ArchiveIterator<'a>(InvariantOpaque<'a>); +pub struct ArchiveIterator<'a>(InvariantOpaque<'a>); #[repr(C)] -pub(crate) struct ArchiveChild<'a>(InvariantOpaque<'a>); +pub struct ArchiveChild<'a>(InvariantOpaque<'a>); unsafe extern "C" { - pub(crate) type Twine; - pub(crate) type DiagnosticInfo; - pub(crate) type SMDiagnostic; + pub type Twine; + pub type DiagnosticInfo; + pub type SMDiagnostic; } #[repr(C)] -pub(crate) struct RustArchiveMember<'a>(InvariantOpaque<'a>); +pub struct RustArchiveMember<'a>(InvariantOpaque<'a>); /// Opaque pointee of `LLVMOperandBundleRef`. #[repr(C)] -pub(crate) struct OperandBundle<'a>(InvariantOpaque<'a>); +pub struct OperandBundle<'a>(InvariantOpaque<'a>); #[repr(C)] -pub(crate) struct Linker<'a>(InvariantOpaque<'a>); +pub struct Linker<'a>(InvariantOpaque<'a>); unsafe extern "C" { - pub(crate) type DiagnosticHandler; + pub type DiagnosticHandler; } -pub(crate) type DiagnosticHandlerTy = unsafe extern "C" fn(&DiagnosticInfo, *mut c_void); +pub type DiagnosticHandlerTy = unsafe extern "C" fn(&DiagnosticInfo, *mut c_void); -pub(crate) mod debuginfo { +pub mod debuginfo { use std::ptr; use bitflags::bitflags; - use super::{InvariantOpaque, Metadata}; - use crate::llvm::{self, Module}; + use super::{InvariantOpaque, Metadata, Module}; /// Opaque target type for references to an LLVM debuginfo builder. /// @@ -800,23 +790,23 @@ pub(crate) mod debuginfo { /// builder reference typically has a shorter lifetime than the LLVM /// session (`'ll`) that it participates in. #[repr(C)] - pub(crate) struct DIBuilder<'ll>(InvariantOpaque<'ll>); + pub struct DIBuilder<'ll>(InvariantOpaque<'ll>); /// Owning pointer to a `DIBuilder<'ll>` that will dispose of the builder /// when dropped. Use `.as_ref()` to get the underlying `&DIBuilder` /// needed for debuginfo FFI calls. - pub(crate) struct DIBuilderBox<'ll> { + pub struct DIBuilderBox<'ll> { raw: ptr::NonNull>, } impl<'ll> DIBuilderBox<'ll> { - pub(crate) fn new(llmod: &'ll Module) -> Self { - let raw = unsafe { llvm::LLVMCreateDIBuilder(llmod) }; + pub fn new(llmod: &'ll Module) -> Self { + let raw = unsafe { super::LLVMCreateDIBuilder(llmod) }; let raw = ptr::NonNull::new(raw).unwrap(); Self { raw } } - pub(crate) fn as_ref(&self) -> &DIBuilder<'ll> { + pub fn as_ref(&self) -> &DIBuilder<'ll> { // SAFETY: This is an owning pointer, so `&DIBuilder` is valid // for as long as `&self` is. unsafe { self.raw.as_ref() } @@ -825,26 +815,26 @@ pub(crate) mod debuginfo { impl<'ll> Drop for DIBuilderBox<'ll> { fn drop(&mut self) { - unsafe { llvm::LLVMDisposeDIBuilder(self.raw) }; + unsafe { super::LLVMDisposeDIBuilder(self.raw) }; } } - pub(crate) type DIDescriptor = Metadata; - pub(crate) type DILocation = Metadata; - pub(crate) type DIScope = DIDescriptor; - pub(crate) type DIFile = DIScope; - pub(crate) type DILexicalBlock = DIScope; - pub(crate) type DISubprogram = DIScope; - pub(crate) type DIType = DIDescriptor; - pub(crate) type DIBasicType = DIType; - pub(crate) type DIDerivedType = DIType; - pub(crate) type DICompositeType = DIDerivedType; - pub(crate) type DIVariable = DIDescriptor; - pub(crate) type DIGlobalVariableExpression = DIDescriptor; - pub(crate) type DIArray = DIDescriptor; - pub(crate) type DISubrange = DIDescriptor; - pub(crate) type DIEnumerator = DIDescriptor; - pub(crate) type DITemplateTypeParameter = DIDescriptor; + pub type DIDescriptor = Metadata; + pub type DILocation = Metadata; + pub type DIScope = DIDescriptor; + pub type DIFile = DIScope; + pub type DILexicalBlock = DIScope; + pub type DISubprogram = DIScope; + pub type DIType = DIDescriptor; + pub type DIBasicType = DIType; + pub type DIDerivedType = DIType; + pub type DICompositeType = DIDerivedType; + pub type DIVariable = DIDescriptor; + pub type DIGlobalVariableExpression = DIDescriptor; + pub type DIArray = DIDescriptor; + pub type DISubrange = DIDescriptor; + pub type DIEnumerator = DIDescriptor; + pub type DITemplateTypeParameter = DIDescriptor; bitflags! { /// Must match the layout of `LLVMDIFlags` in the LLVM-C API. @@ -853,7 +843,7 @@ pub(crate) mod debuginfo { /// assertions in `RustWrapper.cpp` used by `fromRust(LLVMDIFlags)`. #[repr(transparent)] #[derive(Clone, Copy, Default)] - pub(crate) struct DIFlags: u32 { + pub struct DIFlags: u32 { const FlagZero = 0; const FlagPrivate = 1; const FlagProtected = 2; @@ -893,7 +883,7 @@ pub(crate) mod debuginfo { bitflags! { #[repr(transparent)] #[derive(Clone, Copy, Default)] - pub(crate) struct DISPFlags: u32 { + pub struct DISPFlags: u32 { const SPFlagZero = 0; const SPFlagVirtual = 1; const SPFlagPureVirtual = 2; @@ -907,7 +897,7 @@ pub(crate) mod debuginfo { /// LLVMRustDebugEmissionKind #[derive(Copy, Clone)] #[repr(C)] - pub(crate) enum DebugEmissionKind { + pub enum DebugEmissionKind { NoDebug, FullDebug, LineTablesOnly, @@ -915,7 +905,7 @@ pub(crate) mod debuginfo { } impl DebugEmissionKind { - pub(crate) fn from_generic(kind: rustc_session::config::DebugInfo) -> Self { + pub fn from_generic(kind: rustc_session::config::DebugInfo) -> Self { // We should be setting LLVM's emission kind to `LineTablesOnly` if // we are compiling with "limited" debuginfo. However, some of the // existing tools relied on slightly more debuginfo being generated than @@ -939,9 +929,8 @@ pub(crate) mod debuginfo { /// LLVMRustDebugNameTableKind #[derive(Clone, Copy)] #[repr(C)] - pub(crate) enum DebugNameTableKind { + pub enum DebugNameTableKind { Default, - #[expect(dead_code)] Gnu, None, } @@ -951,7 +940,7 @@ pub(crate) mod debuginfo { bitflags! { #[repr(transparent)] #[derive(Default)] - pub(crate) struct AllocKindFlags : u64 { + pub struct AllocKindFlags : u64 { const Unknown = 0; const Alloc = 1; const Realloc = 1 << 1; @@ -974,20 +963,19 @@ bitflags! { } unsafe extern "C" { - pub(crate) type ModuleBuffer; + pub type ModuleBuffer; } -pub(crate) type SelfProfileBeforePassCallback = +pub type SelfProfileBeforePassCallback = unsafe extern "C" fn(*mut c_void, *const c_char, *const c_char); -pub(crate) type SelfProfileAfterPassCallback = unsafe extern "C" fn(*mut c_void); +pub type SelfProfileAfterPassCallback = unsafe extern "C" fn(*mut c_void); -pub(crate) type GetSymbolsCallback = - unsafe extern "C" fn(*mut c_void, *const c_char) -> *mut c_void; -pub(crate) type GetSymbolsErrorCallback = unsafe extern "C" fn(*const c_char) -> *mut c_void; +pub type GetSymbolsCallback = unsafe extern "C" fn(*mut c_void, *const c_char) -> *mut c_void; +pub type GetSymbolsErrorCallback = unsafe extern "C" fn(*const c_char) -> *mut c_void; #[derive(Copy, Clone)] #[repr(transparent)] -pub(crate) struct MetadataKindId(c_uint); +pub struct MetadataKindId(c_uint); impl From for MetadataKindId { fn from(value: MetadataType) -> Self { @@ -997,72 +985,69 @@ impl From for MetadataKindId { unsafe extern "C" { // Create and destroy contexts. - pub(crate) fn LLVMContextDispose(C: &'static mut Context); - pub(crate) fn LLVMGetMDKindIDInContext( + pub fn LLVMContextDispose(C: &'static mut Context); + pub fn LLVMGetMDKindIDInContext( C: &Context, Name: *const c_char, SLen: c_uint, ) -> MetadataKindId; // Create modules. - pub(crate) fn LLVMModuleCreateWithNameInContext( - ModuleID: *const c_char, - C: &Context, - ) -> &Module; - pub(crate) fn LLVMCloneModule(M: &Module) -> &Module; + pub fn LLVMModuleCreateWithNameInContext(ModuleID: *const c_char, C: &Context) -> &Module; + pub fn LLVMCloneModule(M: &Module) -> &Module; /// Data layout. See Module::getDataLayout. - pub(crate) fn LLVMGetDataLayoutStr(M: &Module) -> *const c_char; - pub(crate) fn LLVMSetDataLayout(M: &Module, Triple: *const c_char); + pub fn LLVMGetDataLayoutStr(M: &Module) -> *const c_char; + pub fn LLVMSetDataLayout(M: &Module, Triple: *const c_char); /// Append inline assembly to a module. See `Module::appendModuleInlineAsm`. - pub(crate) fn LLVMAppendModuleInlineAsm( + pub fn LLVMAppendModuleInlineAsm( M: &Module, Asm: *const c_uchar, // See "PTR_LEN_STR". Len: size_t, ); /// Create the specified uniqued inline asm string. See `InlineAsm::get()`. - pub(crate) fn LLVMGetInlineAsm<'ll>( + pub fn LLVMGetInlineAsm<'ll>( Ty: &'ll Type, AsmString: *const c_uchar, // See "PTR_LEN_STR". AsmStringSize: size_t, Constraints: *const c_uchar, // See "PTR_LEN_STR". ConstraintsSize: size_t, - HasSideEffects: llvm::Bool, - IsAlignStack: llvm::Bool, + HasSideEffects: Bool, + IsAlignStack: Bool, Dialect: AsmDialect, - CanThrow: llvm::Bool, + CanThrow: Bool, ) -> &'ll Value; // Operations on integer types - pub(crate) fn LLVMInt1TypeInContext(C: &Context) -> &Type; - pub(crate) fn LLVMInt8TypeInContext(C: &Context) -> &Type; - pub(crate) fn LLVMInt16TypeInContext(C: &Context) -> &Type; - pub(crate) fn LLVMInt32TypeInContext(C: &Context) -> &Type; - pub(crate) fn LLVMInt64TypeInContext(C: &Context) -> &Type; - pub(crate) fn LLVMIntTypeInContext(C: &Context, NumBits: c_uint) -> &Type; + pub fn LLVMInt1TypeInContext(C: &Context) -> &Type; + pub fn LLVMInt8TypeInContext(C: &Context) -> &Type; + pub fn LLVMInt16TypeInContext(C: &Context) -> &Type; + pub fn LLVMInt32TypeInContext(C: &Context) -> &Type; + pub fn LLVMInt64TypeInContext(C: &Context) -> &Type; + pub fn LLVMIntTypeInContext(C: &Context, NumBits: c_uint) -> &Type; - pub(crate) fn LLVMGetIntTypeWidth(IntegerTy: &Type) -> c_uint; + pub fn LLVMGetIntTypeWidth(IntegerTy: &Type) -> c_uint; // Operations on real types - pub(crate) fn LLVMHalfTypeInContext(C: &Context) -> &Type; - pub(crate) fn LLVMFloatTypeInContext(C: &Context) -> &Type; - pub(crate) fn LLVMDoubleTypeInContext(C: &Context) -> &Type; - pub(crate) fn LLVMFP128TypeInContext(C: &Context) -> &Type; + pub fn LLVMHalfTypeInContext(C: &Context) -> &Type; + pub fn LLVMFloatTypeInContext(C: &Context) -> &Type; + pub fn LLVMDoubleTypeInContext(C: &Context) -> &Type; + pub fn LLVMFP128TypeInContext(C: &Context) -> &Type; // Operations on function types - pub(crate) fn LLVMFunctionType<'a>( + pub fn LLVMFunctionType<'a>( ReturnType: &'a Type, ParamTypes: *const &'a Type, ParamCount: c_uint, IsVarArg: Bool, ) -> &'a Type; - pub(crate) fn LLVMCountParamTypes(FunctionTy: &Type) -> c_uint; - pub(crate) fn LLVMGetParamTypes<'a>(FunctionTy: &'a Type, Dest: *mut &'a Type); + pub fn LLVMCountParamTypes(FunctionTy: &Type) -> c_uint; + pub fn LLVMGetParamTypes<'a>(FunctionTy: &'a Type, Dest: *mut &'a Type); // Operations on struct types - pub(crate) fn LLVMStructTypeInContext<'a>( + pub fn LLVMStructTypeInContext<'a>( C: &'a Context, ElementTypes: *const &'a Type, ElementCount: c_uint, @@ -1070,120 +1055,108 @@ unsafe extern "C" { ) -> &'a Type; // Operations on array, pointer, and vector types (sequence types) - pub(crate) fn LLVMPointerTypeInContext(C: &Context, AddressSpace: c_uint) -> &Type; - pub(crate) fn LLVMVectorType(ElementType: &Type, ElementCount: c_uint) -> &Type; + pub fn LLVMPointerTypeInContext(C: &Context, AddressSpace: c_uint) -> &Type; + pub fn LLVMVectorType(ElementType: &Type, ElementCount: c_uint) -> &Type; - pub(crate) fn LLVMGetElementType(Ty: &Type) -> &Type; - pub(crate) fn LLVMGetVectorSize(VectorTy: &Type) -> c_uint; + pub fn LLVMGetElementType(Ty: &Type) -> &Type; + pub fn LLVMGetVectorSize(VectorTy: &Type) -> c_uint; // Operations on other types - pub(crate) fn LLVMVoidTypeInContext(C: &Context) -> &Type; + pub fn LLVMVoidTypeInContext(C: &Context) -> &Type; // Operations on all values - pub(crate) fn LLVMTypeOf(Val: &Value) -> &Type; - pub(crate) fn LLVMGetValueName2(Val: &Value, Length: *mut size_t) -> *const c_char; - pub(crate) fn LLVMSetValueName2(Val: &Value, Name: *const c_char, NameLen: size_t); - pub(crate) fn LLVMReplaceAllUsesWith<'a>(OldVal: &'a Value, NewVal: &'a Value); - pub(crate) safe fn LLVMSetMetadata<'a>(Val: &'a Value, KindID: MetadataKindId, Node: &'a Value); - pub(crate) fn LLVMGlobalSetMetadata<'a>(Val: &'a Value, KindID: c_uint, Metadata: &'a Metadata); - pub(crate) safe fn LLVMValueAsMetadata(Node: &Value) -> &Metadata; + pub fn LLVMTypeOf(Val: &Value) -> &Type; + pub fn LLVMGetValueName2(Val: &Value, Length: *mut size_t) -> *const c_char; + pub fn LLVMSetValueName2(Val: &Value, Name: *const c_char, NameLen: size_t); + pub fn LLVMReplaceAllUsesWith<'a>(OldVal: &'a Value, NewVal: &'a Value); + pub safe fn LLVMSetMetadata<'a>(Val: &'a Value, KindID: MetadataKindId, Node: &'a Value); + pub fn LLVMGlobalSetMetadata<'a>(Val: &'a Value, KindID: c_uint, Metadata: &'a Metadata); + pub safe fn LLVMValueAsMetadata(Node: &Value) -> &Metadata; // Operations on constants of any type - pub(crate) fn LLVMConstNull(Ty: &Type) -> &Value; - pub(crate) fn LLVMGetUndef(Ty: &Type) -> &Value; - pub(crate) fn LLVMGetPoison(Ty: &Type) -> &Value; + pub fn LLVMConstNull(Ty: &Type) -> &Value; + pub fn LLVMGetUndef(Ty: &Type) -> &Value; + pub fn LLVMGetPoison(Ty: &Type) -> &Value; // Operations on metadata - pub(crate) fn LLVMMDStringInContext2( - C: &Context, - Str: *const c_char, - SLen: size_t, - ) -> &Metadata; - pub(crate) fn LLVMMDNodeInContext2<'a>( + pub fn LLVMMDStringInContext2(C: &Context, Str: *const c_char, SLen: size_t) -> &Metadata; + pub fn LLVMMDNodeInContext2<'a>( C: &'a Context, Vals: *const &'a Metadata, Count: size_t, ) -> &'a Metadata; - pub(crate) fn LLVMAddNamedMetadataOperand<'a>( - M: &'a Module, - Name: *const c_char, - Val: &'a Value, - ); + pub fn LLVMAddNamedMetadataOperand<'a>(M: &'a Module, Name: *const c_char, Val: &'a Value); // Operations on scalar constants - pub(crate) fn LLVMConstInt(IntTy: &Type, N: c_ulonglong, SignExtend: Bool) -> &Value; - pub(crate) fn LLVMConstIntOfArbitraryPrecision( - IntTy: &Type, - Wn: c_uint, - Ws: *const u64, - ) -> &Value; - pub(crate) fn LLVMConstReal(RealTy: &Type, N: f64) -> &Value; + pub fn LLVMConstInt(IntTy: &Type, N: c_ulonglong, SignExtend: Bool) -> &Value; + pub fn LLVMConstIntOfArbitraryPrecision(IntTy: &Type, Wn: c_uint, Ws: *const u64) -> &Value; + pub fn LLVMConstReal(RealTy: &Type, N: f64) -> &Value; // Operations on composite constants - pub(crate) fn LLVMConstArray2<'a>( + pub fn LLVMConstArray2<'a>( ElementTy: &'a Type, ConstantVals: *const &'a Value, Length: u64, ) -> &'a Value; - pub(crate) fn LLVMArrayType2(ElementType: &Type, ElementCount: u64) -> &Type; - pub(crate) fn LLVMConstStringInContext2( + pub fn LLVMArrayType2(ElementType: &Type, ElementCount: u64) -> &Type; + pub fn LLVMConstStringInContext2( C: &Context, Str: *const c_char, Length: size_t, DontNullTerminate: Bool, ) -> &Value; - pub(crate) fn LLVMConstStructInContext<'a>( + pub fn LLVMConstStructInContext<'a>( C: &'a Context, ConstantVals: *const &'a Value, Count: c_uint, Packed: Bool, ) -> &'a Value; - pub(crate) fn LLVMConstVector(ScalarConstantVals: *const &Value, Size: c_uint) -> &Value; + pub fn LLVMConstVector(ScalarConstantVals: *const &Value, Size: c_uint) -> &Value; // Constant expressions - pub(crate) fn LLVMConstInBoundsGEP2<'a>( + pub fn LLVMConstInBoundsGEP2<'a>( ty: &'a Type, ConstantVal: &'a Value, ConstantIndices: *const &'a Value, NumIndices: c_uint, ) -> &'a Value; - pub(crate) fn LLVMConstPtrToInt<'a>(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value; - pub(crate) fn LLVMConstIntToPtr<'a>(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value; - pub(crate) fn LLVMConstBitCast<'a>(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value; - pub(crate) fn LLVMConstPointerCast<'a>(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value; - pub(crate) fn LLVMGetAggregateElement(ConstantVal: &Value, Idx: c_uint) -> Option<&Value>; - pub(crate) fn LLVMGetConstOpcode(ConstantVal: &Value) -> Opcode; - pub(crate) fn LLVMIsAConstantExpr(Val: &Value) -> Option<&Value>; + pub fn LLVMConstPtrToInt<'a>(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value; + pub fn LLVMConstIntToPtr<'a>(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value; + pub fn LLVMConstBitCast<'a>(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value; + pub fn LLVMConstPointerCast<'a>(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value; + pub fn LLVMGetAggregateElement(ConstantVal: &Value, Idx: c_uint) -> Option<&Value>; + pub fn LLVMGetConstOpcode(ConstantVal: &Value) -> Opcode; + pub fn LLVMIsAConstantExpr(Val: &Value) -> Option<&Value>; // Operations on global variables, functions, and aliases (globals) - pub(crate) fn LLVMIsDeclaration(Global: &Value) -> Bool; - pub(crate) fn LLVMGetLinkage(Global: &Value) -> RawEnum; - pub(crate) fn LLVMSetLinkage(Global: &Value, RustLinkage: Linkage); - pub(crate) fn LLVMSetSection(Global: &Value, Section: *const c_char); - pub(crate) fn LLVMGetVisibility(Global: &Value) -> RawEnum; - pub(crate) fn LLVMSetVisibility(Global: &Value, Viz: Visibility); - pub(crate) fn LLVMGetAlignment(Global: &Value) -> c_uint; - pub(crate) fn LLVMSetAlignment(Global: &Value, Bytes: c_uint); - pub(crate) fn LLVMSetDLLStorageClass(V: &Value, C: DLLStorageClass); - pub(crate) fn LLVMGlobalGetValueType(Global: &Value) -> &Type; + pub fn LLVMIsDeclaration(Global: &Value) -> Bool; + pub fn LLVMGetLinkage(Global: &Value) -> RawEnum; + pub fn LLVMSetLinkage(Global: &Value, RustLinkage: Linkage); + pub fn LLVMSetSection(Global: &Value, Section: *const c_char); + pub fn LLVMGetVisibility(Global: &Value) -> RawEnum; + pub fn LLVMSetVisibility(Global: &Value, Viz: Visibility); + pub fn LLVMGetAlignment(Global: &Value) -> c_uint; + pub fn LLVMSetAlignment(Global: &Value, Bytes: c_uint); + pub fn LLVMSetDLLStorageClass(V: &Value, C: DLLStorageClass); + pub fn LLVMGlobalGetValueType(Global: &Value) -> &Type; // Operations on global variables - pub(crate) fn LLVMIsAGlobalVariable(GlobalVar: &Value) -> Option<&Value>; - pub(crate) fn LLVMAddGlobal<'a>(M: &'a Module, Ty: &'a Type, Name: *const c_char) -> &'a Value; - pub(crate) fn LLVMGetNamedGlobal(M: &Module, Name: *const c_char) -> Option<&Value>; - pub(crate) fn LLVMGetFirstGlobal(M: &Module) -> Option<&Value>; - pub(crate) fn LLVMGetNextGlobal(GlobalVar: &Value) -> Option<&Value>; - pub(crate) fn LLVMDeleteGlobal(GlobalVar: &Value); - pub(crate) fn LLVMGetInitializer(GlobalVar: &Value) -> Option<&Value>; - pub(crate) fn LLVMSetInitializer<'a>(GlobalVar: &'a Value, ConstantVal: &'a Value); - pub(crate) fn LLVMIsThreadLocal(GlobalVar: &Value) -> Bool; - pub(crate) fn LLVMSetThreadLocalMode(GlobalVar: &Value, Mode: ThreadLocalMode); - pub(crate) fn LLVMIsGlobalConstant(GlobalVar: &Value) -> Bool; - pub(crate) fn LLVMSetGlobalConstant(GlobalVar: &Value, IsConstant: Bool); - pub(crate) safe fn LLVMSetTailCall(CallInst: &Value, IsTailCall: Bool); + pub fn LLVMIsAGlobalVariable(GlobalVar: &Value) -> Option<&Value>; + pub fn LLVMAddGlobal<'a>(M: &'a Module, Ty: &'a Type, Name: *const c_char) -> &'a Value; + pub fn LLVMGetNamedGlobal(M: &Module, Name: *const c_char) -> Option<&Value>; + pub fn LLVMGetFirstGlobal(M: &Module) -> Option<&Value>; + pub fn LLVMGetNextGlobal(GlobalVar: &Value) -> Option<&Value>; + pub fn LLVMDeleteGlobal(GlobalVar: &Value); + pub fn LLVMGetInitializer(GlobalVar: &Value) -> Option<&Value>; + pub fn LLVMSetInitializer<'a>(GlobalVar: &'a Value, ConstantVal: &'a Value); + pub fn LLVMIsThreadLocal(GlobalVar: &Value) -> Bool; + pub fn LLVMSetThreadLocalMode(GlobalVar: &Value, Mode: ThreadLocalMode); + pub fn LLVMIsGlobalConstant(GlobalVar: &Value) -> Bool; + pub fn LLVMSetGlobalConstant(GlobalVar: &Value, IsConstant: Bool); + pub safe fn LLVMSetTailCall(CallInst: &Value, IsTailCall: Bool); // Operations on attributes - pub(crate) fn LLVMCreateStringAttribute( + pub fn LLVMCreateStringAttribute( C: &Context, Name: *const c_char, NameLen: c_uint, @@ -1192,11 +1165,11 @@ unsafe extern "C" { ) -> &Attribute; // Operations on functions - pub(crate) fn LLVMSetFunctionCallConv(Fn: &Value, CC: c_uint); + pub fn LLVMSetFunctionCallConv(Fn: &Value, CC: c_uint); // Operations about llvm intrinsics - pub(crate) fn LLVMLookupIntrinsicID(Name: *const c_char, NameLen: size_t) -> c_uint; - pub(crate) fn LLVMGetIntrinsicDeclaration<'a>( + pub fn LLVMLookupIntrinsicID(Name: *const c_char, NameLen: size_t) -> c_uint; + pub fn LLVMGetIntrinsicDeclaration<'a>( Mod: &'a Module, ID: NonZero, ParamTypes: *const &'a Type, @@ -1204,31 +1177,31 @@ unsafe extern "C" { ) -> &'a Value; // Operations on parameters - pub(crate) fn LLVMIsAArgument(Val: &Value) -> Option<&Value>; - pub(crate) safe fn LLVMCountParams(Fn: &Value) -> c_uint; - pub(crate) fn LLVMGetParam(Fn: &Value, Index: c_uint) -> &Value; + pub fn LLVMIsAArgument(Val: &Value) -> Option<&Value>; + pub safe fn LLVMCountParams(Fn: &Value) -> c_uint; + pub fn LLVMGetParam(Fn: &Value, Index: c_uint) -> &Value; // Operations on basic blocks - pub(crate) fn LLVMGetBasicBlockParent(BB: &BasicBlock) -> &Value; - pub(crate) fn LLVMAppendBasicBlockInContext<'a>( + pub fn LLVMGetBasicBlockParent(BB: &BasicBlock) -> &Value; + pub fn LLVMAppendBasicBlockInContext<'a>( C: &'a Context, Fn: &'a Value, Name: *const c_char, ) -> &'a BasicBlock; // Operations on instructions - pub(crate) fn LLVMIsAInstruction(Val: &Value) -> Option<&Value>; - pub(crate) fn LLVMGetFirstBasicBlock(Fn: &Value) -> &BasicBlock; - pub(crate) fn LLVMGetOperand(Val: &Value, Index: c_uint) -> Option<&Value>; + pub fn LLVMIsAInstruction(Val: &Value) -> Option<&Value>; + pub fn LLVMGetFirstBasicBlock(Fn: &Value) -> &BasicBlock; + pub fn LLVMGetOperand(Val: &Value, Index: c_uint) -> Option<&Value>; // Operations on call sites - pub(crate) fn LLVMSetInstructionCallConv(Instr: &Value, CC: c_uint); + pub fn LLVMSetInstructionCallConv(Instr: &Value, CC: c_uint); // Operations on load/store instructions (only) - pub(crate) fn LLVMSetVolatile(MemoryAccessInst: &Value, volatile: Bool); + pub fn LLVMSetVolatile(MemoryAccessInst: &Value, volatile: Bool); // Operations on phi nodes - pub(crate) fn LLVMAddIncoming<'a>( + pub fn LLVMAddIncoming<'a>( PhiNode: &'a Value, IncomingValues: *const &'a Value, IncomingBlocks: *const &'a BasicBlock, @@ -1236,278 +1209,268 @@ unsafe extern "C" { ); // Instruction builders - pub(crate) fn LLVMCreateBuilderInContext(C: &Context) -> &mut Builder<'_>; - pub(crate) fn LLVMPositionBuilderAtEnd<'a>(Builder: &Builder<'a>, Block: &'a BasicBlock); - pub(crate) fn LLVMGetInsertBlock<'a>(Builder: &Builder<'a>) -> &'a BasicBlock; - pub(crate) fn LLVMDisposeBuilder<'a>(Builder: &'a mut Builder<'a>); + pub fn LLVMCreateBuilderInContext(C: &Context) -> &mut Builder<'_>; + pub fn LLVMPositionBuilderAtEnd<'a>(Builder: &Builder<'a>, Block: &'a BasicBlock); + pub fn LLVMGetInsertBlock<'a>(Builder: &Builder<'a>) -> &'a BasicBlock; + pub fn LLVMDisposeBuilder<'a>(Builder: &'a mut Builder<'a>); // Metadata - pub(crate) fn LLVMSetCurrentDebugLocation2<'a>(Builder: &Builder<'a>, Loc: *const Metadata); - pub(crate) fn LLVMGetCurrentDebugLocation2<'a>(Builder: &Builder<'a>) -> Option<&'a Metadata>; + pub fn LLVMSetCurrentDebugLocation2<'a>(Builder: &Builder<'a>, Loc: *const Metadata); + pub fn LLVMGetCurrentDebugLocation2<'a>(Builder: &Builder<'a>) -> Option<&'a Metadata>; // Terminators - pub(crate) safe fn LLVMBuildRetVoid<'a>(B: &Builder<'a>) -> &'a Value; - pub(crate) fn LLVMBuildRet<'a>(B: &Builder<'a>, V: &'a Value) -> &'a Value; - pub(crate) fn LLVMBuildBr<'a>(B: &Builder<'a>, Dest: &'a BasicBlock) -> &'a Value; - pub(crate) fn LLVMBuildCondBr<'a>( + pub safe fn LLVMBuildRetVoid<'a>(B: &Builder<'a>) -> &'a Value; + pub fn LLVMBuildRet<'a>(B: &Builder<'a>, V: &'a Value) -> &'a Value; + pub fn LLVMBuildBr<'a>(B: &Builder<'a>, Dest: &'a BasicBlock) -> &'a Value; + pub fn LLVMBuildCondBr<'a>( B: &Builder<'a>, If: &'a Value, Then: &'a BasicBlock, Else: &'a BasicBlock, ) -> &'a Value; - pub(crate) fn LLVMBuildSwitch<'a>( + pub fn LLVMBuildSwitch<'a>( B: &Builder<'a>, V: &'a Value, Else: &'a BasicBlock, NumCases: c_uint, ) -> &'a Value; - pub(crate) fn LLVMBuildLandingPad<'a>( + pub fn LLVMBuildLandingPad<'a>( B: &Builder<'a>, Ty: &'a Type, PersFn: Option<&'a Value>, NumClauses: c_uint, Name: *const c_char, ) -> &'a Value; - pub(crate) fn LLVMBuildResume<'a>(B: &Builder<'a>, Exn: &'a Value) -> &'a Value; - pub(crate) fn LLVMBuildUnreachable<'a>(B: &Builder<'a>) -> &'a Value; + pub fn LLVMBuildResume<'a>(B: &Builder<'a>, Exn: &'a Value) -> &'a Value; + pub fn LLVMBuildUnreachable<'a>(B: &Builder<'a>) -> &'a Value; - pub(crate) fn LLVMBuildCleanupPad<'a>( + pub fn LLVMBuildCleanupPad<'a>( B: &Builder<'a>, ParentPad: Option<&'a Value>, Args: *const &'a Value, NumArgs: c_uint, Name: *const c_char, ) -> Option<&'a Value>; - pub(crate) fn LLVMBuildCleanupRet<'a>( + pub fn LLVMBuildCleanupRet<'a>( B: &Builder<'a>, CleanupPad: &'a Value, BB: Option<&'a BasicBlock>, ) -> Option<&'a Value>; - pub(crate) fn LLVMBuildCatchPad<'a>( + pub fn LLVMBuildCatchPad<'a>( B: &Builder<'a>, ParentPad: &'a Value, Args: *const &'a Value, NumArgs: c_uint, Name: *const c_char, ) -> Option<&'a Value>; - pub(crate) fn LLVMBuildCatchRet<'a>( + pub fn LLVMBuildCatchRet<'a>( B: &Builder<'a>, CatchPad: &'a Value, BB: &'a BasicBlock, ) -> Option<&'a Value>; - pub(crate) fn LLVMBuildCatchSwitch<'a>( + pub fn LLVMBuildCatchSwitch<'a>( Builder: &Builder<'a>, ParentPad: Option<&'a Value>, UnwindBB: Option<&'a BasicBlock>, NumHandlers: c_uint, Name: *const c_char, ) -> Option<&'a Value>; - pub(crate) fn LLVMAddHandler<'a>(CatchSwitch: &'a Value, Dest: &'a BasicBlock); - pub(crate) fn LLVMSetPersonalityFn<'a>(Func: &'a Value, Pers: &'a Value); + pub fn LLVMAddHandler<'a>(CatchSwitch: &'a Value, Dest: &'a BasicBlock); + pub fn LLVMSetPersonalityFn<'a>(Func: &'a Value, Pers: &'a Value); // Add a case to the switch instruction - pub(crate) fn LLVMAddCase<'a>(Switch: &'a Value, OnVal: &'a Value, Dest: &'a BasicBlock); + pub fn LLVMAddCase<'a>(Switch: &'a Value, OnVal: &'a Value, Dest: &'a BasicBlock); // Add a clause to the landing pad instruction - pub(crate) fn LLVMAddClause<'a>(LandingPad: &'a Value, ClauseVal: &'a Value); + pub fn LLVMAddClause<'a>(LandingPad: &'a Value, ClauseVal: &'a Value); // Set the cleanup on a landing pad instruction - pub(crate) fn LLVMSetCleanup(LandingPad: &Value, Val: Bool); + pub fn LLVMSetCleanup(LandingPad: &Value, Val: Bool); // Arithmetic - pub(crate) fn LLVMBuildAdd<'a>( + pub fn LLVMBuildAdd<'a>( B: &Builder<'a>, LHS: &'a Value, RHS: &'a Value, Name: *const c_char, ) -> &'a Value; - pub(crate) fn LLVMBuildFAdd<'a>( + pub fn LLVMBuildFAdd<'a>( B: &Builder<'a>, LHS: &'a Value, RHS: &'a Value, Name: *const c_char, ) -> &'a Value; - pub(crate) fn LLVMBuildSub<'a>( + pub fn LLVMBuildSub<'a>( B: &Builder<'a>, LHS: &'a Value, RHS: &'a Value, Name: *const c_char, ) -> &'a Value; - pub(crate) fn LLVMBuildFSub<'a>( + pub fn LLVMBuildFSub<'a>( B: &Builder<'a>, LHS: &'a Value, RHS: &'a Value, Name: *const c_char, ) -> &'a Value; - pub(crate) fn LLVMBuildMul<'a>( + pub fn LLVMBuildMul<'a>( B: &Builder<'a>, LHS: &'a Value, RHS: &'a Value, Name: *const c_char, ) -> &'a Value; - pub(crate) fn LLVMBuildFMul<'a>( + pub fn LLVMBuildFMul<'a>( B: &Builder<'a>, LHS: &'a Value, RHS: &'a Value, Name: *const c_char, ) -> &'a Value; - pub(crate) fn LLVMBuildUDiv<'a>( + pub fn LLVMBuildUDiv<'a>( B: &Builder<'a>, LHS: &'a Value, RHS: &'a Value, Name: *const c_char, ) -> &'a Value; - pub(crate) fn LLVMBuildExactUDiv<'a>( + pub fn LLVMBuildExactUDiv<'a>( B: &Builder<'a>, LHS: &'a Value, RHS: &'a Value, Name: *const c_char, ) -> &'a Value; - pub(crate) fn LLVMBuildSDiv<'a>( + pub fn LLVMBuildSDiv<'a>( B: &Builder<'a>, LHS: &'a Value, RHS: &'a Value, Name: *const c_char, ) -> &'a Value; - pub(crate) fn LLVMBuildExactSDiv<'a>( + pub fn LLVMBuildExactSDiv<'a>( B: &Builder<'a>, LHS: &'a Value, RHS: &'a Value, Name: *const c_char, ) -> &'a Value; - pub(crate) fn LLVMBuildFDiv<'a>( + pub fn LLVMBuildFDiv<'a>( B: &Builder<'a>, LHS: &'a Value, RHS: &'a Value, Name: *const c_char, ) -> &'a Value; - pub(crate) fn LLVMBuildURem<'a>( + pub fn LLVMBuildURem<'a>( B: &Builder<'a>, LHS: &'a Value, RHS: &'a Value, Name: *const c_char, ) -> &'a Value; - pub(crate) fn LLVMBuildSRem<'a>( + pub fn LLVMBuildSRem<'a>( B: &Builder<'a>, LHS: &'a Value, RHS: &'a Value, Name: *const c_char, ) -> &'a Value; - pub(crate) fn LLVMBuildFRem<'a>( + pub fn LLVMBuildFRem<'a>( B: &Builder<'a>, LHS: &'a Value, RHS: &'a Value, Name: *const c_char, ) -> &'a Value; - pub(crate) fn LLVMBuildShl<'a>( + pub fn LLVMBuildShl<'a>( B: &Builder<'a>, LHS: &'a Value, RHS: &'a Value, Name: *const c_char, ) -> &'a Value; - pub(crate) fn LLVMBuildLShr<'a>( + pub fn LLVMBuildLShr<'a>( B: &Builder<'a>, LHS: &'a Value, RHS: &'a Value, Name: *const c_char, ) -> &'a Value; - pub(crate) fn LLVMBuildAShr<'a>( + pub fn LLVMBuildAShr<'a>( B: &Builder<'a>, LHS: &'a Value, RHS: &'a Value, Name: *const c_char, ) -> &'a Value; - pub(crate) fn LLVMBuildNSWAdd<'a>( + pub fn LLVMBuildNSWAdd<'a>( B: &Builder<'a>, LHS: &'a Value, RHS: &'a Value, Name: *const c_char, ) -> &'a Value; - pub(crate) fn LLVMBuildNUWAdd<'a>( + pub fn LLVMBuildNUWAdd<'a>( B: &Builder<'a>, LHS: &'a Value, RHS: &'a Value, Name: *const c_char, ) -> &'a Value; - pub(crate) fn LLVMBuildNSWSub<'a>( + pub fn LLVMBuildNSWSub<'a>( B: &Builder<'a>, LHS: &'a Value, RHS: &'a Value, Name: *const c_char, ) -> &'a Value; - pub(crate) fn LLVMBuildNUWSub<'a>( + pub fn LLVMBuildNUWSub<'a>( B: &Builder<'a>, LHS: &'a Value, RHS: &'a Value, Name: *const c_char, ) -> &'a Value; - pub(crate) fn LLVMBuildNSWMul<'a>( + pub fn LLVMBuildNSWMul<'a>( B: &Builder<'a>, LHS: &'a Value, RHS: &'a Value, Name: *const c_char, ) -> &'a Value; - pub(crate) fn LLVMBuildNUWMul<'a>( + pub fn LLVMBuildNUWMul<'a>( B: &Builder<'a>, LHS: &'a Value, RHS: &'a Value, Name: *const c_char, ) -> &'a Value; - pub(crate) fn LLVMBuildAnd<'a>( + pub fn LLVMBuildAnd<'a>( B: &Builder<'a>, LHS: &'a Value, RHS: &'a Value, Name: *const c_char, ) -> &'a Value; - pub(crate) fn LLVMBuildOr<'a>( + pub fn LLVMBuildOr<'a>( B: &Builder<'a>, LHS: &'a Value, RHS: &'a Value, Name: *const c_char, ) -> &'a Value; - pub(crate) fn LLVMBuildXor<'a>( + pub fn LLVMBuildXor<'a>( B: &Builder<'a>, LHS: &'a Value, RHS: &'a Value, Name: *const c_char, ) -> &'a Value; - pub(crate) fn LLVMBuildNeg<'a>(B: &Builder<'a>, V: &'a Value, Name: *const c_char) - -> &'a Value; - pub(crate) fn LLVMBuildFNeg<'a>( - B: &Builder<'a>, - V: &'a Value, - Name: *const c_char, - ) -> &'a Value; - pub(crate) fn LLVMBuildNot<'a>(B: &Builder<'a>, V: &'a Value, Name: *const c_char) - -> &'a Value; + pub fn LLVMBuildNeg<'a>(B: &Builder<'a>, V: &'a Value, Name: *const c_char) -> &'a Value; + pub fn LLVMBuildFNeg<'a>(B: &Builder<'a>, V: &'a Value, Name: *const c_char) -> &'a Value; + pub fn LLVMBuildNot<'a>(B: &Builder<'a>, V: &'a Value, Name: *const c_char) -> &'a Value; // Extra flags on arithmetic - pub(crate) fn LLVMSetIsDisjoint(Instr: &Value, IsDisjoint: Bool); - pub(crate) fn LLVMSetNUW(ArithInst: &Value, HasNUW: Bool); - pub(crate) fn LLVMSetNSW(ArithInst: &Value, HasNSW: Bool); + pub fn LLVMSetIsDisjoint(Instr: &Value, IsDisjoint: Bool); + pub fn LLVMSetNUW(ArithInst: &Value, HasNUW: Bool); + pub fn LLVMSetNSW(ArithInst: &Value, HasNSW: Bool); // Memory - pub(crate) fn LLVMBuildAlloca<'a>( - B: &Builder<'a>, - Ty: &'a Type, - Name: *const c_char, - ) -> &'a Value; - pub(crate) fn LLVMBuildArrayAlloca<'a>( + pub fn LLVMBuildAlloca<'a>(B: &Builder<'a>, Ty: &'a Type, Name: *const c_char) -> &'a Value; + pub fn LLVMBuildArrayAlloca<'a>( B: &Builder<'a>, Ty: &'a Type, Val: &'a Value, Name: *const c_char, ) -> &'a Value; - pub(crate) fn LLVMBuildLoad2<'a>( + pub fn LLVMBuildLoad2<'a>( B: &Builder<'a>, Ty: &'a Type, PointerVal: &'a Value, Name: *const c_char, ) -> &'a Value; - pub(crate) fn LLVMBuildStore<'a>(B: &Builder<'a>, Val: &'a Value, Ptr: &'a Value) -> &'a Value; + pub fn LLVMBuildStore<'a>(B: &Builder<'a>, Val: &'a Value, Ptr: &'a Value) -> &'a Value; - pub(crate) fn LLVMBuildGEPWithNoWrapFlags<'a>( + pub fn LLVMBuildGEPWithNoWrapFlags<'a>( B: &Builder<'a>, Ty: &'a Type, Pointer: &'a Value, @@ -1518,85 +1481,85 @@ unsafe extern "C" { ) -> &'a Value; // Casts - pub(crate) fn LLVMBuildTrunc<'a>( + pub fn LLVMBuildTrunc<'a>( B: &Builder<'a>, Val: &'a Value, DestTy: &'a Type, Name: *const c_char, ) -> &'a Value; - pub(crate) fn LLVMBuildZExt<'a>( + pub fn LLVMBuildZExt<'a>( B: &Builder<'a>, Val: &'a Value, DestTy: &'a Type, Name: *const c_char, ) -> &'a Value; - pub(crate) fn LLVMBuildSExt<'a>( + pub fn LLVMBuildSExt<'a>( B: &Builder<'a>, Val: &'a Value, DestTy: &'a Type, Name: *const c_char, ) -> &'a Value; - pub(crate) fn LLVMBuildFPToUI<'a>( + pub fn LLVMBuildFPToUI<'a>( B: &Builder<'a>, Val: &'a Value, DestTy: &'a Type, Name: *const c_char, ) -> &'a Value; - pub(crate) fn LLVMBuildFPToSI<'a>( + pub fn LLVMBuildFPToSI<'a>( B: &Builder<'a>, Val: &'a Value, DestTy: &'a Type, Name: *const c_char, ) -> &'a Value; - pub(crate) fn LLVMBuildUIToFP<'a>( + pub fn LLVMBuildUIToFP<'a>( B: &Builder<'a>, Val: &'a Value, DestTy: &'a Type, Name: *const c_char, ) -> &'a Value; - pub(crate) fn LLVMBuildSIToFP<'a>( + pub fn LLVMBuildSIToFP<'a>( B: &Builder<'a>, Val: &'a Value, DestTy: &'a Type, Name: *const c_char, ) -> &'a Value; - pub(crate) fn LLVMBuildFPTrunc<'a>( + pub fn LLVMBuildFPTrunc<'a>( B: &Builder<'a>, Val: &'a Value, DestTy: &'a Type, Name: *const c_char, ) -> &'a Value; - pub(crate) fn LLVMBuildFPExt<'a>( + pub fn LLVMBuildFPExt<'a>( B: &Builder<'a>, Val: &'a Value, DestTy: &'a Type, Name: *const c_char, ) -> &'a Value; - pub(crate) fn LLVMBuildPtrToInt<'a>( + pub fn LLVMBuildPtrToInt<'a>( B: &Builder<'a>, Val: &'a Value, DestTy: &'a Type, Name: *const c_char, ) -> &'a Value; - pub(crate) fn LLVMBuildIntToPtr<'a>( + pub fn LLVMBuildIntToPtr<'a>( B: &Builder<'a>, Val: &'a Value, DestTy: &'a Type, Name: *const c_char, ) -> &'a Value; - pub(crate) fn LLVMBuildBitCast<'a>( + pub fn LLVMBuildBitCast<'a>( B: &Builder<'a>, Val: &'a Value, DestTy: &'a Type, Name: *const c_char, ) -> &'a Value; - pub(crate) fn LLVMBuildPointerCast<'a>( + pub fn LLVMBuildPointerCast<'a>( B: &Builder<'a>, Val: &'a Value, DestTy: &'a Type, Name: *const c_char, ) -> &'a Value; - pub(crate) fn LLVMBuildIntCast2<'a>( + pub fn LLVMBuildIntCast2<'a>( B: &Builder<'a>, Val: &'a Value, DestTy: &'a Type, @@ -1605,14 +1568,14 @@ unsafe extern "C" { ) -> &'a Value; // Comparisons - pub(crate) fn LLVMBuildICmp<'a>( + pub fn LLVMBuildICmp<'a>( B: &Builder<'a>, Op: c_uint, LHS: &'a Value, RHS: &'a Value, Name: *const c_char, ) -> &'a Value; - pub(crate) fn LLVMBuildFCmp<'a>( + pub fn LLVMBuildFCmp<'a>( B: &Builder<'a>, Op: c_uint, LHS: &'a Value, @@ -1621,48 +1584,47 @@ unsafe extern "C" { ) -> &'a Value; // Miscellaneous instructions - pub(crate) fn LLVMBuildPhi<'a>(B: &Builder<'a>, Ty: &'a Type, Name: *const c_char) - -> &'a Value; - pub(crate) fn LLVMBuildSelect<'a>( + pub fn LLVMBuildPhi<'a>(B: &Builder<'a>, Ty: &'a Type, Name: *const c_char) -> &'a Value; + pub fn LLVMBuildSelect<'a>( B: &Builder<'a>, If: &'a Value, Then: &'a Value, Else: &'a Value, Name: *const c_char, ) -> &'a Value; - pub(crate) fn LLVMBuildVAArg<'a>( + pub fn LLVMBuildVAArg<'a>( B: &Builder<'a>, list: &'a Value, Ty: &'a Type, Name: *const c_char, ) -> &'a Value; - pub(crate) fn LLVMBuildExtractElement<'a>( + pub fn LLVMBuildExtractElement<'a>( B: &Builder<'a>, VecVal: &'a Value, Index: &'a Value, Name: *const c_char, ) -> &'a Value; - pub(crate) fn LLVMBuildInsertElement<'a>( + pub fn LLVMBuildInsertElement<'a>( B: &Builder<'a>, VecVal: &'a Value, EltVal: &'a Value, Index: &'a Value, Name: *const c_char, ) -> &'a Value; - pub(crate) fn LLVMBuildShuffleVector<'a>( + pub fn LLVMBuildShuffleVector<'a>( B: &Builder<'a>, V1: &'a Value, V2: &'a Value, Mask: &'a Value, Name: *const c_char, ) -> &'a Value; - pub(crate) fn LLVMBuildExtractValue<'a>( + pub fn LLVMBuildExtractValue<'a>( B: &Builder<'a>, AggVal: &'a Value, Index: c_uint, Name: *const c_char, ) -> &'a Value; - pub(crate) fn LLVMBuildInsertValue<'a>( + pub fn LLVMBuildInsertValue<'a>( B: &Builder<'a>, AggVal: &'a Value, EltVal: &'a Value, @@ -1671,7 +1633,7 @@ unsafe extern "C" { ) -> &'a Value; // Atomic Operations - pub(crate) fn LLVMBuildAtomicCmpXchg<'a>( + pub fn LLVMBuildAtomicCmpXchg<'a>( B: &Builder<'a>, LHS: &'a Value, CMP: &'a Value, @@ -1681,9 +1643,9 @@ unsafe extern "C" { SingleThreaded: Bool, ) -> &'a Value; - pub(crate) fn LLVMSetWeak(CmpXchgInst: &Value, IsWeak: Bool); + pub fn LLVMSetWeak(CmpXchgInst: &Value, IsWeak: Bool); - pub(crate) fn LLVMBuildAtomicRMW<'a>( + pub fn LLVMBuildAtomicRMW<'a>( B: &Builder<'a>, Op: AtomicRmwBinOp, LHS: &'a Value, @@ -1692,7 +1654,7 @@ unsafe extern "C" { SingleThreaded: Bool, ) -> &'a Value; - pub(crate) fn LLVMBuildFence<'a>( + pub fn LLVMBuildFence<'a>( B: &Builder<'a>, Order: AtomicOrdering, SingleThreaded: Bool, @@ -1700,46 +1662,46 @@ unsafe extern "C" { ) -> &'a Value; /// Writes a module to the specified path. Returns 0 on success. - pub(crate) fn LLVMWriteBitcodeToFile(M: &Module, Path: *const c_char) -> c_int; + pub fn LLVMWriteBitcodeToFile(M: &Module, Path: *const c_char) -> c_int; /// Creates a legacy pass manager -- only used for final codegen. - pub(crate) fn LLVMCreatePassManager<'a>() -> &'a mut PassManager<'a>; + pub fn LLVMCreatePassManager<'a>() -> &'a mut PassManager<'a>; - pub(crate) fn LLVMAddAnalysisPasses<'a>(T: &'a TargetMachine, PM: &PassManager<'a>); + pub fn LLVMAddAnalysisPasses<'a>(T: &'a TargetMachine, PM: &PassManager<'a>); - pub(crate) fn LLVMGetHostCPUFeatures() -> *mut c_char; + pub fn LLVMGetHostCPUFeatures() -> *mut c_char; - pub(crate) fn LLVMDisposeMessage(message: *mut c_char); + pub fn LLVMDisposeMessage(message: *mut c_char); - pub(crate) fn LLVMIsMultithreaded() -> Bool; + pub fn LLVMIsMultithreaded() -> Bool; - pub(crate) fn LLVMStructCreateNamed(C: &Context, Name: *const c_char) -> &Type; + pub fn LLVMStructCreateNamed(C: &Context, Name: *const c_char) -> &Type; - pub(crate) fn LLVMStructSetBody<'a>( + pub fn LLVMStructSetBody<'a>( StructTy: &'a Type, ElementTypes: *const &'a Type, ElementCount: c_uint, Packed: Bool, ); - pub(crate) safe fn LLVMMetadataAsValue<'a>(C: &'a Context, MD: &'a Metadata) -> &'a Value; + pub safe fn LLVMMetadataAsValue<'a>(C: &'a Context, MD: &'a Metadata) -> &'a Value; - pub(crate) fn LLVMSetUnnamedAddress(Global: &Value, UnnamedAddr: UnnamedAddr); + pub fn LLVMSetUnnamedAddress(Global: &Value, UnnamedAddr: UnnamedAddr); - pub(crate) fn LLVMIsAConstantInt(value_ref: &Value) -> Option<&ConstantInt>; + pub fn LLVMIsAConstantInt(value_ref: &Value) -> Option<&ConstantInt>; - pub(crate) fn LLVMGetOrInsertComdat(M: &Module, Name: *const c_char) -> &Comdat; - pub(crate) fn LLVMSetComdat(V: &Value, C: &Comdat); + pub fn LLVMGetOrInsertComdat(M: &Module, Name: *const c_char) -> &Comdat; + pub fn LLVMSetComdat(V: &Value, C: &Comdat); - pub(crate) fn LLVMCreateOperandBundle( + pub fn LLVMCreateOperandBundle( Tag: *const c_char, TagLen: size_t, Args: *const &'_ Value, NumArgs: c_uint, ) -> *mut OperandBundle<'_>; - pub(crate) fn LLVMDisposeOperandBundle(Bundle: ptr::NonNull>); + pub fn LLVMDisposeOperandBundle(Bundle: ptr::NonNull>); - pub(crate) fn LLVMBuildCallWithOperandBundles<'a>( + pub fn LLVMBuildCallWithOperandBundles<'a>( B: &Builder<'a>, Ty: &'a Type, Fn: &'a Value, @@ -1749,7 +1711,7 @@ unsafe extern "C" { NumBundles: c_uint, Name: *const c_char, ) -> &'a Value; - pub(crate) fn LLVMBuildInvokeWithOperandBundles<'a>( + pub fn LLVMBuildInvokeWithOperandBundles<'a>( B: &Builder<'a>, Ty: &'a Type, Fn: &'a Value, @@ -1761,7 +1723,7 @@ unsafe extern "C" { NumBundles: c_uint, Name: *const c_char, ) -> &'a Value; - pub(crate) fn LLVMBuildCallBr<'a>( + pub fn LLVMBuildCallBr<'a>( B: &Builder<'a>, Ty: &'a Type, Fn: &'a Value, @@ -1783,20 +1745,20 @@ unsafe extern "C" { // that they really are nullable on the C/C++ side. LLVM doesn't appear to // actually document which ones are nullable. unsafe extern "C" { - pub(crate) fn LLVMCreateDIBuilder<'ll>(M: &'ll Module) -> *mut DIBuilder<'ll>; - pub(crate) fn LLVMDisposeDIBuilder<'ll>(Builder: ptr::NonNull>); + pub fn LLVMCreateDIBuilder<'ll>(M: &'ll Module) -> *mut DIBuilder<'ll>; + pub fn LLVMDisposeDIBuilder<'ll>(Builder: ptr::NonNull>); - pub(crate) fn LLVMDIBuilderFinalize<'ll>(Builder: &DIBuilder<'ll>); + pub fn LLVMDIBuilderFinalize<'ll>(Builder: &DIBuilder<'ll>); - pub(crate) fn LLVMDIBuilderCreateNameSpace<'ll>( + pub fn LLVMDIBuilderCreateNameSpace<'ll>( Builder: &DIBuilder<'ll>, ParentScope: Option<&'ll Metadata>, Name: *const c_uchar, // See "PTR_LEN_STR". NameLen: size_t, - ExportSymbols: llvm::Bool, + ExportSymbols: Bool, ) -> &'ll Metadata; - pub(crate) fn LLVMDIBuilderCreateLexicalBlock<'ll>( + pub fn LLVMDIBuilderCreateLexicalBlock<'ll>( Builder: &DIBuilder<'ll>, Scope: &'ll Metadata, File: &'ll Metadata, @@ -1804,14 +1766,14 @@ unsafe extern "C" { Column: c_uint, ) -> &'ll Metadata; - pub(crate) fn LLVMDIBuilderCreateLexicalBlockFile<'ll>( + pub fn LLVMDIBuilderCreateLexicalBlockFile<'ll>( Builder: &DIBuilder<'ll>, Scope: &'ll Metadata, File: &'ll Metadata, Discriminator: c_uint, // (optional "DWARF path discriminator"; default is 0) ) -> &'ll Metadata; - pub(crate) fn LLVMDIBuilderCreateDebugLocation<'ll>( + pub fn LLVMDIBuilderCreateDebugLocation<'ll>( Ctx: &'ll Context, Line: c_uint, Column: c_uint, @@ -1822,26 +1784,22 @@ unsafe extern "C" { #[link(name = "llvm-wrapper", kind = "static")] unsafe extern "C" { - pub(crate) fn LLVMRustInstallErrorHandlers(); - pub(crate) fn LLVMRustDisableSystemDialogsOnCrash(); + pub fn LLVMRustInstallErrorHandlers(); + pub fn LLVMRustDisableSystemDialogsOnCrash(); // Create and destroy contexts. - pub(crate) fn LLVMRustContextCreate(shouldDiscardNames: bool) -> &'static mut Context; + pub fn LLVMRustContextCreate(shouldDiscardNames: bool) -> &'static mut Context; - /// See llvm::LLVMTypeKind::getTypeID. - pub(crate) fn LLVMRustGetTypeKind(Ty: &Type) -> TypeKind; + /// See super::LLVMTypeKind::getTypeID. + pub fn LLVMRustGetTypeKind(Ty: &Type) -> TypeKind; // Operations on all values - pub(crate) fn LLVMRustGlobalAddMetadata<'a>( - Val: &'a Value, - KindID: c_uint, - Metadata: &'a Metadata, - ); - pub(crate) fn LLVMRustIsNonGVFunctionPointerTy(Val: &Value) -> bool; + pub fn LLVMRustGlobalAddMetadata<'a>(Val: &'a Value, KindID: c_uint, Metadata: &'a Metadata); + pub fn LLVMRustIsNonGVFunctionPointerTy(Val: &Value) -> bool; // Operations on scalar constants - pub(crate) fn LLVMRustConstIntGetZExtValue(ConstantVal: &ConstantInt, Value: &mut u64) -> bool; - pub(crate) fn LLVMRustConstInt128Get( + pub fn LLVMRustConstIntGetZExtValue(ConstantVal: &ConstantInt, Value: &mut u64) -> bool; + pub fn LLVMRustConstInt128Get( ConstantVal: &ConstantInt, SExt: bool, high: &mut u64, @@ -1849,38 +1807,35 @@ unsafe extern "C" { ) -> bool; // Operations on global variables, functions, and aliases (globals) - pub(crate) fn LLVMRustSetDSOLocal(Global: &Value, is_dso_local: bool); + pub fn LLVMRustSetDSOLocal(Global: &Value, is_dso_local: bool); // Operations on global variables - pub(crate) fn LLVMRustGetOrInsertGlobal<'a>( + pub fn LLVMRustGetOrInsertGlobal<'a>( M: &'a Module, Name: *const c_char, NameLen: size_t, T: &'a Type, ) -> &'a Value; - pub(crate) fn LLVMRustInsertPrivateGlobal<'a>(M: &'a Module, T: &'a Type) -> &'a Value; - pub(crate) fn LLVMRustGetNamedValue( + pub fn LLVMRustInsertPrivateGlobal<'a>(M: &'a Module, T: &'a Type) -> &'a Value; + pub fn LLVMRustGetNamedValue( M: &Module, Name: *const c_char, NameLen: size_t, ) -> Option<&Value>; // Operations on attributes - pub(crate) fn LLVMRustCreateAttrNoValue(C: &Context, attr: AttributeKind) -> &Attribute; - pub(crate) fn LLVMRustCreateAlignmentAttr(C: &Context, bytes: u64) -> &Attribute; - pub(crate) fn LLVMRustCreateDereferenceableAttr(C: &Context, bytes: u64) -> &Attribute; - pub(crate) fn LLVMRustCreateDereferenceableOrNullAttr(C: &Context, bytes: u64) -> &Attribute; - pub(crate) fn LLVMRustCreateByValAttr<'a>(C: &'a Context, ty: &'a Type) -> &'a Attribute; - pub(crate) fn LLVMRustCreateStructRetAttr<'a>(C: &'a Context, ty: &'a Type) -> &'a Attribute; - pub(crate) fn LLVMRustCreateElementTypeAttr<'a>(C: &'a Context, ty: &'a Type) -> &'a Attribute; - pub(crate) fn LLVMRustCreateUWTableAttr(C: &Context, async_: bool) -> &Attribute; - pub(crate) fn LLVMRustCreateAllocSizeAttr(C: &Context, size_arg: u32) -> &Attribute; - pub(crate) fn LLVMRustCreateAllocKindAttr(C: &Context, size_arg: u64) -> &Attribute; - pub(crate) fn LLVMRustCreateMemoryEffectsAttr( - C: &Context, - effects: MemoryEffects, - ) -> &Attribute; - pub(crate) fn LLVMRustCreateRangeAttribute( + pub fn LLVMRustCreateAttrNoValue(C: &Context, attr: AttributeKind) -> &Attribute; + pub fn LLVMRustCreateAlignmentAttr(C: &Context, bytes: u64) -> &Attribute; + pub fn LLVMRustCreateDereferenceableAttr(C: &Context, bytes: u64) -> &Attribute; + pub fn LLVMRustCreateDereferenceableOrNullAttr(C: &Context, bytes: u64) -> &Attribute; + pub fn LLVMRustCreateByValAttr<'a>(C: &'a Context, ty: &'a Type) -> &'a Attribute; + pub fn LLVMRustCreateStructRetAttr<'a>(C: &'a Context, ty: &'a Type) -> &'a Attribute; + pub fn LLVMRustCreateElementTypeAttr<'a>(C: &'a Context, ty: &'a Type) -> &'a Attribute; + pub fn LLVMRustCreateUWTableAttr(C: &Context, async_: bool) -> &Attribute; + pub fn LLVMRustCreateAllocSizeAttr(C: &Context, size_arg: u32) -> &Attribute; + pub fn LLVMRustCreateAllocKindAttr(C: &Context, size_arg: u64) -> &Attribute; + pub fn LLVMRustCreateMemoryEffectsAttr(C: &Context, effects: MemoryEffects) -> &Attribute; + pub fn LLVMRustCreateRangeAttribute( C: &Context, num_bits: c_uint, lower_words: *const u64, @@ -1888,13 +1843,13 @@ unsafe extern "C" { ) -> &Attribute; // Operations on functions - pub(crate) fn LLVMRustGetOrInsertFunction<'a>( + pub fn LLVMRustGetOrInsertFunction<'a>( M: &'a Module, Name: *const c_char, NameLen: size_t, FunctionTy: &'a Type, ) -> &'a Value; - pub(crate) fn LLVMRustAddFunctionAttributes<'a>( + pub fn LLVMRustAddFunctionAttributes<'a>( Fn: &'a Value, index: c_uint, Attrs: *const &'a Attribute, @@ -1902,19 +1857,19 @@ unsafe extern "C" { ); // Operations on call sites - pub(crate) fn LLVMRustAddCallSiteAttributes<'a>( + pub fn LLVMRustAddCallSiteAttributes<'a>( Instr: &'a Value, index: c_uint, Attrs: *const &'a Attribute, AttrsLen: size_t, ); - pub(crate) fn LLVMRustSetFastMath(Instr: &Value); - pub(crate) fn LLVMRustSetAlgebraicMath(Instr: &Value); - pub(crate) fn LLVMRustSetAllowReassoc(Instr: &Value); + pub fn LLVMRustSetFastMath(Instr: &Value); + pub fn LLVMRustSetAlgebraicMath(Instr: &Value); + pub fn LLVMRustSetAllowReassoc(Instr: &Value); // Miscellaneous instructions - pub(crate) fn LLVMRustBuildMemCpy<'a>( + pub fn LLVMRustBuildMemCpy<'a>( B: &Builder<'a>, Dst: &'a Value, DstAlign: c_uint, @@ -1923,7 +1878,7 @@ unsafe extern "C" { Size: &'a Value, IsVolatile: bool, ) -> &'a Value; - pub(crate) fn LLVMRustBuildMemMove<'a>( + pub fn LLVMRustBuildMemMove<'a>( B: &Builder<'a>, Dst: &'a Value, DstAlign: c_uint, @@ -1932,7 +1887,7 @@ unsafe extern "C" { Size: &'a Value, IsVolatile: bool, ) -> &'a Value; - pub(crate) fn LLVMRustBuildMemSet<'a>( + pub fn LLVMRustBuildMemSet<'a>( B: &Builder<'a>, Dst: &'a Value, DstAlign: c_uint, @@ -1941,55 +1896,47 @@ unsafe extern "C" { IsVolatile: bool, ) -> &'a Value; - pub(crate) fn LLVMRustBuildVectorReduceFAdd<'a>( + pub fn LLVMRustBuildVectorReduceFAdd<'a>( B: &Builder<'a>, Acc: &'a Value, Src: &'a Value, ) -> &'a Value; - pub(crate) fn LLVMRustBuildVectorReduceFMul<'a>( + pub fn LLVMRustBuildVectorReduceFMul<'a>( B: &Builder<'a>, Acc: &'a Value, Src: &'a Value, ) -> &'a Value; - pub(crate) fn LLVMRustBuildVectorReduceAdd<'a>(B: &Builder<'a>, Src: &'a Value) -> &'a Value; - pub(crate) fn LLVMRustBuildVectorReduceMul<'a>(B: &Builder<'a>, Src: &'a Value) -> &'a Value; - pub(crate) fn LLVMRustBuildVectorReduceAnd<'a>(B: &Builder<'a>, Src: &'a Value) -> &'a Value; - pub(crate) fn LLVMRustBuildVectorReduceOr<'a>(B: &Builder<'a>, Src: &'a Value) -> &'a Value; - pub(crate) fn LLVMRustBuildVectorReduceXor<'a>(B: &Builder<'a>, Src: &'a Value) -> &'a Value; - pub(crate) fn LLVMRustBuildVectorReduceMin<'a>( + pub fn LLVMRustBuildVectorReduceAdd<'a>(B: &Builder<'a>, Src: &'a Value) -> &'a Value; + pub fn LLVMRustBuildVectorReduceMul<'a>(B: &Builder<'a>, Src: &'a Value) -> &'a Value; + pub fn LLVMRustBuildVectorReduceAnd<'a>(B: &Builder<'a>, Src: &'a Value) -> &'a Value; + pub fn LLVMRustBuildVectorReduceOr<'a>(B: &Builder<'a>, Src: &'a Value) -> &'a Value; + pub fn LLVMRustBuildVectorReduceXor<'a>(B: &Builder<'a>, Src: &'a Value) -> &'a Value; + pub fn LLVMRustBuildVectorReduceMin<'a>( B: &Builder<'a>, Src: &'a Value, IsSigned: bool, ) -> &'a Value; - pub(crate) fn LLVMRustBuildVectorReduceMax<'a>( + pub fn LLVMRustBuildVectorReduceMax<'a>( B: &Builder<'a>, Src: &'a Value, IsSigned: bool, ) -> &'a Value; - pub(crate) fn LLVMRustBuildVectorReduceFMin<'a>( + pub fn LLVMRustBuildVectorReduceFMin<'a>( B: &Builder<'a>, Src: &'a Value, IsNaN: bool, ) -> &'a Value; - pub(crate) fn LLVMRustBuildVectorReduceFMax<'a>( + pub fn LLVMRustBuildVectorReduceFMax<'a>( B: &Builder<'a>, Src: &'a Value, IsNaN: bool, ) -> &'a Value; - pub(crate) fn LLVMRustBuildMinNum<'a>( - B: &Builder<'a>, - LHS: &'a Value, - LHS: &'a Value, - ) -> &'a Value; - pub(crate) fn LLVMRustBuildMaxNum<'a>( - B: &Builder<'a>, - LHS: &'a Value, - LHS: &'a Value, - ) -> &'a Value; + pub fn LLVMRustBuildMinNum<'a>(B: &Builder<'a>, LHS: &'a Value, LHS: &'a Value) -> &'a Value; + pub fn LLVMRustBuildMaxNum<'a>(B: &Builder<'a>, LHS: &'a Value, LHS: &'a Value) -> &'a Value; // Atomic Operations - pub(crate) fn LLVMRustBuildAtomicLoad<'a>( + pub fn LLVMRustBuildAtomicLoad<'a>( B: &Builder<'a>, ElementType: &'a Type, PointerVal: &'a Value, @@ -1997,35 +1944,35 @@ unsafe extern "C" { Order: AtomicOrdering, ) -> &'a Value; - pub(crate) fn LLVMRustBuildAtomicStore<'a>( + pub fn LLVMRustBuildAtomicStore<'a>( B: &Builder<'a>, Val: &'a Value, Ptr: &'a Value, Order: AtomicOrdering, ) -> &'a Value; - pub(crate) fn LLVMRustTimeTraceProfilerInitialize(); + pub fn LLVMRustTimeTraceProfilerInitialize(); - pub(crate) fn LLVMRustTimeTraceProfilerFinishThread(); + pub fn LLVMRustTimeTraceProfilerFinishThread(); - pub(crate) fn LLVMRustTimeTraceProfilerFinish(FileName: *const c_char); + pub fn LLVMRustTimeTraceProfilerFinish(FileName: *const c_char); /// Returns a string describing the last error caused by an LLVMRust* call. - pub(crate) fn LLVMRustGetLastError() -> *const c_char; + pub fn LLVMRustGetLastError() -> *const c_char; /// Prints the timing information collected by `-Ztime-llvm-passes`. - pub(crate) fn LLVMRustPrintPassTimings(OutStr: &RustString); + pub fn LLVMRustPrintPassTimings(OutStr: &RustString); /// Prints the statistics collected by `-Zprint-codegen-stats`. - pub(crate) fn LLVMRustPrintStatistics(OutStr: &RustString); + pub fn LLVMRustPrintStatistics(OutStr: &RustString); - pub(crate) fn LLVMRustInlineAsmVerify( + pub fn LLVMRustInlineAsmVerify( Ty: &Type, Constraints: *const c_uchar, // See "PTR_LEN_STR". ConstraintsLen: size_t, ) -> bool; - pub(crate) fn LLVMRustCoverageWriteFilenamesToBuffer( + pub fn LLVMRustCoverageWriteFilenamesToBuffer( Filenames: *const *const c_char, FilenamesLen: size_t, Lengths: *const size_t, @@ -2033,48 +1980,48 @@ unsafe extern "C" { BufferOut: &RustString, ); - pub(crate) fn LLVMRustCoverageWriteFunctionMappingsToBuffer( + pub fn LLVMRustCoverageWriteFunctionMappingsToBuffer( VirtualFileMappingIDs: *const c_uint, NumVirtualFileMappingIDs: size_t, - Expressions: *const crate::coverageinfo::ffi::CounterExpression, + Expressions: *const coverageinfo::CounterExpression, NumExpressions: size_t, - CodeRegions: *const crate::coverageinfo::ffi::CodeRegion, + CodeRegions: *const coverageinfo::CodeRegion, NumCodeRegions: size_t, - ExpansionRegions: *const crate::coverageinfo::ffi::ExpansionRegion, + ExpansionRegions: *const coverageinfo::ExpansionRegion, NumExpansionRegions: size_t, - BranchRegions: *const crate::coverageinfo::ffi::BranchRegion, + BranchRegions: *const coverageinfo::BranchRegion, NumBranchRegions: size_t, - MCDCBranchRegions: *const crate::coverageinfo::ffi::MCDCBranchRegion, + MCDCBranchRegions: *const coverageinfo::MCDCBranchRegion, NumMCDCBranchRegions: size_t, - MCDCDecisionRegions: *const crate::coverageinfo::ffi::MCDCDecisionRegion, + MCDCDecisionRegions: *const coverageinfo::MCDCDecisionRegion, NumMCDCDecisionRegions: size_t, BufferOut: &RustString, ); - pub(crate) fn LLVMRustCoverageCreatePGOFuncNameVar( + pub fn LLVMRustCoverageCreatePGOFuncNameVar( F: &Value, FuncName: *const c_char, FuncNameLen: size_t, ) -> &Value; - pub(crate) fn LLVMRustCoverageHashBytes(Bytes: *const c_char, NumBytes: size_t) -> u64; + pub fn LLVMRustCoverageHashBytes(Bytes: *const c_char, NumBytes: size_t) -> u64; - pub(crate) fn LLVMRustCoverageWriteCovmapSectionNameToString(M: &Module, OutStr: &RustString); + pub fn LLVMRustCoverageWriteCovmapSectionNameToString(M: &Module, OutStr: &RustString); - pub(crate) fn LLVMRustCoverageWriteCovfunSectionNameToString(M: &Module, OutStr: &RustString); + pub fn LLVMRustCoverageWriteCovfunSectionNameToString(M: &Module, OutStr: &RustString); - pub(crate) fn LLVMRustCoverageWriteCovmapVarNameToString(OutStr: &RustString); + pub fn LLVMRustCoverageWriteCovmapVarNameToString(OutStr: &RustString); - pub(crate) fn LLVMRustCoverageMappingVersion() -> u32; - pub(crate) fn LLVMRustDebugMetadataVersion() -> u32; - pub(crate) fn LLVMRustVersionMajor() -> u32; - pub(crate) fn LLVMRustVersionMinor() -> u32; - pub(crate) fn LLVMRustVersionPatch() -> u32; + pub fn LLVMRustCoverageMappingVersion() -> u32; + pub fn LLVMRustDebugMetadataVersion() -> u32; + pub fn LLVMRustVersionMajor() -> u32; + pub fn LLVMRustVersionMinor() -> u32; + pub fn LLVMRustVersionPatch() -> u32; /// Add LLVM module flags. /// /// In order for Rust-C LTO to work, module flags must be compatible with Clang. What /// "compatible" means depends on the merge behaviors involved. - pub(crate) fn LLVMRustAddModuleFlagU32( + pub fn LLVMRustAddModuleFlagU32( M: &Module, MergeBehavior: ModuleFlagMergeBehavior, Name: *const c_char, @@ -2082,7 +2029,7 @@ unsafe extern "C" { Value: u32, ); - pub(crate) fn LLVMRustAddModuleFlagString( + pub fn LLVMRustAddModuleFlagString( M: &Module, MergeBehavior: ModuleFlagMergeBehavior, Name: *const c_char, @@ -2091,7 +2038,7 @@ unsafe extern "C" { ValueLen: size_t, ); - pub(crate) fn LLVMRustDIBuilderCreateCompileUnit<'a>( + pub fn LLVMRustDIBuilderCreateCompileUnit<'a>( Builder: &DIBuilder<'a>, Lang: c_uint, File: &'a DIFile, @@ -2108,7 +2055,7 @@ unsafe extern "C" { DebugNameTableKind: DebugNameTableKind, ) -> &'a DIDescriptor; - pub(crate) fn LLVMRustDIBuilderCreateFile<'a>( + pub fn LLVMRustDIBuilderCreateFile<'a>( Builder: &DIBuilder<'a>, Filename: *const c_char, FilenameLen: size_t, @@ -2121,12 +2068,12 @@ unsafe extern "C" { SourceLen: size_t, ) -> &'a DIFile; - pub(crate) fn LLVMRustDIBuilderCreateSubroutineType<'a>( + pub fn LLVMRustDIBuilderCreateSubroutineType<'a>( Builder: &DIBuilder<'a>, ParameterTypes: &'a DIArray, ) -> &'a DICompositeType; - pub(crate) fn LLVMRustDIBuilderCreateFunction<'a>( + pub fn LLVMRustDIBuilderCreateFunction<'a>( Builder: &DIBuilder<'a>, Scope: &'a DIDescriptor, Name: *const c_char, @@ -2144,7 +2091,7 @@ unsafe extern "C" { Decl: Option<&'a DIDescriptor>, ) -> &'a DISubprogram; - pub(crate) fn LLVMRustDIBuilderCreateMethod<'a>( + pub fn LLVMRustDIBuilderCreateMethod<'a>( Builder: &DIBuilder<'a>, Scope: &'a DIDescriptor, Name: *const c_char, @@ -2159,7 +2106,7 @@ unsafe extern "C" { TParam: &'a DIArray, ) -> &'a DISubprogram; - pub(crate) fn LLVMRustDIBuilderCreateBasicType<'a>( + pub fn LLVMRustDIBuilderCreateBasicType<'a>( Builder: &DIBuilder<'a>, Name: *const c_char, NameLen: size_t, @@ -2167,7 +2114,7 @@ unsafe extern "C" { Encoding: c_uint, ) -> &'a DIBasicType; - pub(crate) fn LLVMRustDIBuilderCreateTypedef<'a>( + pub fn LLVMRustDIBuilderCreateTypedef<'a>( Builder: &DIBuilder<'a>, Type: &'a DIBasicType, Name: *const c_char, @@ -2177,7 +2124,7 @@ unsafe extern "C" { Scope: Option<&'a DIScope>, ) -> &'a DIDerivedType; - pub(crate) fn LLVMRustDIBuilderCreatePointerType<'a>( + pub fn LLVMRustDIBuilderCreatePointerType<'a>( Builder: &DIBuilder<'a>, PointeeTy: &'a DIType, SizeInBits: u64, @@ -2187,7 +2134,7 @@ unsafe extern "C" { NameLen: size_t, ) -> &'a DIDerivedType; - pub(crate) fn LLVMRustDIBuilderCreateStructType<'a>( + pub fn LLVMRustDIBuilderCreateStructType<'a>( Builder: &DIBuilder<'a>, Scope: Option<&'a DIDescriptor>, Name: *const c_char, @@ -2205,7 +2152,7 @@ unsafe extern "C" { UniqueIdLen: size_t, ) -> &'a DICompositeType; - pub(crate) fn LLVMRustDIBuilderCreateMemberType<'a>( + pub fn LLVMRustDIBuilderCreateMemberType<'a>( Builder: &DIBuilder<'a>, Scope: &'a DIDescriptor, Name: *const c_char, @@ -2219,7 +2166,7 @@ unsafe extern "C" { Ty: &'a DIType, ) -> &'a DIDerivedType; - pub(crate) fn LLVMRustDIBuilderCreateVariantMemberType<'a>( + pub fn LLVMRustDIBuilderCreateVariantMemberType<'a>( Builder: &DIBuilder<'a>, Scope: &'a DIScope, Name: *const c_char, @@ -2234,7 +2181,7 @@ unsafe extern "C" { Ty: &'a DIType, ) -> &'a DIType; - pub(crate) fn LLVMRustDIBuilderCreateStaticMemberType<'a>( + pub fn LLVMRustDIBuilderCreateStaticMemberType<'a>( Builder: &DIBuilder<'a>, Scope: &'a DIDescriptor, Name: *const c_char, @@ -2247,13 +2194,13 @@ unsafe extern "C" { AlignInBits: u32, ) -> &'a DIDerivedType; - pub(crate) fn LLVMRustDIBuilderCreateQualifiedType<'a>( + pub fn LLVMRustDIBuilderCreateQualifiedType<'a>( Builder: &DIBuilder<'a>, Tag: c_uint, Type: &'a DIType, ) -> &'a DIDerivedType; - pub(crate) fn LLVMRustDIBuilderCreateStaticVariable<'a>( + pub fn LLVMRustDIBuilderCreateStaticVariable<'a>( Builder: &DIBuilder<'a>, Context: Option<&'a DIScope>, Name: *const c_char, @@ -2269,7 +2216,7 @@ unsafe extern "C" { AlignInBits: u32, ) -> &'a DIGlobalVariableExpression; - pub(crate) fn LLVMRustDIBuilderCreateVariable<'a>( + pub fn LLVMRustDIBuilderCreateVariable<'a>( Builder: &DIBuilder<'a>, Tag: c_uint, Scope: &'a DIDescriptor, @@ -2284,7 +2231,7 @@ unsafe extern "C" { AlignInBits: u32, ) -> &'a DIVariable; - pub(crate) fn LLVMRustDIBuilderCreateArrayType<'a>( + pub fn LLVMRustDIBuilderCreateArrayType<'a>( Builder: &DIBuilder<'a>, Size: u64, AlignInBits: u32, @@ -2292,19 +2239,19 @@ unsafe extern "C" { Subscripts: &'a DIArray, ) -> &'a DIType; - pub(crate) fn LLVMRustDIBuilderGetOrCreateSubrange<'a>( + pub fn LLVMRustDIBuilderGetOrCreateSubrange<'a>( Builder: &DIBuilder<'a>, Lo: i64, Count: i64, ) -> &'a DISubrange; - pub(crate) fn LLVMRustDIBuilderGetOrCreateArray<'a>( + pub fn LLVMRustDIBuilderGetOrCreateArray<'a>( Builder: &DIBuilder<'a>, Ptr: *const Option<&'a DIDescriptor>, Count: c_uint, ) -> &'a DIArray; - pub(crate) fn LLVMRustDIBuilderInsertDeclareAtEnd<'a>( + pub fn LLVMRustDIBuilderInsertDeclareAtEnd<'a>( Builder: &DIBuilder<'a>, Val: &'a Value, VarInfo: &'a DIVariable, @@ -2314,7 +2261,7 @@ unsafe extern "C" { InsertAtEnd: &'a BasicBlock, ); - pub(crate) fn LLVMRustDIBuilderCreateEnumerator<'a>( + pub fn LLVMRustDIBuilderCreateEnumerator<'a>( Builder: &DIBuilder<'a>, Name: *const c_char, NameLen: size_t, @@ -2323,7 +2270,7 @@ unsafe extern "C" { IsUnsigned: bool, ) -> &'a DIEnumerator; - pub(crate) fn LLVMRustDIBuilderCreateEnumerationType<'a>( + pub fn LLVMRustDIBuilderCreateEnumerationType<'a>( Builder: &DIBuilder<'a>, Scope: &'a DIScope, Name: *const c_char, @@ -2337,7 +2284,7 @@ unsafe extern "C" { IsScoped: bool, ) -> &'a DIType; - pub(crate) fn LLVMRustDIBuilderCreateUnionType<'a>( + pub fn LLVMRustDIBuilderCreateUnionType<'a>( Builder: &DIBuilder<'a>, Scope: Option<&'a DIScope>, Name: *const c_char, @@ -2353,7 +2300,7 @@ unsafe extern "C" { UniqueIdLen: size_t, ) -> &'a DIType; - pub(crate) fn LLVMRustDIBuilderCreateVariantPart<'a>( + pub fn LLVMRustDIBuilderCreateVariantPart<'a>( Builder: &DIBuilder<'a>, Scope: &'a DIScope, Name: *const c_char, @@ -2369,7 +2316,7 @@ unsafe extern "C" { UniqueIdLen: size_t, ) -> &'a DIDerivedType; - pub(crate) fn LLVMRustDIBuilderCreateTemplateTypeParameter<'a>( + pub fn LLVMRustDIBuilderCreateTemplateTypeParameter<'a>( Builder: &DIBuilder<'a>, Scope: Option<&'a DIScope>, Name: *const c_char, @@ -2377,37 +2324,37 @@ unsafe extern "C" { Ty: &'a DIType, ) -> &'a DITemplateTypeParameter; - pub(crate) fn LLVMRustDICompositeTypeReplaceArrays<'a>( + pub fn LLVMRustDICompositeTypeReplaceArrays<'a>( Builder: &DIBuilder<'a>, CompositeType: &'a DIType, Elements: Option<&'a DIArray>, Params: Option<&'a DIArray>, ); - pub(crate) fn LLVMRustDILocationCloneWithBaseDiscriminator<'a>( + pub fn LLVMRustDILocationCloneWithBaseDiscriminator<'a>( Location: &'a DILocation, BD: c_uint, ) -> Option<&'a DILocation>; - pub(crate) fn LLVMRustWriteTypeToString(Type: &Type, s: &RustString); - pub(crate) fn LLVMRustWriteValueToString(value_ref: &Value, s: &RustString); + pub fn LLVMRustWriteTypeToString(Type: &Type, s: &RustString); + pub fn LLVMRustWriteValueToString(value_ref: &Value, s: &RustString); - pub(crate) fn LLVMRustHasFeature(T: &TargetMachine, s: *const c_char) -> bool; + pub fn LLVMRustHasFeature(T: &TargetMachine, s: *const c_char) -> bool; - pub(crate) fn LLVMRustPrintTargetCPUs(TM: &TargetMachine, OutStr: &RustString); - pub(crate) fn LLVMRustGetTargetFeaturesCount(T: &TargetMachine) -> size_t; - pub(crate) fn LLVMRustGetTargetFeature( + pub fn LLVMRustPrintTargetCPUs(TM: &TargetMachine, OutStr: &RustString); + pub fn LLVMRustGetTargetFeaturesCount(T: &TargetMachine) -> size_t; + pub fn LLVMRustGetTargetFeature( T: &TargetMachine, Index: size_t, Feature: &mut *const c_char, Desc: &mut *const c_char, ); - pub(crate) fn LLVMRustGetHostCPUName(LenOut: &mut size_t) -> *const u8; + pub fn LLVMRustGetHostCPUName(LenOut: &mut size_t) -> *const u8; // This function makes copies of pointed to data, so the data's lifetime may end after this // function returns. - pub(crate) fn LLVMRustCreateTargetMachine( + pub fn LLVMRustCreateTargetMachine( Triple: *const c_char, CPU: *const c_char, Features: *const c_char, @@ -2433,13 +2380,13 @@ unsafe extern "C" { ArgsCstrBuffLen: usize, ) -> *mut TargetMachine; - pub(crate) fn LLVMRustDisposeTargetMachine(T: *mut TargetMachine); - pub(crate) fn LLVMRustAddLibraryInfo<'a>( + pub fn LLVMRustDisposeTargetMachine(T: *mut TargetMachine); + pub fn LLVMRustAddLibraryInfo<'a>( PM: &PassManager<'a>, M: &'a Module, DisableSimplifyLibCalls: bool, ); - pub(crate) fn LLVMRustWriteOutputFile<'a>( + pub fn LLVMRustWriteOutputFile<'a>( T: &'a TargetMachine, PM: *mut PassManager<'a>, M: &'a Module, @@ -2448,7 +2395,7 @@ unsafe extern "C" { FileType: FileType, VerifyIR: bool, ) -> LLVMRustResult; - pub(crate) fn LLVMRustOptimize<'a>( + pub fn LLVMRustOptimize<'a>( M: &'a Module, TM: &'a TargetMachine, OptLevel: PassBuilderOptLevel, @@ -2485,32 +2432,29 @@ unsafe extern "C" { LLVMPlugins: *const c_char, LLVMPluginsLen: size_t, ) -> LLVMRustResult; - pub(crate) fn LLVMRustPrintModule( + pub fn LLVMRustPrintModule( M: &Module, Output: *const c_char, Demangle: extern "C" fn(*const c_char, size_t, *mut c_char, size_t) -> size_t, ) -> LLVMRustResult; - pub(crate) fn LLVMRustSetLLVMOptions(Argc: c_int, Argv: *const *const c_char); - pub(crate) fn LLVMRustPrintPasses(); - pub(crate) fn LLVMRustSetNormalizedTarget(M: &Module, triple: *const c_char); - pub(crate) fn LLVMRustRunRestrictionPass(M: &Module, syms: *const *const c_char, len: size_t); - - pub(crate) fn LLVMRustOpenArchive(path: *const c_char) -> Option<&'static mut Archive>; - pub(crate) fn LLVMRustArchiveIteratorNew(AR: &Archive) -> &mut ArchiveIterator<'_>; - pub(crate) fn LLVMRustArchiveIteratorNext<'a>( + pub fn LLVMRustSetLLVMOptions(Argc: c_int, Argv: *const *const c_char); + pub fn LLVMRustPrintPasses(); + pub fn LLVMRustSetNormalizedTarget(M: &Module, triple: *const c_char); + pub fn LLVMRustRunRestrictionPass(M: &Module, syms: *const *const c_char, len: size_t); + + pub fn LLVMRustOpenArchive(path: *const c_char) -> Option<&'static mut Archive>; + pub fn LLVMRustArchiveIteratorNew(AR: &Archive) -> &mut ArchiveIterator<'_>; + pub fn LLVMRustArchiveIteratorNext<'a>( AIR: &ArchiveIterator<'a>, ) -> Option<&'a mut ArchiveChild<'a>>; - pub(crate) fn LLVMRustArchiveChildName( - ACR: &ArchiveChild<'_>, - size: &mut size_t, - ) -> *const c_char; - pub(crate) fn LLVMRustArchiveChildFree<'a>(ACR: &'a mut ArchiveChild<'a>); - pub(crate) fn LLVMRustArchiveIteratorFree<'a>(AIR: &'a mut ArchiveIterator<'a>); - pub(crate) fn LLVMRustDestroyArchive(AR: &'static mut Archive); + pub fn LLVMRustArchiveChildName(ACR: &ArchiveChild<'_>, size: &mut size_t) -> *const c_char; + pub fn LLVMRustArchiveChildFree<'a>(ACR: &'a mut ArchiveChild<'a>); + pub fn LLVMRustArchiveIteratorFree<'a>(AIR: &'a mut ArchiveIterator<'a>); + pub fn LLVMRustDestroyArchive(AR: &'static mut Archive); - pub(crate) fn LLVMRustWriteTwineToString(T: &Twine, s: &RustString); + pub fn LLVMRustWriteTwineToString(T: &Twine, s: &RustString); - pub(crate) fn LLVMRustUnpackOptimizationDiagnostic<'a>( + pub fn LLVMRustUnpackOptimizationDiagnostic<'a>( DI: &'a DiagnosticInfo, pass_name_out: &RustString, function_out: &mut Option<&'a Value>, @@ -2520,22 +2464,22 @@ unsafe extern "C" { message_out: &RustString, ); - pub(crate) fn LLVMRustUnpackInlineAsmDiagnostic<'a>( + pub fn LLVMRustUnpackInlineAsmDiagnostic<'a>( DI: &'a DiagnosticInfo, level_out: &mut DiagnosticLevel, cookie_out: &mut u64, message_out: &mut Option<&'a Twine>, ); - pub(crate) fn LLVMRustWriteDiagnosticInfoToString(DI: &DiagnosticInfo, s: &RustString); - pub(crate) fn LLVMRustGetDiagInfoKind(DI: &DiagnosticInfo) -> DiagnosticKind; + pub fn LLVMRustWriteDiagnosticInfoToString(DI: &DiagnosticInfo, s: &RustString); + pub fn LLVMRustGetDiagInfoKind(DI: &DiagnosticInfo) -> DiagnosticKind; - pub(crate) fn LLVMRustGetSMDiagnostic<'a>( + pub fn LLVMRustGetSMDiagnostic<'a>( DI: &'a DiagnosticInfo, cookie_out: &mut u64, ) -> &'a SMDiagnostic; - pub(crate) fn LLVMRustUnpackSMDiagnostic( + pub fn LLVMRustUnpackSMDiagnostic( d: &SMDiagnostic, message_out: &RustString, buffer_out: &RustString, @@ -2545,7 +2489,7 @@ unsafe extern "C" { num_ranges: &mut usize, ) -> bool; - pub(crate) fn LLVMRustWriteArchive( + pub fn LLVMRustWriteArchive( Dst: *const c_char, NumMembers: size_t, Members: *const &RustArchiveMember<'_>, @@ -2553,63 +2497,63 @@ unsafe extern "C" { Kind: ArchiveKind, isEC: bool, ) -> LLVMRustResult; - pub(crate) fn LLVMRustArchiveMemberNew<'a>( + pub fn LLVMRustArchiveMemberNew<'a>( Filename: *const c_char, Name: *const c_char, Child: Option<&ArchiveChild<'a>>, ) -> &'a mut RustArchiveMember<'a>; - pub(crate) fn LLVMRustArchiveMemberFree<'a>(Member: &'a mut RustArchiveMember<'a>); + pub fn LLVMRustArchiveMemberFree<'a>(Member: &'a mut RustArchiveMember<'a>); - pub(crate) fn LLVMRustSetDataLayoutFromTargetMachine<'a>(M: &'a Module, TM: &'a TargetMachine); + pub fn LLVMRustSetDataLayoutFromTargetMachine<'a>(M: &'a Module, TM: &'a TargetMachine); - pub(crate) fn LLVMRustPositionBuilderAtStart<'a>(B: &Builder<'a>, BB: &'a BasicBlock); + pub fn LLVMRustPositionBuilderAtStart<'a>(B: &Builder<'a>, BB: &'a BasicBlock); - pub(crate) fn LLVMRustSetModulePICLevel(M: &Module); - pub(crate) fn LLVMRustSetModulePIELevel(M: &Module); - pub(crate) fn LLVMRustSetModuleCodeModel(M: &Module, Model: CodeModel); - pub(crate) fn LLVMRustModuleBufferCreate(M: &Module) -> &'static mut ModuleBuffer; - pub(crate) fn LLVMRustModuleBufferPtr(p: &ModuleBuffer) -> *const u8; - pub(crate) fn LLVMRustModuleBufferLen(p: &ModuleBuffer) -> usize; - pub(crate) fn LLVMRustModuleBufferFree(p: &'static mut ModuleBuffer); - pub(crate) fn LLVMRustModuleCost(M: &Module) -> u64; - pub(crate) fn LLVMRustModuleInstructionStats(M: &Module, Str: &RustString); + pub fn LLVMRustSetModulePICLevel(M: &Module); + pub fn LLVMRustSetModulePIELevel(M: &Module); + pub fn LLVMRustSetModuleCodeModel(M: &Module, Model: CodeModel); + pub fn LLVMRustModuleBufferCreate(M: &Module) -> &'static mut ModuleBuffer; + pub fn LLVMRustModuleBufferPtr(p: &ModuleBuffer) -> *const u8; + pub fn LLVMRustModuleBufferLen(p: &ModuleBuffer) -> usize; + pub fn LLVMRustModuleBufferFree(p: &'static mut ModuleBuffer); + pub fn LLVMRustModuleCost(M: &Module) -> u64; + pub fn LLVMRustModuleInstructionStats(M: &Module, Str: &RustString); - pub(crate) fn LLVMRustThinLTOBufferCreate( + pub fn LLVMRustThinLTOBufferCreate( M: &Module, is_thin: bool, emit_summary: bool, ) -> &'static mut ThinLTOBuffer; - pub(crate) fn LLVMRustThinLTOBufferFree(M: &'static mut ThinLTOBuffer); - pub(crate) fn LLVMRustThinLTOBufferPtr(M: &ThinLTOBuffer) -> *const c_char; - pub(crate) fn LLVMRustThinLTOBufferLen(M: &ThinLTOBuffer) -> size_t; - pub(crate) fn LLVMRustThinLTOBufferThinLinkDataPtr(M: &ThinLTOBuffer) -> *const c_char; - pub(crate) fn LLVMRustThinLTOBufferThinLinkDataLen(M: &ThinLTOBuffer) -> size_t; - pub(crate) fn LLVMRustCreateThinLTOData( + pub fn LLVMRustThinLTOBufferFree(M: &'static mut ThinLTOBuffer); + pub fn LLVMRustThinLTOBufferPtr(M: &ThinLTOBuffer) -> *const c_char; + pub fn LLVMRustThinLTOBufferLen(M: &ThinLTOBuffer) -> size_t; + pub fn LLVMRustThinLTOBufferThinLinkDataPtr(M: &ThinLTOBuffer) -> *const c_char; + pub fn LLVMRustThinLTOBufferThinLinkDataLen(M: &ThinLTOBuffer) -> size_t; + pub fn LLVMRustCreateThinLTOData( Modules: *const ThinLTOModule, NumModules: size_t, PreservedSymbols: *const *const c_char, PreservedSymbolsLen: size_t, ) -> Option<&'static mut ThinLTOData>; - pub(crate) fn LLVMRustPrepareThinLTORename( + pub fn LLVMRustPrepareThinLTORename( Data: &ThinLTOData, Module: &Module, Target: &TargetMachine, ); - pub(crate) fn LLVMRustPrepareThinLTOResolveWeak(Data: &ThinLTOData, Module: &Module) -> bool; - pub(crate) fn LLVMRustPrepareThinLTOInternalize(Data: &ThinLTOData, Module: &Module) -> bool; - pub(crate) fn LLVMRustPrepareThinLTOImport( + pub fn LLVMRustPrepareThinLTOResolveWeak(Data: &ThinLTOData, Module: &Module) -> bool; + pub fn LLVMRustPrepareThinLTOInternalize(Data: &ThinLTOData, Module: &Module) -> bool; + pub fn LLVMRustPrepareThinLTOImport( Data: &ThinLTOData, Module: &Module, Target: &TargetMachine, ) -> bool; - pub(crate) fn LLVMRustFreeThinLTOData(Data: &'static mut ThinLTOData); - pub(crate) fn LLVMRustParseBitcodeForLTO( + pub fn LLVMRustFreeThinLTOData(Data: &'static mut ThinLTOData); + pub fn LLVMRustParseBitcodeForLTO( Context: &Context, Data: *const u8, len: usize, Identifier: *const c_char, ) -> Option<&Module>; - pub(crate) fn LLVMRustGetSliceFromObjectDataByName( + pub fn LLVMRustGetSliceFromObjectDataByName( data: *const u8, len: usize, name: *const u8, @@ -2617,27 +2561,25 @@ unsafe extern "C" { out_len: &mut usize, ) -> *const u8; - pub(crate) fn LLVMRustLinkerNew(M: &Module) -> &mut Linker<'_>; - pub(crate) fn LLVMRustLinkerAdd( + pub fn LLVMRustLinkerNew(M: &Module) -> &mut Linker<'_>; + pub fn LLVMRustLinkerAdd( linker: &Linker<'_>, bytecode: *const c_char, bytecode_len: usize, ) -> bool; - pub(crate) fn LLVMRustLinkerFree<'a>(linker: &'a mut Linker<'a>); - pub(crate) fn LLVMRustComputeLTOCacheKey( + pub fn LLVMRustLinkerFree<'a>(linker: &'a mut Linker<'a>); + pub fn LLVMRustComputeLTOCacheKey( key_out: &RustString, mod_id: *const c_char, data: &ThinLTOData, ); - pub(crate) fn LLVMRustContextGetDiagnosticHandler( - Context: &Context, - ) -> Option<&DiagnosticHandler>; - pub(crate) fn LLVMRustContextSetDiagnosticHandler( + pub fn LLVMRustContextGetDiagnosticHandler(Context: &Context) -> Option<&DiagnosticHandler>; + pub fn LLVMRustContextSetDiagnosticHandler( context: &Context, diagnostic_handler: Option<&DiagnosticHandler>, ); - pub(crate) fn LLVMRustContextConfigureDiagnosticHandler( + pub fn LLVMRustContextConfigureDiagnosticHandler( context: &Context, diagnostic_handler_callback: DiagnosticHandlerTy, diagnostic_handler_context: *mut c_void, @@ -2648,15 +2590,15 @@ unsafe extern "C" { pgo_available: bool, ); - pub(crate) fn LLVMRustGetMangledName(V: &Value, out: &RustString); + pub fn LLVMRustGetMangledName(V: &Value, out: &RustString); - pub(crate) fn LLVMRustGetElementTypeArgIndex(CallSite: &Value) -> i32; + pub fn LLVMRustGetElementTypeArgIndex(CallSite: &Value) -> i32; - pub(crate) fn LLVMRustLLVMHasZlibCompressionForDebugSymbols() -> bool; + pub fn LLVMRustLLVMHasZlibCompressionForDebugSymbols() -> bool; - pub(crate) fn LLVMRustLLVMHasZstdCompressionForDebugSymbols() -> bool; + pub fn LLVMRustLLVMHasZstdCompressionForDebugSymbols() -> bool; - pub(crate) fn LLVMRustGetSymbols( + pub fn LLVMRustGetSymbols( buf_ptr: *const u8, buf_len: usize, state: *mut c_void, @@ -2664,10 +2606,10 @@ unsafe extern "C" { error_callback: GetSymbolsErrorCallback, ) -> *mut c_void; - pub(crate) fn LLVMRustIs64BitSymbolicFile(buf_ptr: *const u8, buf_len: usize) -> bool; + pub fn LLVMRustIs64BitSymbolicFile(buf_ptr: *const u8, buf_len: usize) -> bool; - pub(crate) fn LLVMRustIsECObject(buf_ptr: *const u8, buf_len: usize) -> bool; + pub fn LLVMRustIsECObject(buf_ptr: *const u8, buf_len: usize) -> bool; - pub(crate) fn LLVMRustSetNoSanitizeAddress(Global: &Value); - pub(crate) fn LLVMRustSetNoSanitizeHWAddress(Global: &Value); + pub fn LLVMRustSetNoSanitizeAddress(Global: &Value); + pub fn LLVMRustSetNoSanitizeHWAddress(Global: &Value); } diff --git a/compiler/rustc_llvm/src/impls.rs b/compiler/rustc_llvm/src/impls.rs new file mode 100644 index 0000000000000..1c80cd231f35b --- /dev/null +++ b/compiler/rustc_llvm/src/impls.rs @@ -0,0 +1,77 @@ +use std::hash::{Hash, Hasher}; +use std::string::FromUtf8Error; +use std::{fmt, ptr}; + +fn build_string(f: impl FnOnce(&crate::RustString)) -> Result { + String::from_utf8(crate::RustString::build_byte_buffer(f)) +} + +impl PartialEq for crate::ffi::Metadata { + fn eq(&self, other: &Self) -> bool { + ptr::eq(self, other) + } +} + +impl Eq for crate::ffi::Metadata {} + +impl Hash for crate::ffi::Metadata { + fn hash(&self, hasher: &mut H) { + (self as *const Self).hash(hasher); + } +} + +impl fmt::Debug for crate::ffi::Metadata { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + (self as *const Self).fmt(f) + } +} + +impl PartialEq for crate::ffi::Type { + fn eq(&self, other: &Self) -> bool { + ptr::eq(self, other) + } +} + +impl Eq for crate::ffi::Type {} + +impl Hash for crate::ffi::Type { + fn hash(&self, state: &mut H) { + ptr::hash(self, state); + } +} + +impl fmt::Debug for crate::ffi::Type { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str( + &build_string(|s| unsafe { + crate::ffi::LLVMRustWriteTypeToString(self, s); + }) + .expect("non-UTF8 type description from LLVM"), + ) + } +} + +impl PartialEq for crate::ffi::Value { + fn eq(&self, other: &Self) -> bool { + ptr::eq(self, other) + } +} + +impl Eq for crate::ffi::Value {} + +impl Hash for crate::ffi::Value { + fn hash(&self, hasher: &mut H) { + (self as *const Self).hash(hasher); + } +} + +impl fmt::Debug for crate::ffi::Value { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str( + &build_string(|s| unsafe { + crate::ffi::LLVMRustWriteValueToString(self, s); + }) + .expect("non-UTF8 value description from LLVM"), + ) + } +} diff --git a/compiler/rustc_llvm/src/lib.rs b/compiler/rustc_llvm/src/lib.rs index ed5edeef1617d..a89da2fb52f19 100644 --- a/compiler/rustc_llvm/src/lib.rs +++ b/compiler/rustc_llvm/src/lib.rs @@ -11,6 +11,9 @@ use std::{ptr, slice}; use libc::size_t; +pub mod ffi; +mod impls; + unsafe extern "C" { /// Opaque type that allows C++ code to write bytes to a Rust-side buffer, /// in conjunction with `RawRustStringOstream`. Use this as `&RustString` diff --git a/triagebot.toml b/triagebot.toml index 4d13eaf1c84c8..b93066e126063 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -164,12 +164,7 @@ trigger_labels = [ "regression-from-stable-to-nightly", "I-unsound", ] -exclude_labels = [ - "P-*", - "T-infra", - "T-release", - "requires-nightly", -] +exclude_labels = ["P-*", "T-infra", "T-release", "requires-nightly"] [autolabel."T-rustdoc"] trigger_files = [ @@ -198,9 +193,7 @@ trigger_files = [ "src/doc/rustdoc.md", "src/doc/rustdoc/", ] -exclude_labels = [ - "T-*", -] +exclude_labels = ["T-*"] trigger_labels = [ "A-rustdoc-json", @@ -230,9 +223,7 @@ trigger_files = [ ] [autolabel."A-compiler-builtins"] -trigger_files = [ - "library/compiler-builtins", -] +trigger_files = ["library/compiler-builtins"] [autolabel."F-autodiff"] trigger_files = [ @@ -241,15 +232,11 @@ trigger_files = [ "compiler/rustc_ast/src/expand/autodiff_attrs.rs", "compiler/rustc_monomorphize/src/partitioning/autodiff.rs", "compiler/rustc_codegen_llvm/src/builder/autodiff.rs", - "compiler/rustc_codegen_llvm/src/llvm/enzyme_ffi.rs", + "compiler/rustc_llvm/src/ffi/enzyme/mod.rs", ] [autolabel."T-rustdoc-frontend"] -trigger_labels = [ - "A-rustdoc-search", - "A-rustdoc-ui", - "A-rustdoc-js", -] +trigger_labels = ["A-rustdoc-search", "A-rustdoc-ui", "A-rustdoc-js"] trigger_files = [ "src/librustdoc/html/", @@ -267,9 +254,7 @@ trigger_files = [ "tests/rustdoc-js-std", ] -trigger_labels = [ - "A-type-based-search", -] +trigger_labels = ["A-type-based-search"] [autolabel."T-compiler"] trigger_files = [ @@ -293,26 +278,17 @@ trigger_files = [ "tests/ui", "tests/ui-fulldeps", ] -exclude_labels = [ - "T-*", -] +exclude_labels = ["T-*"] -trigger_labels = [ - "D-*", - "A-diagnostics", -] +trigger_labels = ["D-*", "A-diagnostics"] [autolabel."A-diagnostics"] -trigger_labels = [ - "D-*", -] +trigger_labels = ["D-*"] [autolabel."A-lints"] -trigger_labels = [ - "L-*", -] +trigger_labels = ["L-*"] [autolabel."T-libs"] trigger_files = [ @@ -324,14 +300,10 @@ trigger_files = [ "library/stdarch", "library/test", ] -exclude_labels = [ - "T-*", -] +exclude_labels = ["T-*"] [autolabel."O-android"] -trigger_files = [ - "library/std/src/os/android" -] +trigger_files = ["library/std/src/os/android"] [autolabel."O-apple"] trigger_files = [ @@ -341,86 +313,58 @@ trigger_files = [ ] [autolabel."O-fuchsia"] -trigger_files = [ - "library/std/src/os/fuchsia" -] +trigger_files = ["library/std/src/os/fuchsia"] [autolabel."O-hermit"] -trigger_files = [ - "library/std/src/sys/pal/hermit", - "library/std/src/os/hermit" -] +trigger_files = ["library/std/src/sys/pal/hermit", "library/std/src/os/hermit"] [autolabel."O-ios"] -trigger_files = [ - "library/std/src/os/ios" -] +trigger_files = ["library/std/src/os/ios"] [autolabel."O-itron"] -trigger_files = [ - "library/std/src/sys/pal/itron" -] +trigger_files = ["library/std/src/sys/pal/itron"] [autolabel."O-linux"] -trigger_files = [ - "library/std/src/os/linux" -] +trigger_files = ["library/std/src/os/linux"] [autolabel."O-macos"] -trigger_files = [ - "library/std/src/os/macos", -] +trigger_files = ["library/std/src/os/macos"] [autolabel."O-netbsd"] -trigger_files = [ - "library/std/src/os/netbsd" -] +trigger_files = ["library/std/src/os/netbsd"] [autolabel."O-redox"] -trigger_files = [ - "library/std/src/os/redox" -] +trigger_files = ["library/std/src/os/redox"] [autolabel."O-SGX"] trigger_files = [ "library/std/src/sys/pal/sgx", - "library/std/src/os/fortanix_sgx" + "library/std/src/os/fortanix_sgx", ] [autolabel."O-solaris"] -trigger_files = [ - "library/std/src/os/solaris" -] +trigger_files = ["library/std/src/os/solaris"] [autolabel."O-solid"] -trigger_files = [ - "library/std/src/sys/pal/solid", - "library/std/src/os/solid" -] +trigger_files = ["library/std/src/sys/pal/solid", "library/std/src/os/solid"] [autolabel."O-unix"] -trigger_files = [ - "library/std/src/sys/pal/unix", - "library/std/src/os/unix" -] +trigger_files = ["library/std/src/sys/pal/unix", "library/std/src/os/unix"] [autolabel."O-wasi"] -trigger_files = [ - "library/std/src/sys/pal/wasi", - "library/std/src/os/wasi" -] +trigger_files = ["library/std/src/sys/pal/wasi", "library/std/src/os/wasi"] [autolabel."O-wasm"] trigger_files = [ "library/std/src/sys/pal/wasm", "library/std/src/os/wasi", - "library/std/src/os/wasip2" + "library/std/src/os/wasip2", ] [autolabel."O-windows"] trigger_files = [ "library/std/src/sys/pal/windows", - "library/std/src/os/windows" + "library/std/src/os/windows", ] [autolabel."T-bootstrap"] @@ -439,13 +383,11 @@ trigger_files = [ "src/tools/libcxx-version", "x.py", "x", - "x.ps1" + "x.ps1", ] [autolabel."A-bootstrap-stamp"] -trigger_files = [ - "src/bootstrap/src/utils/build_stamp.rs", -] +trigger_files = ["src/bootstrap/src/utils/build_stamp.rs"] [autolabel."T-infra"] trigger_files = [ @@ -456,22 +398,20 @@ trigger_files = [ ] [autolabel."T-style"] -trigger_files = [ - "src/doc/style-guide", -] +trigger_files = ["src/doc/style-guide"] [autolabel."A-translation"] trigger_files = [ "compiler/rustc_error_messages", "compiler/rustc_errors/src/translation.rs", - "compiler/rustc_macros/src/diagnostics" + "compiler/rustc_macros/src/diagnostics", ] [autolabel."A-query-system"] trigger_files = [ "compiler/rustc_query_system", "compiler/rustc_query_impl", - "compiler/rustc_macros/src/query.rs" + "compiler/rustc_macros/src/query.rs", ] [autolabel."A-testsuite"] @@ -488,9 +428,7 @@ trigger_files = [ ] [autolabel."A-tidy"] -trigger_files = [ - "src/tools/tidy", -] +trigger_files = ["src/tools/tidy"] [autolabel."A-meta"] trigger_files = [ @@ -507,25 +445,18 @@ trigger_files = [ "REUSE.toml", ".mailmap", ".git-blame-ignore-revs", - ".editorconfig" + ".editorconfig", ] [autolabel."T-release"] -trigger_files = [ - "RELEASES.md", - "src/stage0", - "src/version" -] +trigger_files = ["RELEASES.md", "src/stage0", "src/version"] [autolabel."S-waiting-on-review"] new_pr = true [autolabel."needs-triage"] new_issue = true -exclude_labels = [ - "C-tracking-issue", - "A-diagnostics", -] +exclude_labels = ["C-tracking-issue", "A-diagnostics"] [autolabel."WG-trait-system-refactor"] trigger_files = [ @@ -551,29 +482,20 @@ trigger_files = [ "tests/codegen/stack-probes-inline.rs", "tests/codegen/stack-protector.rs", "tests/ui/sanitizer", - "tests/ui/stack-protector" + "tests/ui/stack-protector", ] [autolabel."A-run-make"] -trigger_files = [ - "tests/run-make", - "src/tools/run-make-support" -] +trigger_files = ["tests/run-make", "src/tools/run-make-support"] [autolabel."A-compiletest"] -trigger_files = [ - "src/tools/compiletest" -] +trigger_files = ["src/tools/compiletest"] [autolabel."A-test-infra-minicore"] -trigger_files = [ - "tests/auxiliary/minicore.rs", -] +trigger_files = ["tests/auxiliary/minicore.rs"] [autolabel."A-rustc-dev-guide"] -trigger_files = [ - "src/doc/rustc-dev-guide", -] +trigger_files = ["src/doc/rustc-dev-guide"] [autolabel."A-LLVM"] trigger_files = [ @@ -600,28 +522,25 @@ message_on_reopen = "Issue #{number} has been reopened." [notify-zulip."beta-nominated".rustdoc] required_labels = ["T-rustdoc"] -zulip_stream = 266220 # #t-rustdoc +zulip_stream = 266220 # #t-rustdoc topic = "beta-nominated: #{number}" # Zulip polls may not be preceded by any other text and pings & short links inside # the title of a poll don't get recognized. Therefore we need to send two messages. -message_on_add = [ - """\ +message_on_add = ["""\ @*T-rustdoc* PR #{number} "{title}" has been nominated for beta backport. -""", - """\ +""", """\ /poll Approve beta backport of #{number}? approve decline don't know -""", -] +"""] message_on_remove = "PR #{number}'s beta-nomination has been removed." message_on_close = "PR #{number} has been closed. Thanks for participating!" message_on_reopen = "PR #{number} has been reopened. Pinging @*T-rustdoc*." [notify-zulip."beta-accepted".rustdoc] required_labels = ["T-rustdoc"] -zulip_stream = 266220 # #t-rustdoc +zulip_stream = 266220 # #t-rustdoc # Put it in the same thread as beta-nominated. topic = "beta-nominated: #{number}" message_on_add = "PR #{number} has been **accepted** for beta backport." @@ -631,29 +550,26 @@ message_on_reopen = "PR #{number} has been reopened. Pinging @*T-rustdoc*." [notify-zulip."stable-nominated".rustdoc] required_labels = ["T-rustdoc"] -zulip_stream = 266220 # #t-rustdoc +zulip_stream = 266220 # #t-rustdoc topic = "stable-nominated: #{number}" # Zulip polls may not be preceded by any other text and pings & short links inside # the title of a poll don't get recognized. Therefore we need to send two messages. -message_on_add = [ - """\ +message_on_add = ["""\ @*T-rustdoc* PR #{number} "{title}" has been nominated for stable backport. -""", - """\ +""", """\ /poll Approve stable backport of #{number}? approve approve (but does not justify new dot release on its own) decline don't know -""", -] +"""] message_on_remove = "PR #{number}'s stable-nomination has been removed." message_on_close = "PR #{number} has been closed. Thanks for participating!" message_on_reopen = "PR #{number} has been reopened. Pinging @*T-rustdoc*." [notify-zulip."stable-accepted".rustdoc] required_labels = ["T-rustdoc"] -zulip_stream = 266220 # #t-rustdoc +zulip_stream = 266220 # #t-rustdoc # Put it in the same thread as stable-nominated. topic = "stable-nominated: #{number}" message_on_add = "PR #{number} has been **accepted** for stable backport." @@ -675,35 +591,29 @@ message_on_reopen = "Issue #{number} has been reopened. Pinging @*T-types*." required_labels = ["T-compiler"] zulip_stream = 474880 # #t-compiler/backports topic = "#{number}: beta-nominated" -message_on_add = [ - """\ +message_on_add = ["""\ @**channel** PR #{number} "{title}" has been nominated for beta backport. -""", - """\ +""", """\ /poll Approve beta backport of #{number}? approve decline don't know -""", -] +"""] message_on_remove = "PR #{number}'s beta-nomination has been removed." [notify-zulip."stable-nominated".compiler] required_labels = ["T-compiler"] zulip_stream = 474880 # #t-compiler/backports topic = "#{number}: stable-nominated" -message_on_add = [ - """\ +message_on_add = ["""\ @**channel** PR #{number} "{title}" has been nominated for stable backport. -""", - """\ +""", """\ /poll Approve stable backport of #{number}? approve approve (but does not justify new dot release on its own) decline don't know -""", -] +"""] message_on_remove = "PR #{number}'s stable-nomination has been removed." [notify-zulip."beta-nominated".bootstrap] @@ -887,7 +797,13 @@ message = """ Some changes occurred to the platform-builtins intrinsics. Make sure the LLVM backend as well as portable-simd gets adapted for the changes. """ -cc = ["@antoyo", "@GuillaumeGomez", "@bjorn3", "@calebzulawski", "@programmerjake"] +cc = [ + "@antoyo", + "@GuillaumeGomez", + "@bjorn3", + "@calebzulawski", + "@programmerjake", +] [mentions."library/core/src/intrinsics"] message = """ @@ -915,11 +831,7 @@ instead of editing the library source file manually. [mentions."src/librustdoc/html/static"] message = "Some changes occurred in HTML/CSS/JS." -cc = [ - "@GuillaumeGomez", - "@jsha", - "@lolbinarycat", -] +cc = ["@GuillaumeGomez", "@jsha", "@lolbinarycat"] [mentions."tests/rustdoc-gui/"] message = "Some changes occurred in GUI tests." @@ -939,12 +851,7 @@ rustdoc-json-types is a **public** (although nightly-only) API. \ If possible, consider changing `src/librustdoc/json/conversions.rs`; \ otherwise, make sure you bump the `FORMAT_VERSION` constant. """ -cc = [ - "@CraftSpider", - "@aDotInTheVoid", - "@Enselic", - "@obi1kenobi", -] +cc = ["@CraftSpider", "@aDotInTheVoid", "@Enselic", "@obi1kenobi"] [mentions."src/tools/cargo"] cc = ["@ehuss"] @@ -1193,7 +1100,7 @@ cc = ["@ZuseZ4"] cc = ["@ZuseZ4"] [mentions."compiler/rustc_codegen_llvm/src/builder/autodiff.rs"] cc = ["@ZuseZ4"] -[mentions."compiler/rustc_codegen_llvm/src/llvm/enzyme_ffi.rs"] +[mentions."compiler/rustc_llvm/src/ffi/enzyme/mod.rs"] cc = ["@ZuseZ4"] [mentions."library/core/src/fmt/rt.rs"] @@ -1214,10 +1121,7 @@ title = "[stable" branch = "stable" [assign.adhoc_groups] -compiler_leads = [ - "@davidtwco", - "@wesleywiser", -] +compiler_leads = ["@davidtwco", "@wesleywiser"] compiler = [ "@BoxyUwU", "@compiler-errors", @@ -1284,26 +1188,10 @@ parser = [ "@petrochenkov", "@spastorino", ] -lexer = [ - "@nnethercote", - "@petrochenkov", - "@chenyukang", -] -arena = [ - "@nnethercote", - "@spastorino", -] -mir = [ - "@davidtwco", - "@oli-obk", - "@matthewjasper", - "@saethlin", -] -mir-opt = [ - "@oli-obk", - "@wesleywiser", - "@saethlin", -] +lexer = ["@nnethercote", "@petrochenkov", "@chenyukang"] +arena = ["@nnethercote", "@spastorino"] +mir = ["@davidtwco", "@oli-obk", "@matthewjasper", "@saethlin"] +mir-opt = ["@oli-obk", "@wesleywiser", "@saethlin"] types = [ "@compiler-errors", "@jackh726", @@ -1312,127 +1200,115 @@ types = [ "@spastorino", "@BoxyUwU", ] -borrowck = [ - "@davidtwco", - "@matthewjasper" -] -ast_lowering = [ - "@compiler-errors", - "@spastorino", -] -debuginfo = [ - "@davidtwco" -] -fallback = [ - "@Mark-Simulacrum" -] -style-team = [ - "@calebcartwright", - "@compiler-errors", - "@joshtriplett", - "@yaahc", -] -project-const-traits = [ - "@compiler-errors", - "@fee1-dead", - "@fmease", - "@oli-obk", +borrowck = ["@davidtwco", "@matthewjasper"] +ast_lowering = ["@compiler-errors", "@spastorino"] +debuginfo = ["@davidtwco"] +fallback = ["@Mark-Simulacrum"] +style-team = ["@calebcartwright", "@compiler-errors", "@joshtriplett", "@yaahc"] +project-const-traits = ["@compiler-errors", "@fee1-dead", "@fmease", "@oli-obk"] +project-stable-mir = ["@celinval", "@oli-obk", "@scottmcm"] +project-exploit-mitigations = ["@cuviper", "@rcvalle"] +compiletest = ["@jieyouxu"] + +[assign.owners] +"/.github/workflows" = ["infra-ci"] +"/Cargo.lock" = ["@Mark-Simulacrum"] +"/Cargo.toml" = ["@Mark-Simulacrum"] +"/compiler" = ["compiler"] +"/compiler/rustc_abi" = ["compiler", "codegen"] +"/compiler/rustc_arena" = ["compiler", "arena"] +"/compiler/rustc_ast" = ["compiler", "parser"] +"/compiler/rustc_ast_lowering" = ["compiler", "ast_lowering"] +"/compiler/rustc_data_structures/src/stable_hasher.rs" = [ + "compiler", + "incremental", +] +"/compiler/rustc_hir_analysis" = ["compiler", "types"] +"/compiler/rustc_incremental" = ["compiler", "incremental"] +"/compiler/rustc_borrowck" = ["compiler", "borrowck"] +"/compiler/rustc_lexer" = ["compiler", "lexer"] +"/compiler/rustc_llvm" = ["@cuviper"] +"/compiler/rustc_codegen_llvm/src/debuginfo" = ["compiler", "debuginfo"] +"/compiler/rustc_codegen_ssa" = ["compiler", "codegen"] +"/compiler/rustc_middle/src/mir" = ["compiler", "mir"] +"/compiler/rustc_middle/src/traits" = ["compiler", "types"] +"/compiler/rustc_middle/src/ty" = ["compiler", "types"] +"/compiler/rustc_const_eval/src/interpret" = ["compiler", "mir"] +"/compiler/rustc_mir_build/src/builder" = ["compiler", "mir"] +"/compiler/rustc_mir_transform" = ["compiler", "mir", "mir-opt"] +"/compiler/rustc_smir" = ["project-stable-mir"] +"/compiler/rustc_parse" = ["compiler", "parser"] +"/compiler/rustc_parse/src/lexer" = ["compiler", "lexer"] +"/compiler/rustc_query_impl" = ["compiler", "query-system"] +"/compiler/rustc_query_system" = ["compiler", "query-system"] +"/compiler/rustc_query_system/src/dep_graph" = [ + "compiler", + "incremental", + "query-system", ] -project-stable-mir = [ - "@celinval", +"/compiler/rustc_query_system/src/ich" = [ + "compiler", + "incremental", + "query-system", +] +"/compiler/rustc_trait_selection" = ["compiler", "types"] +"/compiler/rustc_traits" = ["compiler", "types"] +"/compiler/rustc_type_ir" = ["compiler", "types"] +"/compiler/stable_mir" = ["project-stable-mir"] +"/library/alloc" = ["libs"] +"/library/core" = ["libs", "@scottmcm"] +"/library/panic_abort" = ["libs"] +"/library/panic_unwind" = ["libs"] +"/library/proc_macro" = ["@petrochenkov"] +"/library/std" = ["libs", "@ChrisDenton"] +"/library/std/src/sys/pal/windows" = ["@ChrisDenton"] +"/library/stdarch" = ["libs"] +"/library/test" = ["libs"] +"/src/bootstrap" = ["bootstrap"] +"/src/ci" = ["infra-ci"] +"/src/doc" = ["docs"] +"/src/doc/book" = ["@ehuss"] +"/src/doc/edition-guide" = ["@ehuss"] +"/src/doc/embedded-book" = ["@ehuss"] +"/src/doc/nomicon" = ["@ehuss"] +"/src/doc/reference" = ["@ehuss"] +"/src/doc/rust-by-example" = ["@ehuss"] +"/src/doc/rustc" = ["compiler", "@ehuss"] +"/src/doc/rustc-dev-guide" = ["compiler"] +"/src/doc/rustdoc" = ["rustdoc"] +"/src/doc/style-guide" = ["style-team"] +"/src/doc/unstable-book" = ["compiler"] +"/src/etc" = ["@Mark-Simulacrum"] +"/src/librustdoc" = ["rustdoc"] +"/src/llvm-project" = ["@cuviper"] +"/src/rustdoc-json-types" = ["rustdoc"] +"/src/stage0" = ["bootstrap"] +"/tests/run-make" = ["@jieyouxu"] +"/tests/rustdoc" = ["rustdoc"] +"/tests/rustdoc-gui" = ["rustdoc"] +"/tests/rustdoc-js-std" = ["rustdoc"] +"/tests/rustdoc-js/" = ["rustdoc"] +"/tests/rustdoc-json" = ["@aDotInTheVoid"] +"/tests/rustdoc-ui" = ["rustdoc"] +"/tests/ui" = ["compiler"] +"/src/tools/cargo" = ["@ehuss"] +"/src/tools/compiletest" = [ + "bootstrap", + "@wesleywiser", "@oli-obk", - "@scottmcm", -] -project-exploit-mitigations = [ - "@cuviper", - "@rcvalle", -] -compiletest = [ + "@compiler-errors", "@jieyouxu", ] - -[assign.owners] -"/.github/workflows" = ["infra-ci"] -"/Cargo.lock" = ["@Mark-Simulacrum"] -"/Cargo.toml" = ["@Mark-Simulacrum"] -"/compiler" = ["compiler"] -"/compiler/rustc_abi" = ["compiler", "codegen"] -"/compiler/rustc_arena" = ["compiler", "arena"] -"/compiler/rustc_ast" = ["compiler", "parser"] -"/compiler/rustc_ast_lowering" = ["compiler", "ast_lowering"] -"/compiler/rustc_data_structures/src/stable_hasher.rs" = ["compiler", "incremental"] -"/compiler/rustc_hir_analysis" = ["compiler", "types"] -"/compiler/rustc_incremental" = ["compiler", "incremental"] -"/compiler/rustc_borrowck" = ["compiler", "borrowck"] -"/compiler/rustc_lexer" = ["compiler", "lexer"] -"/compiler/rustc_llvm" = ["@cuviper"] -"/compiler/rustc_codegen_llvm/src/debuginfo" = ["compiler", "debuginfo"] -"/compiler/rustc_codegen_ssa" = ["compiler", "codegen"] -"/compiler/rustc_middle/src/mir" = ["compiler", "mir"] -"/compiler/rustc_middle/src/traits" = ["compiler", "types"] -"/compiler/rustc_middle/src/ty" = ["compiler", "types"] -"/compiler/rustc_const_eval/src/interpret" = ["compiler", "mir"] -"/compiler/rustc_mir_build/src/builder" = ["compiler", "mir"] -"/compiler/rustc_mir_transform" = ["compiler", "mir", "mir-opt"] -"/compiler/rustc_smir" = ["project-stable-mir"] -"/compiler/rustc_parse" = ["compiler", "parser"] -"/compiler/rustc_parse/src/lexer" = ["compiler", "lexer"] -"/compiler/rustc_query_impl" = ["compiler", "query-system"] -"/compiler/rustc_query_system" = ["compiler", "query-system"] -"/compiler/rustc_query_system/src/dep_graph" = ["compiler", "incremental", "query-system"] -"/compiler/rustc_query_system/src/ich" = ["compiler", "incremental", "query-system"] -"/compiler/rustc_trait_selection" = ["compiler", "types"] -"/compiler/rustc_traits" = ["compiler", "types"] -"/compiler/rustc_type_ir" = ["compiler", "types"] -"/compiler/stable_mir" = ["project-stable-mir"] -"/library/alloc" = ["libs"] -"/library/core" = ["libs", "@scottmcm"] -"/library/panic_abort" = ["libs"] -"/library/panic_unwind" = ["libs"] -"/library/proc_macro" = ["@petrochenkov"] -"/library/std" = ["libs", "@ChrisDenton"] -"/library/std/src/sys/pal/windows" = ["@ChrisDenton"] -"/library/stdarch" = ["libs"] -"/library/test" = ["libs"] -"/src/bootstrap" = ["bootstrap"] -"/src/ci" = ["infra-ci"] -"/src/doc" = ["docs"] -"/src/doc/book" = ["@ehuss"] -"/src/doc/edition-guide" = ["@ehuss"] -"/src/doc/embedded-book" = ["@ehuss"] -"/src/doc/nomicon" = ["@ehuss"] -"/src/doc/reference" = ["@ehuss"] -"/src/doc/rust-by-example" = ["@ehuss"] -"/src/doc/rustc" = ["compiler", "@ehuss"] -"/src/doc/rustc-dev-guide" = ["compiler"] -"/src/doc/rustdoc" = ["rustdoc"] -"/src/doc/style-guide" = ["style-team"] -"/src/doc/unstable-book" = ["compiler"] -"/src/etc" = ["@Mark-Simulacrum"] -"/src/librustdoc" = ["rustdoc"] -"/src/llvm-project" = ["@cuviper"] -"/src/rustdoc-json-types" = ["rustdoc"] -"/src/stage0" = ["bootstrap"] -"/tests/run-make" = ["@jieyouxu"] -"/tests/rustdoc" = ["rustdoc"] -"/tests/rustdoc-gui" = ["rustdoc"] -"/tests/rustdoc-js-std" = ["rustdoc"] -"/tests/rustdoc-js/" = ["rustdoc"] -"/tests/rustdoc-json" = ["@aDotInTheVoid"] -"/tests/rustdoc-ui" = ["rustdoc"] -"/tests/ui" = ["compiler"] -"/src/tools/cargo" = ["@ehuss"] -"/src/tools/compiletest" = ["bootstrap", "@wesleywiser", "@oli-obk", "@compiler-errors", "@jieyouxu"] -"/src/tools/linkchecker" = ["@ehuss"] -"/src/tools/opt-dist" = ["@kobzol"] -"/src/tools/run-make-support" = ["@jieyouxu"] -"/src/tools/rust-installer" = ["bootstrap"] -"/src/tools/rustbook" = ["@ehuss"] -"/src/tools/rustdoc" = ["rustdoc"] -"/src/tools/rustdoc-js" = ["rustdoc"] -"/src/tools/rustdoc-themes" = ["rustdoc"] -"/src/tools/tidy" = ["bootstrap"] -"/src/tools/x" = ["bootstrap"] +"/src/tools/linkchecker" = ["@ehuss"] +"/src/tools/opt-dist" = ["@kobzol"] +"/src/tools/run-make-support" = ["@jieyouxu"] +"/src/tools/rust-installer" = ["bootstrap"] +"/src/tools/rustbook" = ["@ehuss"] +"/src/tools/rustdoc" = ["rustdoc"] +"/src/tools/rustdoc-js" = ["rustdoc"] +"/src/tools/rustdoc-themes" = ["rustdoc"] +"/src/tools/tidy" = ["bootstrap"] +"/src/tools/x" = ["bootstrap"] "/src/tools/rustdoc-gui-test" = ["bootstrap"] "/src/tools/libcxx-version" = ["bootstrap"]