mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 16:24:46 +00:00
Rollup merge of #130458 - nnethercote:rustc_codegen_ssa-cleanups, r=jieyouxu
`rustc_codegen_ssa` cleanups Just some minor improvements I found while reading through this code. r? ``@jieyouxu``
This commit is contained in:
commit
d5a081981d
@ -157,7 +157,7 @@ pub trait ArchiveBuilderBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn create_mingw_dll_import_lib(
|
||||
fn create_mingw_dll_import_lib(
|
||||
sess: &Session,
|
||||
lib_name: &str,
|
||||
import_name_and_ordinal_vector: Vec<(String, Option<u16>)>,
|
||||
|
@ -8,7 +8,7 @@ use std::{fmt, io, mem};
|
||||
use rustc_target::spec::LldFlavor;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Command {
|
||||
pub(crate) struct Command {
|
||||
program: Program,
|
||||
args: Vec<OsString>,
|
||||
env: Vec<(OsString, OsString)>,
|
||||
@ -23,15 +23,15 @@ enum Program {
|
||||
}
|
||||
|
||||
impl Command {
|
||||
pub fn new<P: AsRef<OsStr>>(program: P) -> Command {
|
||||
pub(crate) fn new<P: AsRef<OsStr>>(program: P) -> Command {
|
||||
Command::_new(Program::Normal(program.as_ref().to_owned()))
|
||||
}
|
||||
|
||||
pub fn bat_script<P: AsRef<OsStr>>(program: P) -> Command {
|
||||
pub(crate) fn bat_script<P: AsRef<OsStr>>(program: P) -> Command {
|
||||
Command::_new(Program::CmdBatScript(program.as_ref().to_owned()))
|
||||
}
|
||||
|
||||
pub fn lld<P: AsRef<OsStr>>(program: P, flavor: LldFlavor) -> Command {
|
||||
pub(crate) fn lld<P: AsRef<OsStr>>(program: P, flavor: LldFlavor) -> Command {
|
||||
Command::_new(Program::Lld(program.as_ref().to_owned(), flavor))
|
||||
}
|
||||
|
||||
@ -39,12 +39,12 @@ impl Command {
|
||||
Command { program, args: Vec::new(), env: Vec::new(), env_remove: Vec::new() }
|
||||
}
|
||||
|
||||
pub fn arg<P: AsRef<OsStr>>(&mut self, arg: P) -> &mut Command {
|
||||
pub(crate) fn arg<P: AsRef<OsStr>>(&mut self, arg: P) -> &mut Command {
|
||||
self._arg(arg.as_ref());
|
||||
self
|
||||
}
|
||||
|
||||
pub fn args<I>(&mut self, args: I) -> &mut Command
|
||||
pub(crate) fn args<I>(&mut self, args: I) -> &mut Command
|
||||
where
|
||||
I: IntoIterator<Item: AsRef<OsStr>>,
|
||||
{
|
||||
@ -58,7 +58,7 @@ impl Command {
|
||||
self.args.push(arg.to_owned());
|
||||
}
|
||||
|
||||
pub fn env<K, V>(&mut self, key: K, value: V) -> &mut Command
|
||||
pub(crate) fn env<K, V>(&mut self, key: K, value: V) -> &mut Command
|
||||
where
|
||||
K: AsRef<OsStr>,
|
||||
V: AsRef<OsStr>,
|
||||
@ -71,7 +71,7 @@ impl Command {
|
||||
self.env.push((key.to_owned(), value.to_owned()));
|
||||
}
|
||||
|
||||
pub fn env_remove<K>(&mut self, key: K) -> &mut Command
|
||||
pub(crate) fn env_remove<K>(&mut self, key: K) -> &mut Command
|
||||
where
|
||||
K: AsRef<OsStr>,
|
||||
{
|
||||
@ -83,11 +83,11 @@ impl Command {
|
||||
self.env_remove.push(key.to_owned());
|
||||
}
|
||||
|
||||
pub fn output(&mut self) -> io::Result<Output> {
|
||||
pub(crate) fn output(&mut self) -> io::Result<Output> {
|
||||
self.command().output()
|
||||
}
|
||||
|
||||
pub fn command(&self) -> process::Command {
|
||||
pub(crate) fn command(&self) -> process::Command {
|
||||
let mut ret = match self.program {
|
||||
Program::Normal(ref p) => process::Command::new(p),
|
||||
Program::CmdBatScript(ref p) => {
|
||||
@ -111,17 +111,17 @@ impl Command {
|
||||
|
||||
// extensions
|
||||
|
||||
pub fn get_args(&self) -> &[OsString] {
|
||||
pub(crate) fn get_args(&self) -> &[OsString] {
|
||||
&self.args
|
||||
}
|
||||
|
||||
pub fn take_args(&mut self) -> Vec<OsString> {
|
||||
pub(crate) fn take_args(&mut self) -> Vec<OsString> {
|
||||
mem::take(&mut self.args)
|
||||
}
|
||||
|
||||
/// Returns a `true` if we're pretty sure that this'll blow OS spawn limits,
|
||||
/// or `false` if we should attempt to spawn and see what the OS says.
|
||||
pub fn very_likely_to_exceed_some_spawn_limit(&self) -> bool {
|
||||
pub(crate) fn very_likely_to_exceed_some_spawn_limit(&self) -> bool {
|
||||
// We mostly only care about Windows in this method, on Unix the limits
|
||||
// can be gargantuan anyway so we're pretty unlikely to hit them
|
||||
if cfg!(unix) {
|
||||
|
@ -30,7 +30,7 @@ use crate::errors;
|
||||
/// and prevent inspection of linker output in case of errors, which we occasionally do.
|
||||
/// This should be acceptable because other messages from rustc are in English anyway,
|
||||
/// and may also be desirable to improve searchability of the linker diagnostics.
|
||||
pub fn disable_localization(linker: &mut Command) {
|
||||
pub(crate) fn disable_localization(linker: &mut Command) {
|
||||
// No harm in setting both env vars simultaneously.
|
||||
// Unix-style linkers.
|
||||
linker.env("LC_ALL", "C");
|
||||
@ -41,7 +41,7 @@ pub fn disable_localization(linker: &mut Command) {
|
||||
/// The third parameter is for env vars, used on windows to set up the
|
||||
/// path for MSVC to find its DLLs, and gcc to find its bundled
|
||||
/// toolchain
|
||||
pub fn get_linker<'a>(
|
||||
pub(crate) fn get_linker<'a>(
|
||||
sess: &'a Session,
|
||||
linker: &Path,
|
||||
flavor: LinkerFlavor,
|
||||
@ -215,28 +215,36 @@ fn link_or_cc_args<L: Linker + ?Sized>(
|
||||
macro_rules! generate_arg_methods {
|
||||
($($ty:ty)*) => { $(
|
||||
impl $ty {
|
||||
pub fn verbatim_args(&mut self, args: impl IntoIterator<Item: AsRef<OsStr>>) -> &mut Self {
|
||||
#[allow(unused)]
|
||||
pub(crate) fn verbatim_args(&mut self, args: impl IntoIterator<Item: AsRef<OsStr>>) -> &mut Self {
|
||||
verbatim_args(self, args)
|
||||
}
|
||||
pub fn verbatim_arg(&mut self, arg: impl AsRef<OsStr>) -> &mut Self {
|
||||
#[allow(unused)]
|
||||
pub(crate) fn verbatim_arg(&mut self, arg: impl AsRef<OsStr>) -> &mut Self {
|
||||
verbatim_args(self, iter::once(arg))
|
||||
}
|
||||
pub fn link_args(&mut self, args: impl IntoIterator<Item: AsRef<OsStr>, IntoIter: ExactSizeIterator>) -> &mut Self {
|
||||
#[allow(unused)]
|
||||
pub(crate) fn link_args(&mut self, args: impl IntoIterator<Item: AsRef<OsStr>, IntoIter: ExactSizeIterator>) -> &mut Self {
|
||||
link_args(self, args)
|
||||
}
|
||||
pub fn link_arg(&mut self, arg: impl AsRef<OsStr>) -> &mut Self {
|
||||
#[allow(unused)]
|
||||
pub(crate) fn link_arg(&mut self, arg: impl AsRef<OsStr>) -> &mut Self {
|
||||
link_args(self, iter::once(arg))
|
||||
}
|
||||
pub fn cc_args(&mut self, args: impl IntoIterator<Item: AsRef<OsStr>>) -> &mut Self {
|
||||
#[allow(unused)]
|
||||
pub(crate) fn cc_args(&mut self, args: impl IntoIterator<Item: AsRef<OsStr>>) -> &mut Self {
|
||||
cc_args(self, args)
|
||||
}
|
||||
pub fn cc_arg(&mut self, arg: impl AsRef<OsStr>) -> &mut Self {
|
||||
#[allow(unused)]
|
||||
pub(crate) fn cc_arg(&mut self, arg: impl AsRef<OsStr>) -> &mut Self {
|
||||
cc_args(self, iter::once(arg))
|
||||
}
|
||||
pub fn link_or_cc_args(&mut self, args: impl IntoIterator<Item: AsRef<OsStr>>) -> &mut Self {
|
||||
#[allow(unused)]
|
||||
pub(crate) fn link_or_cc_args(&mut self, args: impl IntoIterator<Item: AsRef<OsStr>>) -> &mut Self {
|
||||
link_or_cc_args(self, args)
|
||||
}
|
||||
pub fn link_or_cc_arg(&mut self, arg: impl AsRef<OsStr>) -> &mut Self {
|
||||
#[allow(unused)]
|
||||
pub(crate) fn link_or_cc_arg(&mut self, arg: impl AsRef<OsStr>) -> &mut Self {
|
||||
link_or_cc_args(self, iter::once(arg))
|
||||
}
|
||||
}
|
||||
@ -263,7 +271,7 @@ generate_arg_methods! {
|
||||
/// represents the meaning of each option being passed down. This trait is then
|
||||
/// used to dispatch on whether a GNU-like linker (generally `ld.exe`) or an
|
||||
/// MSVC linker (e.g., `link.exe`) is being used.
|
||||
pub trait Linker {
|
||||
pub(crate) trait Linker {
|
||||
fn cmd(&mut self) -> &mut Command;
|
||||
fn is_cc(&self) -> bool {
|
||||
false
|
||||
@ -314,12 +322,12 @@ pub trait Linker {
|
||||
}
|
||||
|
||||
impl dyn Linker + '_ {
|
||||
pub fn take_cmd(&mut self) -> Command {
|
||||
pub(crate) fn take_cmd(&mut self) -> Command {
|
||||
mem::replace(self.cmd(), Command::new(""))
|
||||
}
|
||||
}
|
||||
|
||||
pub struct GccLinker<'a> {
|
||||
struct GccLinker<'a> {
|
||||
cmd: Command,
|
||||
sess: &'a Session,
|
||||
target_cpu: &'a str,
|
||||
@ -849,7 +857,7 @@ impl<'a> Linker for GccLinker<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct MsvcLinker<'a> {
|
||||
struct MsvcLinker<'a> {
|
||||
cmd: Command,
|
||||
sess: &'a Session,
|
||||
}
|
||||
@ -1103,7 +1111,7 @@ impl<'a> Linker for MsvcLinker<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct EmLinker<'a> {
|
||||
struct EmLinker<'a> {
|
||||
cmd: Command,
|
||||
sess: &'a Session,
|
||||
}
|
||||
@ -1220,7 +1228,7 @@ impl<'a> Linker for EmLinker<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct WasmLd<'a> {
|
||||
struct WasmLd<'a> {
|
||||
cmd: Command,
|
||||
sess: &'a Session,
|
||||
}
|
||||
@ -1404,7 +1412,7 @@ impl<'a> WasmLd<'a> {
|
||||
}
|
||||
|
||||
/// Linker shepherd script for L4Re (Fiasco)
|
||||
pub struct L4Bender<'a> {
|
||||
struct L4Bender<'a> {
|
||||
cmd: Command,
|
||||
sess: &'a Session,
|
||||
hinted_static: bool,
|
||||
@ -1510,7 +1518,7 @@ impl<'a> Linker for L4Bender<'a> {
|
||||
}
|
||||
|
||||
impl<'a> L4Bender<'a> {
|
||||
pub fn new(cmd: Command, sess: &'a Session) -> L4Bender<'a> {
|
||||
fn new(cmd: Command, sess: &'a Session) -> L4Bender<'a> {
|
||||
L4Bender { cmd, sess, hinted_static: false }
|
||||
}
|
||||
|
||||
@ -1523,14 +1531,14 @@ impl<'a> L4Bender<'a> {
|
||||
}
|
||||
|
||||
/// Linker for AIX.
|
||||
pub struct AixLinker<'a> {
|
||||
struct AixLinker<'a> {
|
||||
cmd: Command,
|
||||
sess: &'a Session,
|
||||
hinted_static: Option<bool>,
|
||||
}
|
||||
|
||||
impl<'a> AixLinker<'a> {
|
||||
pub fn new(cmd: Command, sess: &'a Session) -> AixLinker<'a> {
|
||||
fn new(cmd: Command, sess: &'a Session) -> AixLinker<'a> {
|
||||
AixLinker { cmd, sess, hinted_static: None }
|
||||
}
|
||||
|
||||
@ -1758,7 +1766,7 @@ pub(crate) fn linked_symbols(
|
||||
|
||||
/// Much simplified and explicit CLI for the NVPTX linker. The linker operates
|
||||
/// with bitcode and uses LLVM backend to generate a PTX assembly.
|
||||
pub struct PtxLinker<'a> {
|
||||
struct PtxLinker<'a> {
|
||||
cmd: Command,
|
||||
sess: &'a Session,
|
||||
}
|
||||
@ -1824,7 +1832,7 @@ impl<'a> Linker for PtxLinker<'a> {
|
||||
}
|
||||
|
||||
/// The `self-contained` LLVM bitcode linker
|
||||
pub struct LlbcLinker<'a> {
|
||||
struct LlbcLinker<'a> {
|
||||
cmd: Command,
|
||||
sess: &'a Session,
|
||||
}
|
||||
@ -1895,7 +1903,7 @@ impl<'a> Linker for LlbcLinker<'a> {
|
||||
fn linker_plugin_lto(&mut self) {}
|
||||
}
|
||||
|
||||
pub struct BpfLinker<'a> {
|
||||
struct BpfLinker<'a> {
|
||||
cmd: Command,
|
||||
sess: &'a Session,
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ use rustc_target::spec::{ef_avr_arch, RelocModel, Target};
|
||||
/// <dd>The metadata can be found in the `.rustc` section of the shared library.</dd>
|
||||
/// </dl>
|
||||
#[derive(Debug)]
|
||||
pub struct DefaultMetadataLoader;
|
||||
pub(crate) struct DefaultMetadataLoader;
|
||||
|
||||
static AIX_METADATA_SYMBOL_NAME: &'static str = "__aix_rust_metadata";
|
||||
|
||||
@ -416,7 +416,7 @@ fn macho_is_arm64e(target: &Target) -> bool {
|
||||
target.llvm_target.starts_with("arm64e")
|
||||
}
|
||||
|
||||
pub enum MetadataPosition {
|
||||
pub(crate) enum MetadataPosition {
|
||||
First,
|
||||
Last,
|
||||
}
|
||||
@ -452,7 +452,7 @@ pub enum MetadataPosition {
|
||||
/// * ELF - All other targets are similar to Windows in that there's a
|
||||
/// `SHF_EXCLUDE` flag we can set on sections in an object file to get
|
||||
/// automatically removed from the final output.
|
||||
pub fn create_wrapper_file(
|
||||
pub(crate) fn create_wrapper_file(
|
||||
sess: &Session,
|
||||
section_name: String,
|
||||
data: &[u8],
|
||||
|
@ -1,9 +1,9 @@
|
||||
pub mod archive;
|
||||
pub mod command;
|
||||
pub(crate) mod command;
|
||||
pub mod link;
|
||||
pub mod linker;
|
||||
pub(crate) mod linker;
|
||||
pub mod lto;
|
||||
pub mod metadata;
|
||||
pub mod rpath;
|
||||
pub(crate) mod rpath;
|
||||
pub mod symbol_export;
|
||||
pub mod write;
|
||||
|
@ -6,14 +6,14 @@ use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_fs_util::try_canonicalize;
|
||||
use tracing::debug;
|
||||
|
||||
pub struct RPathConfig<'a> {
|
||||
pub(super) struct RPathConfig<'a> {
|
||||
pub libs: &'a [&'a Path],
|
||||
pub out_filename: PathBuf,
|
||||
pub is_like_osx: bool,
|
||||
pub linker_is_gnu: bool,
|
||||
}
|
||||
|
||||
pub fn get_rpath_flags(config: &RPathConfig<'_>) -> Vec<OsString> {
|
||||
pub(super) fn get_rpath_flags(config: &RPathConfig<'_>) -> Vec<OsString> {
|
||||
debug!("preparing the RPATH!");
|
||||
|
||||
let rpaths = get_rpaths(config);
|
||||
|
@ -18,7 +18,7 @@ use tracing::debug;
|
||||
|
||||
use crate::base::allocator_kind_for_codegen;
|
||||
|
||||
pub fn threshold(tcx: TyCtxt<'_>) -> SymbolExportLevel {
|
||||
fn threshold(tcx: TyCtxt<'_>) -> SymbolExportLevel {
|
||||
crates_export_threshold(tcx.crate_types())
|
||||
}
|
||||
|
||||
@ -484,7 +484,7 @@ fn is_unreachable_local_definition_provider(tcx: TyCtxt<'_>, def_id: LocalDefId)
|
||||
!tcx.reachable_set(()).contains(&def_id)
|
||||
}
|
||||
|
||||
pub fn provide(providers: &mut Providers) {
|
||||
pub(crate) fn provide(providers: &mut Providers) {
|
||||
providers.reachable_non_generics = reachable_non_generics_provider;
|
||||
providers.is_reachable_non_generic = is_reachable_non_generic_provider_local;
|
||||
providers.exported_symbols = exported_symbols_provider_local;
|
||||
@ -525,7 +525,7 @@ fn symbol_export_level(tcx: TyCtxt<'_>, sym_def_id: DefId) -> SymbolExportLevel
|
||||
}
|
||||
|
||||
/// This is the symbol name of the given instance instantiated in a specific crate.
|
||||
pub fn symbol_name_for_instance_in_crate<'tcx>(
|
||||
pub(crate) fn symbol_name_for_instance_in_crate<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
symbol: ExportedSymbol<'tcx>,
|
||||
instantiating_crate: CrateNum,
|
||||
@ -582,7 +582,7 @@ pub fn symbol_name_for_instance_in_crate<'tcx>(
|
||||
/// This is the symbol name of the given instance as seen by the linker.
|
||||
///
|
||||
/// On 32-bit Windows symbols are decorated according to their calling conventions.
|
||||
pub fn linking_symbol_name_for_instance_in_crate<'tcx>(
|
||||
pub(crate) fn linking_symbol_name_for_instance_in_crate<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
symbol: ExportedSymbol<'tcx>,
|
||||
instantiating_crate: CrateNum,
|
||||
@ -661,7 +661,7 @@ pub fn linking_symbol_name_for_instance_in_crate<'tcx>(
|
||||
format!("{prefix}{undecorated}{suffix}{args_in_bytes}")
|
||||
}
|
||||
|
||||
pub fn exporting_symbol_name_for_instance_in_crate<'tcx>(
|
||||
pub(crate) fn exporting_symbol_name_for_instance_in_crate<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
symbol: ExportedSymbol<'tcx>,
|
||||
cnum: CrateNum,
|
||||
|
@ -335,7 +335,7 @@ pub type TargetMachineFactoryFn<B> = Arc<
|
||||
+ Sync,
|
||||
>;
|
||||
|
||||
pub type ExportedSymbols = FxHashMap<CrateNum, Arc<Vec<(String, SymbolExportInfo)>>>;
|
||||
type ExportedSymbols = FxHashMap<CrateNum, Arc<Vec<(String, SymbolExportInfo)>>>;
|
||||
|
||||
/// Additional resources used by optimize_and_codegen (not module specific)
|
||||
#[derive(Clone)]
|
||||
@ -437,9 +437,9 @@ fn generate_lto_work<B: ExtraBackendMethods>(
|
||||
}
|
||||
}
|
||||
|
||||
pub struct CompiledModules {
|
||||
pub modules: Vec<CompiledModule>,
|
||||
pub allocator_module: Option<CompiledModule>,
|
||||
struct CompiledModules {
|
||||
modules: Vec<CompiledModule>,
|
||||
allocator_module: Option<CompiledModule>,
|
||||
}
|
||||
|
||||
fn need_bitcode_in_object(tcx: TyCtxt<'_>) -> bool {
|
||||
@ -462,7 +462,7 @@ fn need_pre_lto_bitcode_for_incr_comp(sess: &Session) -> bool {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn start_async_codegen<B: ExtraBackendMethods>(
|
||||
pub(crate) fn start_async_codegen<B: ExtraBackendMethods>(
|
||||
backend: B,
|
||||
tcx: TyCtxt<'_>,
|
||||
target_cpu: String,
|
||||
@ -836,13 +836,13 @@ pub enum FatLtoInput<B: WriteBackendMethods> {
|
||||
}
|
||||
|
||||
/// Actual LTO type we end up choosing based on multiple factors.
|
||||
pub enum ComputedLtoType {
|
||||
pub(crate) enum ComputedLtoType {
|
||||
No,
|
||||
Thin,
|
||||
Fat,
|
||||
}
|
||||
|
||||
pub fn compute_per_cgu_lto_type(
|
||||
pub(crate) fn compute_per_cgu_lto_type(
|
||||
sess_lto: &Lto,
|
||||
opts: &config::Options,
|
||||
sess_crate_types: &[CrateType],
|
||||
@ -1087,7 +1087,7 @@ struct Diagnostic {
|
||||
// A cut-down version of `rustc_errors::Subdiag` that impls `Send`. It's
|
||||
// missing the following fields from `rustc_errors::Subdiag`.
|
||||
// - `span`: it doesn't impl `Send`.
|
||||
pub struct Subdiagnostic {
|
||||
pub(crate) struct Subdiagnostic {
|
||||
level: Level,
|
||||
messages: Vec<(DiagMessage, Style)>,
|
||||
}
|
||||
@ -1779,7 +1779,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
|
||||
|
||||
/// `FatalError` is explicitly not `Send`.
|
||||
#[must_use]
|
||||
pub struct WorkerFatalError;
|
||||
pub(crate) struct WorkerFatalError;
|
||||
|
||||
fn spawn_work<'a, B: ExtraBackendMethods>(
|
||||
cgcx: &'a CodegenContext<B>,
|
||||
@ -1867,7 +1867,7 @@ pub struct SharedEmitterMain {
|
||||
}
|
||||
|
||||
impl SharedEmitter {
|
||||
pub fn new() -> (SharedEmitter, SharedEmitterMain) {
|
||||
fn new() -> (SharedEmitter, SharedEmitterMain) {
|
||||
let (sender, receiver) = channel();
|
||||
|
||||
(SharedEmitter { sender }, SharedEmitterMain { receiver })
|
||||
@ -1883,7 +1883,7 @@ impl SharedEmitter {
|
||||
drop(self.sender.send(SharedEmitterMessage::InlineAsmError(cookie, msg, level, source)));
|
||||
}
|
||||
|
||||
pub fn fatal(&self, msg: &str) {
|
||||
fn fatal(&self, msg: &str) {
|
||||
drop(self.sender.send(SharedEmitterMessage::Fatal(msg.to_string())));
|
||||
}
|
||||
}
|
||||
@ -1930,7 +1930,7 @@ impl Emitter for SharedEmitter {
|
||||
}
|
||||
|
||||
impl SharedEmitterMain {
|
||||
pub fn check(&self, sess: &Session, blocking: bool) {
|
||||
fn check(&self, sess: &Session, blocking: bool) {
|
||||
loop {
|
||||
let message = if blocking {
|
||||
match self.receiver.recv() {
|
||||
@ -2087,17 +2087,17 @@ impl<B: ExtraBackendMethods> OngoingCodegen<B> {
|
||||
)
|
||||
}
|
||||
|
||||
pub fn codegen_finished(&self, tcx: TyCtxt<'_>) {
|
||||
pub(crate) fn codegen_finished(&self, tcx: TyCtxt<'_>) {
|
||||
self.wait_for_signal_to_codegen_item();
|
||||
self.check_for_errors(tcx.sess);
|
||||
drop(self.coordinator.sender.send(Box::new(Message::CodegenComplete::<B>)));
|
||||
}
|
||||
|
||||
pub fn check_for_errors(&self, sess: &Session) {
|
||||
pub(crate) fn check_for_errors(&self, sess: &Session) {
|
||||
self.shared_emitter_main.check(sess, false);
|
||||
}
|
||||
|
||||
pub fn wait_for_signal_to_codegen_item(&self) {
|
||||
pub(crate) fn wait_for_signal_to_codegen_item(&self) {
|
||||
match self.codegen_worker_receive.recv() {
|
||||
Ok(CguMessage) => {
|
||||
// Ok to proceed.
|
||||
@ -2110,7 +2110,7 @@ impl<B: ExtraBackendMethods> OngoingCodegen<B> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn submit_codegened_module_to_llvm<B: ExtraBackendMethods>(
|
||||
pub(crate) fn submit_codegened_module_to_llvm<B: ExtraBackendMethods>(
|
||||
_backend: &B,
|
||||
tx_to_llvm_workers: &Sender<Box<dyn Any + Send>>,
|
||||
module: ModuleCodegen<B::Module>,
|
||||
@ -2120,7 +2120,7 @@ pub fn submit_codegened_module_to_llvm<B: ExtraBackendMethods>(
|
||||
drop(tx_to_llvm_workers.send(Box::new(Message::CodegenDone::<B> { llvm_work_item, cost })));
|
||||
}
|
||||
|
||||
pub fn submit_post_lto_module_to_llvm<B: ExtraBackendMethods>(
|
||||
pub(crate) fn submit_post_lto_module_to_llvm<B: ExtraBackendMethods>(
|
||||
_backend: &B,
|
||||
tx_to_llvm_workers: &Sender<Box<dyn Any + Send>>,
|
||||
module: CachedModuleCodegen,
|
||||
@ -2129,7 +2129,7 @@ pub fn submit_post_lto_module_to_llvm<B: ExtraBackendMethods>(
|
||||
drop(tx_to_llvm_workers.send(Box::new(Message::CodegenDone::<B> { llvm_work_item, cost: 0 })));
|
||||
}
|
||||
|
||||
pub fn submit_pre_lto_module_to_llvm<B: ExtraBackendMethods>(
|
||||
pub(crate) fn submit_pre_lto_module_to_llvm<B: ExtraBackendMethods>(
|
||||
_backend: &B,
|
||||
tcx: TyCtxt<'_>,
|
||||
tx_to_llvm_workers: &Sender<Box<dyn Any + Send>>,
|
||||
|
@ -44,47 +44,23 @@ use crate::{
|
||||
errors, meth, mir, CachedModuleCodegen, CompiledModule, CrateInfo, ModuleCodegen, ModuleKind,
|
||||
};
|
||||
|
||||
pub fn bin_op_to_icmp_predicate(op: BinOp, signed: bool) -> IntPredicate {
|
||||
match op {
|
||||
BinOp::Eq => IntPredicate::IntEQ,
|
||||
BinOp::Ne => IntPredicate::IntNE,
|
||||
BinOp::Lt => {
|
||||
if signed {
|
||||
IntPredicate::IntSLT
|
||||
} else {
|
||||
IntPredicate::IntULT
|
||||
}
|
||||
}
|
||||
BinOp::Le => {
|
||||
if signed {
|
||||
IntPredicate::IntSLE
|
||||
} else {
|
||||
IntPredicate::IntULE
|
||||
}
|
||||
}
|
||||
BinOp::Gt => {
|
||||
if signed {
|
||||
IntPredicate::IntSGT
|
||||
} else {
|
||||
IntPredicate::IntUGT
|
||||
}
|
||||
}
|
||||
BinOp::Ge => {
|
||||
if signed {
|
||||
IntPredicate::IntSGE
|
||||
} else {
|
||||
IntPredicate::IntUGE
|
||||
}
|
||||
}
|
||||
op => bug!(
|
||||
"comparison_op_to_icmp_predicate: expected comparison operator, \
|
||||
found {:?}",
|
||||
op
|
||||
),
|
||||
pub(crate) fn bin_op_to_icmp_predicate(op: BinOp, signed: bool) -> IntPredicate {
|
||||
match (op, signed) {
|
||||
(BinOp::Eq, _) => IntPredicate::IntEQ,
|
||||
(BinOp::Ne, _) => IntPredicate::IntNE,
|
||||
(BinOp::Lt, true) => IntPredicate::IntSLT,
|
||||
(BinOp::Lt, false) => IntPredicate::IntULT,
|
||||
(BinOp::Le, true) => IntPredicate::IntSLE,
|
||||
(BinOp::Le, false) => IntPredicate::IntULE,
|
||||
(BinOp::Gt, true) => IntPredicate::IntSGT,
|
||||
(BinOp::Gt, false) => IntPredicate::IntUGT,
|
||||
(BinOp::Ge, true) => IntPredicate::IntSGE,
|
||||
(BinOp::Ge, false) => IntPredicate::IntUGE,
|
||||
op => bug!("bin_op_to_icmp_predicate: expected comparison operator, found {:?}", op),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn bin_op_to_fcmp_predicate(op: BinOp) -> RealPredicate {
|
||||
pub(crate) fn bin_op_to_fcmp_predicate(op: BinOp) -> RealPredicate {
|
||||
match op {
|
||||
BinOp::Eq => RealPredicate::RealOEQ,
|
||||
BinOp::Ne => RealPredicate::RealUNE,
|
||||
@ -92,13 +68,7 @@ pub fn bin_op_to_fcmp_predicate(op: BinOp) -> RealPredicate {
|
||||
BinOp::Le => RealPredicate::RealOLE,
|
||||
BinOp::Gt => RealPredicate::RealOGT,
|
||||
BinOp::Ge => RealPredicate::RealOGE,
|
||||
op => {
|
||||
bug!(
|
||||
"comparison_op_to_fcmp_predicate: expected comparison operator, \
|
||||
found {:?}",
|
||||
op
|
||||
);
|
||||
}
|
||||
op => bug!("bin_op_to_fcmp_predicate: expected comparison operator, found {:?}", op),
|
||||
}
|
||||
}
|
||||
|
||||
@ -135,7 +105,7 @@ pub fn compare_simd_types<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||
///
|
||||
/// The `old_info` argument is a bit odd. It is intended for use in an upcast,
|
||||
/// where the new vtable for an object will be derived from the old one.
|
||||
pub fn unsized_info<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||
fn unsized_info<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||
bx: &mut Bx,
|
||||
source: Ty<'tcx>,
|
||||
target: Ty<'tcx>,
|
||||
@ -154,7 +124,8 @@ pub fn unsized_info<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||
let old_info =
|
||||
old_info.expect("unsized_info: missing old info for trait upcasting coercion");
|
||||
if data_a.principal_def_id() == data_b.principal_def_id() {
|
||||
// A NOP cast that doesn't actually change anything, should be allowed even with invalid vtables.
|
||||
// A NOP cast that doesn't actually change anything, should be allowed even with
|
||||
// invalid vtables.
|
||||
return old_info;
|
||||
}
|
||||
|
||||
@ -182,7 +153,7 @@ pub fn unsized_info<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||
}
|
||||
|
||||
/// Coerces `src` to `dst_ty`. `src_ty` must be a pointer.
|
||||
pub fn unsize_ptr<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||
pub(crate) fn unsize_ptr<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||
bx: &mut Bx,
|
||||
src: Bx::Value,
|
||||
src_ty: Ty<'tcx>,
|
||||
@ -227,7 +198,7 @@ pub fn unsize_ptr<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||
}
|
||||
|
||||
/// Coerces `src` to `dst_ty` which is guaranteed to be a `dyn*` type.
|
||||
pub fn cast_to_dyn_star<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||
pub(crate) fn cast_to_dyn_star<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||
bx: &mut Bx,
|
||||
src: Bx::Value,
|
||||
src_ty_and_layout: TyAndLayout<'tcx>,
|
||||
@ -250,7 +221,7 @@ pub fn cast_to_dyn_star<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||
|
||||
/// Coerces `src`, which is a reference to a value of type `src_ty`,
|
||||
/// to a value of type `dst_ty`, and stores the result in `dst`.
|
||||
pub fn coerce_unsized_into<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||
pub(crate) fn coerce_unsized_into<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||
bx: &mut Bx,
|
||||
src: PlaceRef<'tcx, Bx::Value>,
|
||||
dst: PlaceRef<'tcx, Bx::Value>,
|
||||
@ -305,7 +276,7 @@ pub fn coerce_unsized_into<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||
///
|
||||
/// If `is_unchecked` is true, this does no masking, and adds sufficient `assume`
|
||||
/// calls or operation flags to preserve as much freedom to optimize as possible.
|
||||
pub fn build_shift_expr_rhs<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||
pub(crate) fn build_shift_expr_rhs<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||
bx: &mut Bx,
|
||||
lhs: Bx::Value,
|
||||
mut rhs: Bx::Value,
|
||||
@ -369,11 +340,11 @@ pub fn wants_msvc_seh(sess: &Session) -> bool {
|
||||
/// Returns `true` if this session's target requires the new exception
|
||||
/// handling LLVM IR instructions (catchpad / cleanuppad / ... instead
|
||||
/// of landingpad)
|
||||
pub fn wants_new_eh_instructions(sess: &Session) -> bool {
|
||||
pub(crate) fn wants_new_eh_instructions(sess: &Session) -> bool {
|
||||
wants_wasm_eh(sess) || wants_msvc_seh(sess)
|
||||
}
|
||||
|
||||
pub fn codegen_instance<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>(
|
||||
pub(crate) fn codegen_instance<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>(
|
||||
cx: &'a Bx::CodegenCx,
|
||||
instance: Instance<'tcx>,
|
||||
) {
|
||||
@ -454,7 +425,7 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||
|
||||
let isize_ty = cx.type_isize();
|
||||
let ptr_ty = cx.type_ptr();
|
||||
let (arg_argc, arg_argv) = get_argc_argv(cx, &mut bx);
|
||||
let (arg_argc, arg_argv) = get_argc_argv(&mut bx);
|
||||
|
||||
let (start_fn, start_ty, args, instance) = if let EntryFnType::Main { sigpipe } = entry_type
|
||||
{
|
||||
@ -497,33 +468,30 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||
}
|
||||
|
||||
/// Obtain the `argc` and `argv` values to pass to the rust start function.
|
||||
fn get_argc_argv<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||
cx: &'a Bx::CodegenCx,
|
||||
bx: &mut Bx,
|
||||
) -> (Bx::Value, Bx::Value) {
|
||||
if cx.sess().target.os.contains("uefi") {
|
||||
fn get_argc_argv<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(bx: &mut Bx) -> (Bx::Value, Bx::Value) {
|
||||
if bx.cx().sess().target.os.contains("uefi") {
|
||||
// Params for UEFI
|
||||
let param_handle = bx.get_param(0);
|
||||
let param_system_table = bx.get_param(1);
|
||||
let ptr_size = bx.tcx().data_layout.pointer_size;
|
||||
let ptr_align = bx.tcx().data_layout.pointer_align.abi;
|
||||
let arg_argc = bx.const_int(cx.type_isize(), 2);
|
||||
let arg_argc = bx.const_int(bx.cx().type_isize(), 2);
|
||||
let arg_argv = bx.alloca(2 * ptr_size, ptr_align);
|
||||
bx.store(param_handle, arg_argv, ptr_align);
|
||||
let arg_argv_el1 = bx.inbounds_ptradd(arg_argv, bx.const_usize(ptr_size.bytes()));
|
||||
bx.store(param_system_table, arg_argv_el1, ptr_align);
|
||||
(arg_argc, arg_argv)
|
||||
} else if cx.sess().target.main_needs_argc_argv {
|
||||
} else if bx.cx().sess().target.main_needs_argc_argv {
|
||||
// Params from native `main()` used as args for rust start function
|
||||
let param_argc = bx.get_param(0);
|
||||
let param_argv = bx.get_param(1);
|
||||
let arg_argc = bx.intcast(param_argc, cx.type_isize(), true);
|
||||
let arg_argc = bx.intcast(param_argc, bx.cx().type_isize(), true);
|
||||
let arg_argv = param_argv;
|
||||
(arg_argc, arg_argv)
|
||||
} else {
|
||||
// The Rust start function doesn't need `argc` and `argv`, so just pass zeros.
|
||||
let arg_argc = bx.const_int(cx.type_int(), 0);
|
||||
let arg_argv = bx.const_null(cx.type_ptr());
|
||||
let arg_argc = bx.const_int(bx.cx().type_int(), 0);
|
||||
let arg_argv = bx.const_null(bx.cx().type_ptr());
|
||||
(arg_argc, arg_argv)
|
||||
}
|
||||
}
|
||||
@ -985,7 +953,8 @@ impl CrateInfo {
|
||||
false
|
||||
}
|
||||
CrateType::Staticlib | CrateType::Rlib => {
|
||||
// We don't invoke the linker for these, so we don't need to collect the NatVis for them.
|
||||
// We don't invoke the linker for these, so we don't need to collect the NatVis for
|
||||
// them.
|
||||
false
|
||||
}
|
||||
});
|
||||
@ -999,7 +968,7 @@ impl CrateInfo {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn provide(providers: &mut Providers) {
|
||||
pub(crate) fn provide(providers: &mut Providers) {
|
||||
providers.backend_optimization_level = |tcx, cratenum| {
|
||||
let for_speed = match tcx.sess.opts.optimize {
|
||||
// If globally no optimisation is done, #[optimize] has no effect.
|
||||
|
@ -317,9 +317,9 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
|
||||
"extern mutable statics are not allowed with `#[linkage]`",
|
||||
);
|
||||
diag.note(
|
||||
"marking the extern static mutable would allow changing which symbol \
|
||||
the static references rather than make the target of the symbol \
|
||||
mutable",
|
||||
"marking the extern static mutable would allow changing which \
|
||||
symbol the static references rather than make the target of the \
|
||||
symbol mutable",
|
||||
);
|
||||
diag.emit();
|
||||
}
|
||||
@ -711,18 +711,19 @@ fn check_link_ordinal(tcx: TyCtxt<'_>, attr: &ast::Attribute) -> Option<u16> {
|
||||
if let Some(MetaItemLit { kind: LitKind::Int(ordinal, LitIntType::Unsuffixed), .. }) =
|
||||
sole_meta_list
|
||||
{
|
||||
// According to the table at https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#import-header,
|
||||
// the ordinal must fit into 16 bits. Similarly, the Ordinal field in COFFShortExport (defined
|
||||
// in llvm/include/llvm/Object/COFFImportFile.h), which we use to communicate import information
|
||||
// to LLVM for `#[link(kind = "raw-dylib"_])`, is also defined to be uint16_t.
|
||||
// According to the table at
|
||||
// https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#import-header, the
|
||||
// ordinal must fit into 16 bits. Similarly, the Ordinal field in COFFShortExport (defined
|
||||
// in llvm/include/llvm/Object/COFFImportFile.h), which we use to communicate import
|
||||
// information to LLVM for `#[link(kind = "raw-dylib"_])`, is also defined to be uint16_t.
|
||||
//
|
||||
// FIXME: should we allow an ordinal of 0? The MSVC toolchain has inconsistent support for this:
|
||||
// both LINK.EXE and LIB.EXE signal errors and abort when given a .DEF file that specifies
|
||||
// a zero ordinal. However, llvm-dlltool is perfectly happy to generate an import library
|
||||
// for such a .DEF file, and MSVC's LINK.EXE is also perfectly happy to consume an import
|
||||
// library produced by LLVM with an ordinal of 0, and it generates an .EXE. (I don't know yet
|
||||
// if the resulting EXE runs, as I haven't yet built the necessary DLL -- see earlier comment
|
||||
// about LINK.EXE failing.)
|
||||
// FIXME: should we allow an ordinal of 0? The MSVC toolchain has inconsistent support for
|
||||
// this: both LINK.EXE and LIB.EXE signal errors and abort when given a .DEF file that
|
||||
// specifies a zero ordinal. However, llvm-dlltool is perfectly happy to generate an import
|
||||
// library for such a .DEF file, and MSVC's LINK.EXE is also perfectly happy to consume an
|
||||
// import library produced by LLVM with an ordinal of 0, and it generates an .EXE. (I
|
||||
// don't know yet if the resulting EXE runs, as I haven't yet built the necessary DLL --
|
||||
// see earlier comment about LINK.EXE failing.)
|
||||
if *ordinal <= u16::MAX as u128 {
|
||||
Some(ordinal.get() as u16)
|
||||
} else {
|
||||
@ -755,6 +756,6 @@ fn check_link_name_xor_ordinal(
|
||||
}
|
||||
}
|
||||
|
||||
pub fn provide(providers: &mut Providers) {
|
||||
pub(crate) fn provide(providers: &mut Providers) {
|
||||
*providers = Providers { codegen_fn_attrs, should_inherit_track_caller, ..*providers };
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ mod temp_stable_hash_impls {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn build_langcall<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||
pub(crate) fn build_langcall<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||
bx: &Bx,
|
||||
span: Option<Span>,
|
||||
li: LangItem,
|
||||
@ -129,7 +129,7 @@ pub fn build_langcall<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||
(bx.fn_abi_of_instance(instance, ty::List::empty()), bx.get_fn_addr(instance), instance)
|
||||
}
|
||||
|
||||
pub fn shift_mask_val<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||
pub(crate) fn shift_mask_val<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||
bx: &mut Bx,
|
||||
llty: Bx::Type,
|
||||
mask_llty: Bx::Type,
|
||||
@ -200,7 +200,8 @@ pub fn i686_decorated_name(
|
||||
let mut decorated_name = String::with_capacity(name.len() + 6);
|
||||
|
||||
if disable_name_mangling {
|
||||
// LLVM uses a binary 1 ('\x01') prefix to a name to indicate that mangling needs to be disabled.
|
||||
// LLVM uses a binary 1 ('\x01') prefix to a name to indicate that mangling needs to be
|
||||
// disabled.
|
||||
decorated_name.push('\x01');
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ pub fn tag_base_type<'tcx>(tcx: TyCtxt<'tcx>, enum_type_and_layout: TyAndLayout<
|
||||
})
|
||||
}
|
||||
|
||||
pub fn tag_base_type_opt<'tcx>(
|
||||
fn tag_base_type_opt<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
enum_type_and_layout: TyAndLayout<'tcx>,
|
||||
) -> Option<Ty<'tcx>> {
|
||||
@ -76,9 +76,9 @@ pub fn tag_base_type_opt<'tcx>(
|
||||
Primitive::Float(f) => Integer::from_size(f.size()).unwrap(),
|
||||
// FIXME(erikdesjardins): handle non-default addrspace ptr sizes
|
||||
Primitive::Pointer(_) => {
|
||||
// If the niche is the NULL value of a reference, then `discr_enum_ty` will be
|
||||
// a RawPtr. CodeView doesn't know what to do with enums whose base type is a
|
||||
// pointer so we fix this up to just be `usize`.
|
||||
// If the niche is the NULL value of a reference, then `discr_enum_ty` will
|
||||
// be a RawPtr. CodeView doesn't know what to do with enums whose base type
|
||||
// is a pointer so we fix this up to just be `usize`.
|
||||
// DWARF might be able to deal with this but with an integer type we are on
|
||||
// the safe side there too.
|
||||
tcx.data_layout.ptr_sized_integer()
|
||||
|
@ -95,7 +95,8 @@ fn push_debuginfo_type_name<'tcx>(
|
||||
}
|
||||
Err(e) => {
|
||||
// Computing the layout can still fail here, e.g. if the target architecture
|
||||
// cannot represent the type. See https://github.com/rust-lang/rust/issues/94961.
|
||||
// cannot represent the type. See
|
||||
// https://github.com/rust-lang/rust/issues/94961.
|
||||
tcx.dcx().emit_fatal(e.into_diagnostic());
|
||||
}
|
||||
}
|
||||
@ -575,33 +576,20 @@ pub fn push_item_name(tcx: TyCtxt<'_>, def_id: DefId, qualified: bool, output: &
|
||||
}
|
||||
|
||||
fn coroutine_kind_label(coroutine_kind: Option<CoroutineKind>) -> &'static str {
|
||||
use CoroutineDesugaring::*;
|
||||
use CoroutineKind::*;
|
||||
use CoroutineSource::*;
|
||||
match coroutine_kind {
|
||||
Some(CoroutineKind::Desugared(CoroutineDesugaring::Gen, CoroutineSource::Block)) => {
|
||||
"gen_block"
|
||||
}
|
||||
Some(CoroutineKind::Desugared(CoroutineDesugaring::Gen, CoroutineSource::Closure)) => {
|
||||
"gen_closure"
|
||||
}
|
||||
Some(CoroutineKind::Desugared(CoroutineDesugaring::Gen, CoroutineSource::Fn)) => "gen_fn",
|
||||
Some(CoroutineKind::Desugared(CoroutineDesugaring::Async, CoroutineSource::Block)) => {
|
||||
"async_block"
|
||||
}
|
||||
Some(CoroutineKind::Desugared(CoroutineDesugaring::Async, CoroutineSource::Closure)) => {
|
||||
"async_closure"
|
||||
}
|
||||
Some(CoroutineKind::Desugared(CoroutineDesugaring::Async, CoroutineSource::Fn)) => {
|
||||
"async_fn"
|
||||
}
|
||||
Some(CoroutineKind::Desugared(CoroutineDesugaring::AsyncGen, CoroutineSource::Block)) => {
|
||||
"async_gen_block"
|
||||
}
|
||||
Some(CoroutineKind::Desugared(CoroutineDesugaring::AsyncGen, CoroutineSource::Closure)) => {
|
||||
"async_gen_closure"
|
||||
}
|
||||
Some(CoroutineKind::Desugared(CoroutineDesugaring::AsyncGen, CoroutineSource::Fn)) => {
|
||||
"async_gen_fn"
|
||||
}
|
||||
Some(CoroutineKind::Coroutine(_)) => "coroutine",
|
||||
Some(Desugared(Gen, Block)) => "gen_block",
|
||||
Some(Desugared(Gen, Closure)) => "gen_closure",
|
||||
Some(Desugared(Gen, Fn)) => "gen_fn",
|
||||
Some(Desugared(Async, Block)) => "async_block",
|
||||
Some(Desugared(Async, Closure)) => "async_closure",
|
||||
Some(Desugared(Async, Fn)) => "async_fn",
|
||||
Some(Desugared(AsyncGen, Block)) => "async_gen_block",
|
||||
Some(Desugared(AsyncGen, Closure)) => "async_gen_closure",
|
||||
Some(Desugared(AsyncGen, Fn)) => "async_gen_fn",
|
||||
Some(Coroutine(_)) => "coroutine",
|
||||
None => "closure",
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ use crate::fluent_generated as fluent;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_ssa_incorrect_cgu_reuse_type)]
|
||||
pub struct IncorrectCguReuseType<'a> {
|
||||
pub(crate) struct IncorrectCguReuseType<'a> {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
pub cgu_user_name: &'a str,
|
||||
@ -32,14 +32,14 @@ pub struct IncorrectCguReuseType<'a> {
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_ssa_cgu_not_recorded)]
|
||||
pub struct CguNotRecorded<'a> {
|
||||
pub(crate) struct CguNotRecorded<'a> {
|
||||
pub cgu_user_name: &'a str,
|
||||
pub cgu_name: &'a str,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_ssa_unknown_reuse_kind)]
|
||||
pub struct UnknownReuseKind {
|
||||
pub(crate) struct UnknownReuseKind {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
pub kind: Symbol,
|
||||
@ -47,14 +47,14 @@ pub struct UnknownReuseKind {
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_ssa_missing_query_depgraph)]
|
||||
pub struct MissingQueryDepGraph {
|
||||
pub(crate) struct MissingQueryDepGraph {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_ssa_malformed_cgu_name)]
|
||||
pub struct MalformedCguName {
|
||||
pub(crate) struct MalformedCguName {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
pub user_path: String,
|
||||
@ -63,7 +63,7 @@ pub struct MalformedCguName {
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_ssa_no_module_named)]
|
||||
pub struct NoModuleNamed<'a> {
|
||||
pub(crate) struct NoModuleNamed<'a> {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
pub user_path: &'a str,
|
||||
@ -73,7 +73,7 @@ pub struct NoModuleNamed<'a> {
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_ssa_field_associated_value_expected)]
|
||||
pub struct FieldAssociatedValueExpected {
|
||||
pub(crate) struct FieldAssociatedValueExpected {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
pub name: Symbol,
|
||||
@ -81,7 +81,7 @@ pub struct FieldAssociatedValueExpected {
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_ssa_no_field)]
|
||||
pub struct NoField {
|
||||
pub(crate) struct NoField {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
pub name: Symbol,
|
||||
@ -89,49 +89,49 @@ pub struct NoField {
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_ssa_lib_def_write_failure)]
|
||||
pub struct LibDefWriteFailure {
|
||||
pub(crate) struct LibDefWriteFailure {
|
||||
pub error: Error,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_ssa_version_script_write_failure)]
|
||||
pub struct VersionScriptWriteFailure {
|
||||
pub(crate) struct VersionScriptWriteFailure {
|
||||
pub error: Error,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_ssa_symbol_file_write_failure)]
|
||||
pub struct SymbolFileWriteFailure {
|
||||
pub(crate) struct SymbolFileWriteFailure {
|
||||
pub error: Error,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_ssa_ld64_unimplemented_modifier)]
|
||||
pub struct Ld64UnimplementedModifier;
|
||||
pub(crate) struct Ld64UnimplementedModifier;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_ssa_linker_unsupported_modifier)]
|
||||
pub struct LinkerUnsupportedModifier;
|
||||
pub(crate) struct LinkerUnsupportedModifier;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_ssa_L4Bender_exporting_symbols_unimplemented)]
|
||||
pub struct L4BenderExportingSymbolsUnimplemented;
|
||||
pub(crate) struct L4BenderExportingSymbolsUnimplemented;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_ssa_no_natvis_directory)]
|
||||
pub struct NoNatvisDirectory {
|
||||
pub(crate) struct NoNatvisDirectory {
|
||||
pub error: Error,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_ssa_no_saved_object_file)]
|
||||
pub struct NoSavedObjectFile<'a> {
|
||||
pub(crate) struct NoSavedObjectFile<'a> {
|
||||
pub cgu_name: &'a str,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_ssa_copy_path_buf)]
|
||||
pub struct CopyPathBuf {
|
||||
pub(crate) struct CopyPathBuf {
|
||||
pub source_file: PathBuf,
|
||||
pub output_path: PathBuf,
|
||||
pub error: Error,
|
||||
@ -180,20 +180,20 @@ pub struct IgnoringOutput {
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_ssa_create_temp_dir)]
|
||||
pub struct CreateTempDir {
|
||||
pub(crate) struct CreateTempDir {
|
||||
pub error: Error,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_ssa_add_native_library)]
|
||||
pub struct AddNativeLibrary {
|
||||
pub(crate) struct AddNativeLibrary {
|
||||
pub library_path: PathBuf,
|
||||
pub error: Error,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_ssa_multiple_external_func_decl)]
|
||||
pub struct MultipleExternalFuncDecl<'a> {
|
||||
pub(crate) struct MultipleExternalFuncDecl<'a> {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
pub function: Symbol,
|
||||
@ -215,7 +215,7 @@ pub enum LinkRlibError {
|
||||
IncompatibleDependencyFormats { ty1: String, ty2: String, list1: String, list2: String },
|
||||
}
|
||||
|
||||
pub struct ThorinErrorWrapper(pub thorin::Error);
|
||||
pub(crate) struct ThorinErrorWrapper(pub thorin::Error);
|
||||
|
||||
impl<G: EmissionGuarantee> Diagnostic<'_, G> for ThorinErrorWrapper {
|
||||
fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_, G> {
|
||||
@ -343,7 +343,7 @@ impl<G: EmissionGuarantee> Diagnostic<'_, G> for ThorinErrorWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct LinkingFailed<'a> {
|
||||
pub(crate) struct LinkingFailed<'a> {
|
||||
pub linker_path: &'a PathBuf,
|
||||
pub exit_status: ExitStatus,
|
||||
pub command: &'a Command,
|
||||
@ -376,28 +376,28 @@ impl<G: EmissionGuarantee> Diagnostic<'_, G> for LinkingFailed<'_> {
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_ssa_link_exe_unexpected_error)]
|
||||
pub struct LinkExeUnexpectedError;
|
||||
pub(crate) struct LinkExeUnexpectedError;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_ssa_repair_vs_build_tools)]
|
||||
pub struct RepairVSBuildTools;
|
||||
pub(crate) struct RepairVSBuildTools;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_ssa_missing_cpp_build_tool_component)]
|
||||
pub struct MissingCppBuildToolComponent;
|
||||
pub(crate) struct MissingCppBuildToolComponent;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_ssa_select_cpp_build_tool_workload)]
|
||||
pub struct SelectCppBuildToolWorkload;
|
||||
pub(crate) struct SelectCppBuildToolWorkload;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_ssa_visual_studio_not_installed)]
|
||||
pub struct VisualStudioNotInstalled;
|
||||
pub(crate) struct VisualStudioNotInstalled;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_ssa_linker_not_found)]
|
||||
#[note]
|
||||
pub struct LinkerNotFound {
|
||||
pub(crate) struct LinkerNotFound {
|
||||
pub linker_path: PathBuf,
|
||||
pub error: Error,
|
||||
}
|
||||
@ -406,7 +406,7 @@ pub struct LinkerNotFound {
|
||||
#[diag(codegen_ssa_unable_to_exe_linker)]
|
||||
#[note]
|
||||
#[note(codegen_ssa_command_note)]
|
||||
pub struct UnableToExeLinker {
|
||||
pub(crate) struct UnableToExeLinker {
|
||||
pub linker_path: PathBuf,
|
||||
pub error: Error,
|
||||
pub command_formatted: String,
|
||||
@ -414,38 +414,38 @@ pub struct UnableToExeLinker {
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_ssa_msvc_missing_linker)]
|
||||
pub struct MsvcMissingLinker;
|
||||
pub(crate) struct MsvcMissingLinker;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_ssa_self_contained_linker_missing)]
|
||||
pub struct SelfContainedLinkerMissing;
|
||||
pub(crate) struct SelfContainedLinkerMissing;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_ssa_check_installed_visual_studio)]
|
||||
pub struct CheckInstalledVisualStudio;
|
||||
pub(crate) struct CheckInstalledVisualStudio;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_ssa_insufficient_vs_code_product)]
|
||||
pub struct InsufficientVSCodeProduct;
|
||||
pub(crate) struct InsufficientVSCodeProduct;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_ssa_processing_dymutil_failed)]
|
||||
#[note]
|
||||
pub struct ProcessingDymutilFailed {
|
||||
pub(crate) struct ProcessingDymutilFailed {
|
||||
pub status: ExitStatus,
|
||||
pub output: String,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_ssa_unable_to_run_dsymutil)]
|
||||
pub struct UnableToRunDsymutil {
|
||||
pub(crate) struct UnableToRunDsymutil {
|
||||
pub error: Error,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_ssa_stripping_debug_info_failed)]
|
||||
#[note]
|
||||
pub struct StrippingDebugInfoFailed<'a> {
|
||||
pub(crate) struct StrippingDebugInfoFailed<'a> {
|
||||
pub util: &'a str,
|
||||
pub status: ExitStatus,
|
||||
pub output: String,
|
||||
@ -453,58 +453,59 @@ pub struct StrippingDebugInfoFailed<'a> {
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_ssa_unable_to_run)]
|
||||
pub struct UnableToRun<'a> {
|
||||
pub(crate) struct UnableToRun<'a> {
|
||||
pub util: &'a str,
|
||||
pub error: Error,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_ssa_linker_file_stem)]
|
||||
pub struct LinkerFileStem;
|
||||
pub(crate) struct LinkerFileStem;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_ssa_static_library_native_artifacts)]
|
||||
pub struct StaticLibraryNativeArtifacts;
|
||||
pub(crate) struct StaticLibraryNativeArtifacts;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_ssa_static_library_native_artifacts_to_file)]
|
||||
pub struct StaticLibraryNativeArtifactsToFile<'a> {
|
||||
pub(crate) struct StaticLibraryNativeArtifactsToFile<'a> {
|
||||
pub path: &'a Path,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_ssa_link_script_unavailable)]
|
||||
pub struct LinkScriptUnavailable;
|
||||
pub(crate) struct LinkScriptUnavailable;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_ssa_link_script_write_failure)]
|
||||
pub struct LinkScriptWriteFailure {
|
||||
pub(crate) struct LinkScriptWriteFailure {
|
||||
pub path: PathBuf,
|
||||
pub error: Error,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_ssa_failed_to_write)]
|
||||
pub struct FailedToWrite {
|
||||
pub(crate) struct FailedToWrite {
|
||||
pub path: PathBuf,
|
||||
pub error: Error,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_ssa_unable_to_write_debugger_visualizer)]
|
||||
pub struct UnableToWriteDebuggerVisualizer {
|
||||
pub(crate) struct UnableToWriteDebuggerVisualizer {
|
||||
pub path: PathBuf,
|
||||
pub error: Error,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_ssa_rlib_archive_build_failure)]
|
||||
pub struct RlibArchiveBuildFailure {
|
||||
pub(crate) struct RlibArchiveBuildFailure {
|
||||
pub path: PathBuf,
|
||||
pub error: Error,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
// Public for rustc_codegen_llvm::back::archive
|
||||
pub enum ExtractBundledLibsError<'a> {
|
||||
#[diag(codegen_ssa_extract_bundled_libs_open_file)]
|
||||
OpenFile { rlib: &'a Path, error: Box<dyn std::error::Error> },
|
||||
@ -533,26 +534,26 @@ pub enum ExtractBundledLibsError<'a> {
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_ssa_unsupported_arch)]
|
||||
pub struct UnsupportedArch<'a> {
|
||||
pub(crate) struct UnsupportedArch<'a> {
|
||||
pub arch: &'a str,
|
||||
pub os: &'a str,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
pub enum AppleSdkRootError<'a> {
|
||||
pub(crate) enum AppleSdkRootError<'a> {
|
||||
#[diag(codegen_ssa_apple_sdk_error_sdk_path)]
|
||||
SdkPath { sdk_name: &'a str, error: Error },
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_ssa_read_file)]
|
||||
pub struct ReadFileError {
|
||||
pub(crate) struct ReadFileError {
|
||||
pub message: std::io::Error,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_ssa_unsupported_link_self_contained)]
|
||||
pub struct UnsupportedLinkSelfContained;
|
||||
pub(crate) struct UnsupportedLinkSelfContained;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_ssa_archive_build_failure)]
|
||||
@ -571,7 +572,7 @@ pub struct UnknownArchiveKind<'a> {
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_ssa_expected_used_symbol)]
|
||||
pub struct ExpectedUsedSymbol {
|
||||
pub(crate) struct ExpectedUsedSymbol {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
}
|
||||
@ -579,45 +580,45 @@ pub struct ExpectedUsedSymbol {
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_ssa_multiple_main_functions)]
|
||||
#[help]
|
||||
pub struct MultipleMainFunctions {
|
||||
pub(crate) struct MultipleMainFunctions {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_ssa_metadata_object_file_write)]
|
||||
pub struct MetadataObjectFileWrite {
|
||||
pub(crate) struct MetadataObjectFileWrite {
|
||||
pub error: Error,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_ssa_invalid_windows_subsystem)]
|
||||
pub struct InvalidWindowsSubsystem {
|
||||
pub(crate) struct InvalidWindowsSubsystem {
|
||||
pub subsystem: Symbol,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_ssa_shuffle_indices_evaluation)]
|
||||
pub struct ShuffleIndicesEvaluation {
|
||||
pub(crate) struct ShuffleIndicesEvaluation {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_ssa_missing_memory_ordering)]
|
||||
pub struct MissingMemoryOrdering;
|
||||
pub(crate) struct MissingMemoryOrdering;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_ssa_unknown_atomic_ordering)]
|
||||
pub struct UnknownAtomicOrdering;
|
||||
pub(crate) struct UnknownAtomicOrdering;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_ssa_atomic_compare_exchange)]
|
||||
pub struct AtomicCompareExchange;
|
||||
pub(crate) struct AtomicCompareExchange;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_ssa_unknown_atomic_operation)]
|
||||
pub struct UnknownAtomicOperation;
|
||||
pub(crate) struct UnknownAtomicOperation;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
pub enum InvalidMonomorphization<'tcx> {
|
||||
@ -986,7 +987,7 @@ impl IntoDiagArg for ExpectedPointerMutability {
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_ssa_invalid_no_sanitize)]
|
||||
#[note]
|
||||
pub struct InvalidNoSanitize {
|
||||
pub(crate) struct InvalidNoSanitize {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
}
|
||||
@ -994,7 +995,7 @@ pub struct InvalidNoSanitize {
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_ssa_invalid_link_ordinal_nargs)]
|
||||
#[note]
|
||||
pub struct InvalidLinkOrdinalNargs {
|
||||
pub(crate) struct InvalidLinkOrdinalNargs {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
}
|
||||
@ -1002,14 +1003,14 @@ pub struct InvalidLinkOrdinalNargs {
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_ssa_illegal_link_ordinal_format)]
|
||||
#[note]
|
||||
pub struct InvalidLinkOrdinalFormat {
|
||||
pub(crate) struct InvalidLinkOrdinalFormat {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_ssa_target_feature_safe_trait)]
|
||||
pub struct TargetFeatureSafeTrait {
|
||||
pub(crate) struct TargetFeatureSafeTrait {
|
||||
#[primary_span]
|
||||
#[label]
|
||||
pub span: Span,
|
||||
@ -1050,7 +1051,7 @@ pub(crate) struct ErrorCallingDllTool<'a> {
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_ssa_error_creating_remark_dir)]
|
||||
pub struct ErrorCreatingRemarkDir {
|
||||
pub(crate) struct ErrorCreatingRemarkDir {
|
||||
pub error: std::io::Error,
|
||||
}
|
||||
|
||||
|
@ -128,7 +128,7 @@ impl CompiledModule {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct CachedModuleCodegen {
|
||||
pub(crate) struct CachedModuleCodegen {
|
||||
pub name: String,
|
||||
pub source: WorkProduct,
|
||||
}
|
||||
|
@ -8,10 +8,10 @@ use tracing::{debug, instrument};
|
||||
use crate::traits::*;
|
||||
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub struct VirtualIndex(u64);
|
||||
pub(crate) struct VirtualIndex(u64);
|
||||
|
||||
impl<'a, 'tcx> VirtualIndex {
|
||||
pub fn from_index(index: usize) -> Self {
|
||||
pub(crate) fn from_index(index: usize) -> Self {
|
||||
VirtualIndex(index as u64)
|
||||
}
|
||||
|
||||
@ -51,7 +51,7 @@ impl<'a, 'tcx> VirtualIndex {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_optional_fn<Bx: BuilderMethods<'a, 'tcx>>(
|
||||
pub(crate) fn get_optional_fn<Bx: BuilderMethods<'a, 'tcx>>(
|
||||
self,
|
||||
bx: &mut Bx,
|
||||
llvtable: Bx::Value,
|
||||
@ -61,7 +61,7 @@ impl<'a, 'tcx> VirtualIndex {
|
||||
self.get_fn_inner(bx, llvtable, ty, fn_abi, false)
|
||||
}
|
||||
|
||||
pub fn get_fn<Bx: BuilderMethods<'a, 'tcx>>(
|
||||
pub(crate) fn get_fn<Bx: BuilderMethods<'a, 'tcx>>(
|
||||
self,
|
||||
bx: &mut Bx,
|
||||
llvtable: Bx::Value,
|
||||
@ -71,7 +71,7 @@ impl<'a, 'tcx> VirtualIndex {
|
||||
self.get_fn_inner(bx, llvtable, ty, fn_abi, true)
|
||||
}
|
||||
|
||||
pub fn get_usize<Bx: BuilderMethods<'a, 'tcx>>(
|
||||
pub(crate) fn get_usize<Bx: BuilderMethods<'a, 'tcx>>(
|
||||
self,
|
||||
bx: &mut Bx,
|
||||
llvtable: Bx::Value,
|
||||
@ -115,7 +115,7 @@ fn expect_dyn_trait_in_self(ty: Ty<'_>) -> ty::PolyExistentialTraitRef<'_> {
|
||||
/// making an object `Foo<dyn Trait>` from a value of type `Foo<T>`, then
|
||||
/// `trait_ref` would map `T: Trait`.
|
||||
#[instrument(level = "debug", skip(cx))]
|
||||
pub fn get_vtable<'tcx, Cx: CodegenMethods<'tcx>>(
|
||||
pub(crate) fn get_vtable<'tcx, Cx: CodegenMethods<'tcx>>(
|
||||
cx: &Cx,
|
||||
ty: Ty<'tcx>,
|
||||
trait_ref: Option<ty::PolyExistentialTraitRef<'tcx>>,
|
||||
|
@ -69,13 +69,13 @@ enum LocalKind {
|
||||
SSA(DefLocation),
|
||||
}
|
||||
|
||||
struct LocalAnalyzer<'mir, 'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> {
|
||||
fx: &'mir FunctionCx<'a, 'tcx, Bx>,
|
||||
dominators: &'mir Dominators<mir::BasicBlock>,
|
||||
struct LocalAnalyzer<'a, 'b, 'tcx, Bx: BuilderMethods<'b, 'tcx>> {
|
||||
fx: &'a FunctionCx<'b, 'tcx, Bx>,
|
||||
dominators: &'a Dominators<mir::BasicBlock>,
|
||||
locals: IndexVec<mir::Local, LocalKind>,
|
||||
}
|
||||
|
||||
impl<'mir, 'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> LocalAnalyzer<'mir, 'a, 'tcx, Bx> {
|
||||
impl<'a, 'b, 'tcx, Bx: BuilderMethods<'b, 'tcx>> LocalAnalyzer<'a, 'b, 'tcx, Bx> {
|
||||
fn define(&mut self, local: mir::Local, location: DefLocation) {
|
||||
let kind = &mut self.locals[local];
|
||||
match *kind {
|
||||
@ -152,9 +152,7 @@ impl<'mir, 'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> LocalAnalyzer<'mir, 'a, 'tcx,
|
||||
}
|
||||
}
|
||||
|
||||
impl<'mir, 'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> Visitor<'tcx>
|
||||
for LocalAnalyzer<'mir, 'a, 'tcx, Bx>
|
||||
{
|
||||
impl<'a, 'b, 'tcx, Bx: BuilderMethods<'b, 'tcx>> Visitor<'tcx> for LocalAnalyzer<'a, 'b, 'tcx, Bx> {
|
||||
fn visit_assign(
|
||||
&mut self,
|
||||
place: &mir::Place<'tcx>,
|
||||
|
@ -996,7 +996,8 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||
// To get a `*mut RcBox<Self>`, we just keep unwrapping newtypes until
|
||||
// we get a value of a built-in pointer type.
|
||||
//
|
||||
// This is also relevant for `Pin<&mut Self>`, where we need to peel the `Pin`.
|
||||
// This is also relevant for `Pin<&mut Self>`, where we need to peel the
|
||||
// `Pin`.
|
||||
while !op.layout.ty.is_unsafe_ptr() && !op.layout.ty.is_ref() {
|
||||
let (idx, _) = op.layout.non_1zst_field(bx).expect(
|
||||
"not exactly one non-1-ZST field in a `DispatchFromDyn` type",
|
||||
@ -1004,9 +1005,9 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||
op = op.extract_field(bx, idx);
|
||||
}
|
||||
|
||||
// now that we have `*dyn Trait` or `&dyn Trait`, split it up into its
|
||||
// Now that we have `*dyn Trait` or `&dyn Trait`, split it up into its
|
||||
// data pointer and vtable. Look up the method in the vtable, and pass
|
||||
// the data pointer as the first argument
|
||||
// the data pointer as the first argument.
|
||||
llfn = Some(meth::VirtualIndex::from_index(idx).get_fn(
|
||||
bx,
|
||||
meta,
|
||||
@ -1212,10 +1213,8 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||
mergeable_succ,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||
pub fn codegen_block(&mut self, mut bb: mir::BasicBlock) {
|
||||
pub(crate) fn codegen_block(&mut self, mut bb: mir::BasicBlock) {
|
||||
let llbb = match self.try_llbb(bb) {
|
||||
Some(llbb) => llbb,
|
||||
None => return,
|
||||
@ -1255,7 +1254,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn codegen_block_as_unreachable(&mut self, bb: mir::BasicBlock) {
|
||||
pub(crate) fn codegen_block_as_unreachable(&mut self, bb: mir::BasicBlock) {
|
||||
let llbb = match self.try_llbb(bb) {
|
||||
Some(llbb) => llbb,
|
||||
None => return,
|
||||
@ -1440,8 +1439,9 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||
let (mut llval, align, by_ref) = match op.val {
|
||||
Immediate(_) | Pair(..) => match arg.mode {
|
||||
PassMode::Indirect { attrs, .. } => {
|
||||
// Indirect argument may have higher alignment requirements than the type's alignment.
|
||||
// This can happen, e.g. when passing types with <4 byte alignment on the stack on x86.
|
||||
// Indirect argument may have higher alignment requirements than the type's
|
||||
// alignment. This can happen, e.g. when passing types with <4 byte alignment
|
||||
// on the stack on x86.
|
||||
let required_align = match attrs.pointee_align {
|
||||
Some(pointee_align) => cmp::max(pointee_align, arg.layout.align.abi),
|
||||
None => arg.layout.align.abi,
|
||||
@ -1740,7 +1740,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||
}
|
||||
|
||||
/// Like `llbb`, but may fail if the basic block should be skipped.
|
||||
pub fn try_llbb(&mut self, bb: mir::BasicBlock) -> Option<Bx::BasicBlock> {
|
||||
pub(crate) fn try_llbb(&mut self, bb: mir::BasicBlock) -> Option<Bx::BasicBlock> {
|
||||
match self.cached_llbbs[bb] {
|
||||
CachedLlbb::None => {
|
||||
let llbb = Bx::append_block(self.cx, self.llfn, &format!("{bb:?}"));
|
||||
|
@ -10,7 +10,7 @@ use crate::mir::operand::OperandRef;
|
||||
use crate::traits::*;
|
||||
|
||||
impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||
pub fn eval_mir_constant_to_operand(
|
||||
pub(crate) fn eval_mir_constant_to_operand(
|
||||
&self,
|
||||
bx: &mut Bx,
|
||||
constant: &mir::ConstOperand<'tcx>,
|
||||
@ -32,27 +32,28 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||
/// that the given `constant` is an `Const::Unevaluated` and must be convertible to
|
||||
/// a `ValTree`. If you want a more general version of this, talk to `wg-const-eval` on zulip.
|
||||
///
|
||||
/// Note that this function is cursed, since usually MIR consts should not be evaluated to valtrees!
|
||||
pub fn eval_unevaluated_mir_constant_to_valtree(
|
||||
/// Note that this function is cursed, since usually MIR consts should not be evaluated to
|
||||
/// valtrees!
|
||||
fn eval_unevaluated_mir_constant_to_valtree(
|
||||
&self,
|
||||
constant: &mir::ConstOperand<'tcx>,
|
||||
) -> Result<Result<ty::ValTree<'tcx>, Ty<'tcx>>, ErrorHandled> {
|
||||
let uv = match self.monomorphize(constant.const_) {
|
||||
mir::Const::Unevaluated(uv, _) => uv.shrink(),
|
||||
mir::Const::Ty(_, c) => match c.kind() {
|
||||
// A constant that came from a const generic but was then used as an argument to old-style
|
||||
// simd_shuffle (passing as argument instead of as a generic param).
|
||||
// A constant that came from a const generic but was then used as an argument to
|
||||
// old-style simd_shuffle (passing as argument instead of as a generic param).
|
||||
rustc_type_ir::ConstKind::Value(_, valtree) => return Ok(Ok(valtree)),
|
||||
other => span_bug!(constant.span, "{other:#?}"),
|
||||
},
|
||||
// We should never encounter `Const::Val` unless MIR opts (like const prop) evaluate
|
||||
// a constant and write that value back into `Operand`s. This could happen, but is unlikely.
|
||||
// Also: all users of `simd_shuffle` are on unstable and already need to take a lot of care
|
||||
// around intrinsics. For an issue to happen here, it would require a macro expanding to a
|
||||
// `simd_shuffle` call without wrapping the constant argument in a `const {}` block, but
|
||||
// the user pass through arbitrary expressions.
|
||||
// FIXME(oli-obk): replace the magic const generic argument of `simd_shuffle` with a real
|
||||
// const generic, and get rid of this entire function.
|
||||
// a constant and write that value back into `Operand`s. This could happen, but is
|
||||
// unlikely. Also: all users of `simd_shuffle` are on unstable and already need to take
|
||||
// a lot of care around intrinsics. For an issue to happen here, it would require a
|
||||
// macro expanding to a `simd_shuffle` call without wrapping the constant argument in a
|
||||
// `const {}` block, but the user pass through arbitrary expressions.
|
||||
// FIXME(oli-obk): replace the magic const generic argument of `simd_shuffle` with a
|
||||
// real const generic, and get rid of this entire function.
|
||||
other => span_bug!(constant.span, "{other:#?}"),
|
||||
};
|
||||
let uv = self.monomorphize(uv);
|
||||
|
@ -5,7 +5,7 @@ use super::FunctionCx;
|
||||
use crate::traits::*;
|
||||
|
||||
impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||
pub fn codegen_coverage(&self, bx: &mut Bx, kind: &CoverageKind, scope: SourceScope) {
|
||||
pub(crate) fn codegen_coverage(&self, bx: &mut Bx, kind: &CoverageKind, scope: SourceScope) {
|
||||
// Determine the instance that coverage data was originally generated for.
|
||||
let instance = if let Some(inlined) = scope.inlined_instance(&self.mir.source_scopes) {
|
||||
self.monomorphize(inlined)
|
||||
|
@ -24,6 +24,7 @@ pub struct FunctionDebugContext<'tcx, S, L> {
|
||||
/// Maps from an inlined function to its debug info declaration.
|
||||
pub inlined_function_scopes: FxHashMap<Instance<'tcx>, S>,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
pub enum VariableKind {
|
||||
ArgumentVariable(usize /*index*/),
|
||||
@ -243,7 +244,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||
|
||||
/// Apply debuginfo and/or name, after creating the `alloca` for a local,
|
||||
/// or initializing the local with an operand (whichever applies).
|
||||
pub fn debug_introduce_local(&self, bx: &mut Bx, local: mir::Local) {
|
||||
pub(crate) fn debug_introduce_local(&self, bx: &mut Bx, local: mir::Local) {
|
||||
let full_debug_info = bx.sess().opts.debuginfo == DebugInfo::Full;
|
||||
|
||||
let vars = match &self.per_local_var_debug_info {
|
||||
@ -426,7 +427,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn debug_introduce_locals(&self, bx: &mut Bx) {
|
||||
pub(crate) fn debug_introduce_locals(&self, bx: &mut Bx) {
|
||||
if bx.sess().opts.debuginfo == DebugInfo::Full || !bx.sess().fewer_names() {
|
||||
for local in self.locals.indices() {
|
||||
self.debug_introduce_local(bx, local);
|
||||
@ -435,7 +436,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||
}
|
||||
|
||||
/// Partition all `VarDebugInfo` in `self.mir`, by their base `Local`.
|
||||
pub fn compute_per_local_var_debug_info(
|
||||
pub(crate) fn compute_per_local_var_debug_info(
|
||||
&self,
|
||||
bx: &mut Bx,
|
||||
) -> Option<IndexVec<mir::Local, Vec<PerLocalVarDebugInfo<'tcx, Bx::DIVariable>>>> {
|
||||
|
@ -15,8 +15,8 @@ use crate::traits::*;
|
||||
|
||||
mod analyze;
|
||||
mod block;
|
||||
pub mod constant;
|
||||
pub mod coverageinfo;
|
||||
mod constant;
|
||||
mod coverageinfo;
|
||||
pub mod debuginfo;
|
||||
mod intrinsic;
|
||||
mod locals;
|
||||
|
@ -64,7 +64,7 @@ impl<V: CodegenObject> OperandValue<V> {
|
||||
/// If this is ZeroSized/Immediate/Pair, return an array of the 0/1/2 values.
|
||||
/// If this is Ref, return the place.
|
||||
#[inline]
|
||||
pub fn immediates_or_place(self) -> Either<ArrayVec<V, 2>, PlaceValue<V>> {
|
||||
pub(crate) fn immediates_or_place(self) -> Either<ArrayVec<V, 2>, PlaceValue<V>> {
|
||||
match self {
|
||||
OperandValue::ZeroSized => Either::Left(ArrayVec::new()),
|
||||
OperandValue::Immediate(a) => Either::Left(ArrayVec::from_iter([a])),
|
||||
@ -75,7 +75,7 @@ impl<V: CodegenObject> OperandValue<V> {
|
||||
|
||||
/// Given an array of 0/1/2 immediate values, return ZeroSized/Immediate/Pair.
|
||||
#[inline]
|
||||
pub fn from_immediates(immediates: ArrayVec<V, 2>) -> Self {
|
||||
pub(crate) fn from_immediates(immediates: ArrayVec<V, 2>) -> Self {
|
||||
let mut it = immediates.into_iter();
|
||||
let Some(a) = it.next() else {
|
||||
return OperandValue::ZeroSized;
|
||||
@ -90,7 +90,7 @@ impl<V: CodegenObject> OperandValue<V> {
|
||||
/// optional metadata as backend values.
|
||||
///
|
||||
/// If you're making a place, use [`Self::deref`] instead.
|
||||
pub fn pointer_parts(self) -> (V, Option<V>) {
|
||||
pub(crate) fn pointer_parts(self) -> (V, Option<V>) {
|
||||
match self {
|
||||
OperandValue::Immediate(llptr) => (llptr, None),
|
||||
OperandValue::Pair(llptr, llextra) => (llptr, Some(llextra)),
|
||||
@ -105,7 +105,7 @@ impl<V: CodegenObject> OperandValue<V> {
|
||||
/// alignment, then maybe you want [`OperandRef::deref`] instead.
|
||||
///
|
||||
/// This is the inverse of [`PlaceValue::address`].
|
||||
pub fn deref(self, align: Align) -> PlaceValue<V> {
|
||||
pub(crate) fn deref(self, align: Align) -> PlaceValue<V> {
|
||||
let (llval, llextra) = self.pointer_parts();
|
||||
PlaceValue { llval, llextra, align }
|
||||
}
|
||||
@ -153,7 +153,7 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> {
|
||||
OperandRef { val: OperandValue::ZeroSized, layout }
|
||||
}
|
||||
|
||||
pub fn from_const<Bx: BuilderMethods<'a, 'tcx, Value = V>>(
|
||||
pub(crate) fn from_const<Bx: BuilderMethods<'a, 'tcx, Value = V>>(
|
||||
bx: &mut Bx,
|
||||
val: mir::ConstValue<'tcx>,
|
||||
ty: Ty<'tcx>,
|
||||
@ -334,7 +334,7 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> {
|
||||
OperandRef { val, layout }
|
||||
}
|
||||
|
||||
pub fn extract_field<Bx: BuilderMethods<'a, 'tcx, Value = V>>(
|
||||
pub(crate) fn extract_field<Bx: BuilderMethods<'a, 'tcx, Value = V>>(
|
||||
&self,
|
||||
bx: &mut Bx,
|
||||
i: usize,
|
||||
@ -478,8 +478,8 @@ impl<'a, 'tcx, V: CodegenObject> OperandValue<V> {
|
||||
debug!("OperandRef::store: operand={:?}, dest={:?}", self, dest);
|
||||
match self {
|
||||
OperandValue::ZeroSized => {
|
||||
// Avoid generating stores of zero-sized values, because the only way to have a zero-sized
|
||||
// value is through `undef`/`poison`, and the store itself is useless.
|
||||
// Avoid generating stores of zero-sized values, because the only way to have a
|
||||
// zero-sized value is through `undef`/`poison`, and the store itself is useless.
|
||||
}
|
||||
OperandValue::Ref(val) => {
|
||||
assert!(dest.layout.is_sized(), "cannot directly store unsized values");
|
||||
|
@ -19,7 +19,7 @@ use crate::{base, MemFlags};
|
||||
|
||||
impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||
#[instrument(level = "trace", skip(self, bx))]
|
||||
pub fn codegen_rvalue(
|
||||
pub(crate) fn codegen_rvalue(
|
||||
&mut self,
|
||||
bx: &mut Bx,
|
||||
dest: PlaceRef<'tcx, Bx::Value>,
|
||||
@ -419,7 +419,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn codegen_rvalue_unsized(
|
||||
pub(crate) fn codegen_rvalue_unsized(
|
||||
&mut self,
|
||||
bx: &mut Bx,
|
||||
indirect_dest: PlaceRef<'tcx, Bx::Value>,
|
||||
@ -440,7 +440,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn codegen_rvalue_operand(
|
||||
pub(crate) fn codegen_rvalue_operand(
|
||||
&mut self,
|
||||
bx: &mut Bx,
|
||||
rvalue: &mir::Rvalue<'tcx>,
|
||||
@ -836,7 +836,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||
OperandRef { val, layout: self.cx.layout_of(mk_ptr_ty(self.cx.tcx(), ty)) }
|
||||
}
|
||||
|
||||
pub fn codegen_scalar_binop(
|
||||
fn codegen_scalar_binop(
|
||||
&mut self,
|
||||
bx: &mut Bx,
|
||||
op: mir::BinOp,
|
||||
@ -981,7 +981,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn codegen_fat_ptr_binop(
|
||||
fn codegen_fat_ptr_binop(
|
||||
&mut self,
|
||||
bx: &mut Bx,
|
||||
op: mir::BinOp,
|
||||
@ -1023,7 +1023,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn codegen_scalar_checked_binop(
|
||||
fn codegen_scalar_checked_binop(
|
||||
&mut self,
|
||||
bx: &mut Bx,
|
||||
op: mir::BinOp,
|
||||
@ -1047,10 +1047,8 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||
|
||||
OperandValue::Pair(val, of)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||
pub fn rvalue_creates_operand(&self, rvalue: &mir::Rvalue<'tcx>, span: Span) -> bool {
|
||||
pub(crate) fn rvalue_creates_operand(&self, rvalue: &mir::Rvalue<'tcx>, span: Span) -> bool {
|
||||
match *rvalue {
|
||||
mir::Rvalue::Cast(mir::CastKind::Transmute, ref operand, cast_ty) => {
|
||||
let operand_ty = operand.ty(self.mir, self.cx.tcx());
|
||||
|
@ -7,7 +7,7 @@ use crate::traits::*;
|
||||
|
||||
impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||
#[instrument(level = "debug", skip(self, bx))]
|
||||
pub fn codegen_statement(&mut self, bx: &mut Bx, statement: &mir::Statement<'tcx>) {
|
||||
pub(crate) fn codegen_statement(&mut self, bx: &mut Bx, statement: &mir::Statement<'tcx>) {
|
||||
self.set_debug_loc(bx, statement.source_info);
|
||||
match statement.kind {
|
||||
mir::StatementKind::Assign(box (ref place, ref rvalue)) => {
|
||||
|
@ -45,11 +45,13 @@ pub fn size_and_align_of_dst<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||
// The info in this case is the length of the str, so the size is that
|
||||
// times the unit size.
|
||||
(
|
||||
// All slice sizes must fit into `isize`, so this multiplication cannot (signed) wrap.
|
||||
// All slice sizes must fit into `isize`, so this multiplication cannot (signed)
|
||||
// wrap.
|
||||
// NOTE: ideally, we want the effects of both `unchecked_smul` and `unchecked_umul`
|
||||
// (resulting in `mul nsw nuw` in LLVM IR), since we know that the multiplication
|
||||
// cannot signed wrap, and that both operands are non-negative. But at the time of writing,
|
||||
// the `LLVM-C` binding can't do this, and it doesn't seem to enable any further optimizations.
|
||||
// cannot signed wrap, and that both operands are non-negative. But at the time of
|
||||
// writing, the `LLVM-C` binding can't do this, and it doesn't seem to enable any
|
||||
// further optimizations.
|
||||
bx.unchecked_smul(info.unwrap(), bx.const_usize(unit.size.bytes())),
|
||||
bx.const_usize(unit.align.abi.bytes()),
|
||||
)
|
||||
@ -67,9 +69,9 @@ pub fn size_and_align_of_dst<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||
let (fn_abi, llfn, _instance) =
|
||||
common::build_langcall(bx, None, LangItem::PanicNounwind);
|
||||
|
||||
// Generate the call.
|
||||
// Cannot use `do_call` since we don't have a MIR terminator so we can't create a `TerminationCodegenHelper`.
|
||||
// (But we are in good company, this code is duplicated plenty of times.)
|
||||
// Generate the call. Cannot use `do_call` since we don't have a MIR terminator so we
|
||||
// can't create a `TerminationCodegenHelper`. (But we are in good company, this code is
|
||||
// duplicated plenty of times.)
|
||||
let fn_ty = bx.fn_decl_backend_type(fn_abi);
|
||||
|
||||
bx.call(
|
||||
@ -148,9 +150,14 @@ pub fn size_and_align_of_dst<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||
// The full formula for the size would be:
|
||||
// let unsized_offset_adjusted = unsized_offset_unadjusted.align_to(unsized_align);
|
||||
// let full_size = (unsized_offset_adjusted + unsized_size).align_to(full_align);
|
||||
// However, `unsized_size` is a multiple of `unsized_align`.
|
||||
// Therefore, we can equivalently do the `align_to(unsized_align)` *after* adding `unsized_size`:
|
||||
// let full_size = (unsized_offset_unadjusted + unsized_size).align_to(unsized_align).align_to(full_align);
|
||||
// However, `unsized_size` is a multiple of `unsized_align`. Therefore, we can
|
||||
// equivalently do the `align_to(unsized_align)` *after* adding `unsized_size`:
|
||||
//
|
||||
// let full_size =
|
||||
// (unsized_offset_unadjusted + unsized_size)
|
||||
// .align_to(unsized_align)
|
||||
// .align_to(full_align);
|
||||
//
|
||||
// Furthermore, `align >= unsized_align`, and therefore we only need to do:
|
||||
// let full_size = (unsized_offset_unadjusted + unsized_size).align_to(full_align);
|
||||
|
||||
|
@ -15,7 +15,7 @@ use rustc_span::Span;
|
||||
|
||||
use crate::errors;
|
||||
|
||||
pub fn from_target_feature(
|
||||
pub(crate) fn from_target_feature(
|
||||
tcx: TyCtxt<'_>,
|
||||
attr: &ast::Attribute,
|
||||
supported_target_features: &UnordMap<String, Option<Symbol>>,
|
||||
@ -146,7 +146,7 @@ fn asm_target_features(tcx: TyCtxt<'_>, did: DefId) -> &FxIndexSet<Symbol> {
|
||||
|
||||
/// Checks the function annotated with `#[target_feature]` is not a safe
|
||||
/// trait method implementation, reporting an error if it is.
|
||||
pub fn check_target_feature_trait_unsafe(tcx: TyCtxt<'_>, id: LocalDefId, attr_span: Span) {
|
||||
pub(crate) fn check_target_feature_trait_unsafe(tcx: TyCtxt<'_>, id: LocalDefId, attr_span: Span) {
|
||||
if let DefKind::AssocFn = tcx.def_kind(id) {
|
||||
let parent_id = tcx.local_parent(id);
|
||||
if let DefKind::Trait | DefKind::Impl { of_trait: true } = tcx.def_kind(parent_id) {
|
||||
|
@ -59,11 +59,15 @@ pub trait CodegenBackend {
|
||||
fn locale_resource(&self) -> &'static str;
|
||||
|
||||
fn init(&self, _sess: &Session) {}
|
||||
|
||||
fn print(&self, _req: &PrintRequest, _out: &mut String, _sess: &Session) {}
|
||||
|
||||
fn target_features(&self, _sess: &Session, _allow_unstable: bool) -> Vec<Symbol> {
|
||||
vec![]
|
||||
}
|
||||
|
||||
fn print_passes(&self) {}
|
||||
|
||||
fn print_version(&self) {}
|
||||
|
||||
/// The metadata loader used to load rlib and dylib metadata.
|
||||
@ -75,6 +79,7 @@ pub trait CodegenBackend {
|
||||
}
|
||||
|
||||
fn provide(&self, _providers: &mut Providers) {}
|
||||
|
||||
fn codegen_crate<'tcx>(
|
||||
&self,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
@ -120,6 +125,7 @@ pub trait ExtraBackendMethods:
|
||||
kind: AllocatorKind,
|
||||
alloc_error_handler_kind: AllocatorKind,
|
||||
) -> Self::Module;
|
||||
|
||||
/// This generates the codegen unit and returns it along with
|
||||
/// a `u64` giving an estimate of the unit's processing cost.
|
||||
fn compile_codegen_unit(
|
||||
@ -127,6 +133,7 @@ pub trait ExtraBackendMethods:
|
||||
tcx: TyCtxt<'_>,
|
||||
cgu_name: Symbol,
|
||||
) -> (ModuleCodegen<Self::Module>, u64);
|
||||
|
||||
fn target_machine_factory(
|
||||
&self,
|
||||
sess: &Session,
|
||||
|
@ -25,6 +25,7 @@ pub trait MiscMethods<'tcx>: BackendTypes {
|
||||
fn codegen_unit(&self) -> &'tcx CodegenUnit<'tcx>;
|
||||
fn set_frame_pointer_type(&self, llfn: Self::Function);
|
||||
fn apply_target_cpu_attr(&self, llfn: Self::Function);
|
||||
/// Declares the extern "C" main function for the entry point. Returns None if the symbol already exists.
|
||||
/// Declares the extern "C" main function for the entry point. Returns None if the symbol
|
||||
/// already exists.
|
||||
fn declare_c_main(&self, fn_type: Self::Type) -> Option<Self::Function>;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user