summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa/src/base.rs
AgeCommit message (Collapse)AuthorLines
2023-02-24Rename many interner functions.Nicholas Nethercote-1/+1
(This is a large commit. The changes to `compiler/rustc_middle/src/ty/context.rs` are the most important ones.) The current naming scheme is a mess, with a mix of `_intern_`, `intern_` and `mk_` prefixes, with little consistency. In particular, in many cases it's easy to use an iterator interner when a (preferable) slice interner is available. The guiding principles of the new naming system: - No `_intern_` prefixes. - The `intern_` prefix is for internal operations. - The `mk_` prefix is for external operations. - For cases where there is a slice interner and an iterator interner, the former is `mk_foo` and the latter is `mk_foo_from_iter`. Also, `slice_interners!` and `direct_interners!` can now be `pub` or non-`pub`, which helps enforce the internal/external operations division. It's not perfect, but I think it's a clear improvement. The following lists show everything that was renamed. slice_interners - const_list - mk_const_list -> mk_const_list_from_iter - intern_const_list -> mk_const_list - substs - mk_substs -> mk_substs_from_iter - intern_substs -> mk_substs - check_substs -> check_and_mk_substs (this is a weird one) - canonical_var_infos - intern_canonical_var_infos -> mk_canonical_var_infos - poly_existential_predicates - mk_poly_existential_predicates -> mk_poly_existential_predicates_from_iter - intern_poly_existential_predicates -> mk_poly_existential_predicates - _intern_poly_existential_predicates -> intern_poly_existential_predicates - predicates - mk_predicates -> mk_predicates_from_iter - intern_predicates -> mk_predicates - _intern_predicates -> intern_predicates - projs - intern_projs -> mk_projs - place_elems - mk_place_elems -> mk_place_elems_from_iter - intern_place_elems -> mk_place_elems - bound_variable_kinds - mk_bound_variable_kinds -> mk_bound_variable_kinds_from_iter - intern_bound_variable_kinds -> mk_bound_variable_kinds direct_interners - region - intern_region (unchanged) - const - mk_const_internal -> intern_const - const_allocation - intern_const_alloc -> mk_const_alloc - layout - intern_layout -> mk_layout - adt_def - intern_adt_def -> mk_adt_def_from_data (unusual case, hard to avoid) - alloc_adt_def(!) -> mk_adt_def - external_constraints - intern_external_constraints -> mk_external_constraints Other - type_list - mk_type_list -> mk_type_list_from_iter - intern_type_list -> mk_type_list - tup - mk_tup -> mk_tup_from_iter - intern_tup -> mk_tup
2023-02-18Use inttoptr to support usize as dyn* value, use pointercast to make sure ↵Michael Goulet-0/+8
pointers are compatible
2023-02-18make first component of dyn* use pointer layout+type, and adjust DynStar commentRalf Jung-8/+1
2023-02-16`if $c:expr { Some($r:expr) } else { None }` =>> `$c.then(|| $r)`Maybe Waffle-6/+4
2023-02-14s/eval_usize/eval_target_usize/ for clarityOli Scherer-1/+1
2023-02-10[link] enable packed bundled lib in non stable casesDaniil Belov-0/+1
2023-01-26add EarlyBinder::no_bound_varsKyle Matsuda-1/+1
2023-01-26change fn_sig query to use EarlyBinder; remove bound_fn_sig query; add ↵Kyle Matsuda-1/+1
EarlyBinder to fn_sig in metadata
2023-01-19Use UnordSet instead of FxHashSet in define_id_collections!().Michael Woerister-6/+9
2023-01-11Allow codegen to unsize dyn* to dynMichael Goulet-3/+1
2022-12-27UPDATE - migrate base.rs to new diagnostics infrastructureJhonny Bill Mena-11/+5
2022-12-20Remove wrapper functions for some unstable optionsNilstrieb-2/+2
They are trivial and just forward to the option. Like most other options, we can just access it directly.
2022-12-10compiler: remove unnecessary imports and qualified pathsKaDiWa-1/+0
2022-11-12linker: Simplify linking of `compiler_builtins` and `profiler_builtins`Vadim Petrochenkov-6/+13
This also fixes linking of native libraries bundled into these crates when `-Zpacked-bundled-libs` is enabled
2022-10-31Rewrite implementation of `#[alloc_error_handler]`Amanieu d'Antras-1/+8
The new implementation doesn't use weak lang items and instead changes `#[alloc_error_handler]` to an attribute macro just like `#[global_allocator]`. The attribute will generate the `__rg_oom` function which is called by the compiler-generated `__rust_alloc_error_handler`. If no `__rg_oom` function is defined in any crate then the compiler shim will call `__rdl_oom` in the alloc crate which will simply panic. This also fixes link errors with `-C link-dead-code` with `default_alloc_error_handler`: `__rg_oom` was previously defined in the alloc crate and would attempt to reference the `oom` lang item, even if it didn't exist. This worked as long as `__rg_oom` was excluded from linking since it was not called. This is a prerequisite for the stabilization of `default_alloc_error_handler` (#102318).
2022-10-29Cleanup weak lang itemsCameron Steffen-7/+6
2022-10-25Simplify `cast_shift_expr_rhs`.Nicholas Nethercote-21/+16
It's only ever used with shift operators.
2022-10-25Inline and remove `cast_shift_rhs`.Nicholas Nethercote-9/+0
It has a single call site.
2022-10-15linker: Fix weak lang item linking with combination windows-gnu + LLD + LTOVadim Petrochenkov-3/+8
2022-10-14Address nits, add test for implicit dyn-star coercion without feature gateMichael Goulet-2/+5
2022-10-14Allow dyn* upcastingMichael Goulet-13/+48
2022-10-01Merge apply_attrs_callsite into call and invokebjorn3-1/+1
Some codegen backends are not able to apply callsite attrs after the fact.
2022-09-10Fix pointer value punning.Charles Lew-1/+6
Seems this doesn't trigger error on LLVM 15, but let's fix it for better compatibility.
2022-09-06Fix CI failures on windows and aarch64-linuxVadim Petrochenkov-20/+28
2022-09-06change stdlib circular dependencies handlingDaniil Belov-17/+27
2022-08-28Support `#[unix_sigpipe = "inherit|sig_dfl|sig_ign"]` on `fn main()`Martin Nordholts-6/+10
This makes it possible to instruct libstd to never touch the signal handler for `SIGPIPE`, which makes programs pipeable by default (e.g. with `./your-program | head -n 1`) without `ErrorKind::BrokenPipe` errors.
2022-08-06make NOP dyn casts not require anything about the vtableRalf Jung-0/+1
2022-07-27Reliably signal coordinator thread on panic during ongoing codegenNikita Popov-54/+4
Replace the separate AbortCodegenOnDrop guard by integrating this functionality into OngoingCodegen (or rather, the Coordinator part of it). This ensures that we send a CodegenAborted message and wait for workers to finish even if the panic occurs outside codegen_crate() (e.g. inside join_codegen()). This requires some minor changes to the handling of CodegenAborted, as it can now occur when the main thread is LLVMing rather than Codegenning.
2022-07-20consistently use VTable over Vtable (matching stable stdlib API RawWakerVTable)Ralf Jung-1/+1
2022-07-13Rename `debugging_opts` to `unstable_opts`Joshua Nelson-1/+1
This is no longer used only for debugging options (e.g. `-Zoutput-width`, `-Zallow-features`). Rename it to be more clear.
2022-06-07Rollup merge of #97738 - Kixiron:zst-panic, r=eddybDylan DPC-2/+3
Fix ICEs from zsts within unsized types with non-zero offsets - Fixes #97732 - Fixes ICEs while compiling `alloc` with `-Z randomize-layout` r? ``@eddyb``
2022-06-06Rename CodegenUnit::work_product to previous_work_productbjorn3-2/+2
It returns the previous work product or panics if there is none. This rename makes the purpose of this method clearer.
2022-06-04Fixed premature assertions that caused -Z randomize-layout to fail on allocChase Wilson-2/+3
2022-05-24Add support for embedding pretty printers via the `#[debugger_visualizer]` ↵ridwanabdillahi-13/+48
attribute. Add tests for embedding pretty printers and update documentation. Ensure all error checking for `#[debugger_visualizer]` is done up front and not when the `debugger_visualizer` query is run. Clean up potential ODR violations when embedding pretty printers into the `__rustc_debug_gdb_scripts_section__` section. Respond to PR comments and update documentation.
2022-05-15Compute pre_compiled_cgus more eagerlybjorn3-28/+19
This reduces the complexity of this code a lot
2022-05-15Move cgu_reuse a bit earlierbjorn3-8/+8
There is no reason it needs to be lazily computed at the first iteration of the cgu loop.
2022-05-03Add support for a new attribute `#[debugger_visualizer]` to support ↵ridwanabdillahi-1/+17
embedding debugger visualizers into a generated PDB. Cleanup `DebuggerVisualizerFile` type and other minor cleanup of queries. Merge the queries for debugger visualizers into a single query. Revert move of `resolve_path` to `rustc_builtin_macros`. Update dependencies in Cargo.toml for `rustc_passes`. Respond to PR comments. Load visualizer files into opaque bytes `Vec<u8>`. Debugger visualizers for dynamically linked crates should not be embedded in the current crate. Update the unstable book with the new feature. Add the tracking issue for the debugger_visualizer feature. Respond to PR comments and minor cleanups.
2022-04-30Merge new_metadata into codegen_allocatorbjorn3-9/+2
2022-04-25Auto merge of #95604 - nbdd0121:used2, r=petrochenkovbors-0/+7
Generate synthetic object file to ensure all exported and used symbols participate in the linking Fix #50007 and #47384 This is the synthetic object file approach that I described in https://github.com/rust-lang/rust/pull/95363#issuecomment-1079932354, allowing all exported and used symbols to be linked while still allowing them to be GCed. Related #93791, #95363 r? `@petrochenkov` cc `@carbotaniuman`
2022-04-18Synthesis object file for `#[used]` and exported symbolsGary Guo-0/+7
2022-04-08check_doc_keyword: don't alloc string for emptiness checkklensy-1/+1
check_doc_alias_value: get argument as Symbol to prevent needless string convertions check_doc_attrs: don't alloc vec, iterate over slice. Vec introduced in #83149, but no perf run posted on merge replace as_str() check with symbol check get_single_str_from_tts: don't prealloc string trivial string to str replace LifetimeScopeForPath::NonElided use Vec<Symbol> instead of Vec<String> AssertModuleSource use BTreeSet<Symbol> instead of BTreeSet<String> CrateInfo.crate_name replace FxHashMap<CrateNum, String> with FxHashMap<CrateNum, Symbol>
2022-03-28use cfg attribute instead of macroklensy-25/+27
2022-03-11Improve `AdtDef` interning.Nicholas Nethercote-1/+1
This commit makes `AdtDef` use `Interned`. Much the commit is tedious changes to introduce getter functions. The interesting changes are in `compiler/rustc_middle/src/ty/adt.rs`.
2022-02-23Normalize main return type during mono item collection & codegenTomasz Miąsko-1/+4
2022-02-19Adopt let else in more placesest31-12/+9
2022-02-09Ensure that queries only return Copy types.Camille GILLOT-2/+2
2021-12-19Auto merge of #91957 - nnethercote:rm-SymbolStr, r=oli-obkbors-1/+1
Remove `SymbolStr` This was originally proposed in https://github.com/rust-lang/rust/pull/74554#discussion_r466203544. As well as removing the icky `SymbolStr` type, it allows the removal of a lot of `&` and `*` occurrences. Best reviewed one commit at a time. r? `@oli-obk`
2021-12-15Remove unnecessary sigils around `Symbol::as_str()` calls.Nicholas Nethercote-1/+1
2021-12-15Remove `in_band_lifetimes` from `rustc_codegen_ssa`LegionMammal978-1/+1
See #91867 for more information.
2021-12-07Use object crate for .rustc metadata generationNikita Popov-26/+40
We already use the object crate for generating uncompressed .rmeta metadata object files. This switches the generation of compressed .rustc object files to use the object crate as well. These have slightly different requirements in that .rmeta should be completely excluded from any final compilation artifacts, while .rustc should be part of shared objects, but not loaded into memory. The primary motivation for this change is #90326: In LLVM 14, the current way of setting section flags (and in particular, preventing the setting of SHF_ALLOC) will no longer work. There are other ways we could work around this, but switching to the object crate seems like the most elegant, as we already use it for .rmeta, and as it makes this independent of the codegen backend. In particular, we don't need separate handling in codegen_llvm and codegen_gcc. codegen_cranelift should be able to reuse the implementation as well, though I have omitted that here, as it is not based on codegen_ssa. This change mostly extracts the existing code for .rmeta handling to allow using it for .rustc as well, and adjust the codegen infrastructure to handle the metadata object file separately: We no longer create a backend-specific module for it, and directly produce the compiled module instead. This does not fix #90326 by itself yet, as .llvmbc will need to be handled separately.