about summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa/src
AgeCommit message (Collapse)AuthorLines
2022-06-08Don't pass in a vector to `Encoder::new`.Nicholas Nethercote-1/+1
It's not necessary.
2022-06-08Remove an unnecessary encoder operation.Nicholas Nethercote-2/+0
2022-06-07Rollup merge of #97808 - alexcrichton:wasm-features, r=petrochenkovDylan DPC-0/+3
Add some unstable target features for the wasm target codegen I was experimenting with cross-language LTO for the wasm target recently between Rust and C and found that C was injecting the `+mutable-globals` flag on all functions. When specifying the corresponding `-Ctarget-feature=+mutable-globals` feature to Rust it prints a warning about an unknown feature. I've added the `mutable-globals` feature plus another few I know of to the list of known features for wasm targets. These features all continue to be unstable to source code as they were before.
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-07Rollup merge of #97058 - bjorn3:multi_artifact_work_products, r=nagisaDylan DPC-31/+27
Various refactors to the incr comp workproduct handling This is the result of me looking into adding support for having multiple object files for a single codegen unit to incr comp. This is necessary to support inline assembly in cg_clif without requiring partial linking which is not supported on Windows and seems to fail on macOS for some reason. Cg_clif uses an external assembler to handle inline asm and thus produces one object file with regular functions and one object file containing compiled inline asm for each codegen unit which uses inline asm. Current incr comp can't handle this. This PR doesn't yet add support for this, but it makes it easier to do so.
2022-06-06Add some unstable target features for the wasm target codegenAlex Crichton-0/+3
I was experimenting with cross-language LTO for the wasm target recently between Rust and C and found that C was injecting the `+mutable-globals` flag on all functions. When specifying the corresponding `-Ctarget-feature=+mutable-globals` feature to Rust it prints a warning about an unknown feature. I've added the `mutable-globals` feature plus another few I know of to the list of known features for wasm targets. These features all continue to be unstable to source code as they were before.
2022-06-06Make saved_file field of WorkProduct non-optionalbjorn3-23/+19
A WorkProduct without a saved file is useless
2022-06-06Factor Option out of copy_cgu_workproduct_to_incr_comp_cache_dir callbjorn3-6/+6
This improves clarity of the code a bit
2022-06-06Avoid an unnecessary clone for copy_cgu_workproduct_to_incr_comp_cache_dir callsbjorn3-2/+2
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-06-03Fully stabilize NLLJack Huey-1/+0
2022-06-03Fix emscripten linker invocationbjorn3-13/+6
2022-06-03Avoid rustc_serialize in linker.rsbjorn3-16/+13
2022-06-02commentRalf Jung-0/+3
Co-authored-by: Oli Scherer <github35764891676564198441@oli-obk.de>
2022-06-02add cast kind of from_exposed_addr (int-to-ptr casts)Ralf Jung-1/+2
2022-06-01Session object: Decouple e_flags from FileFlagsMartin Kröning-5/+6
2022-06-01rename PointerAddress → PointerExposeAddressRalf Jung-1/+1
2022-05-31Add a pointer to address cast kindTomasz Miąsko-3/+7
A pointer to address cast are often special-cased. Introduce a dedicated cast kind to make them easy distinguishable.
2022-05-29Rollup merge of #97028 - ridwanabdillahi:pretty-printer, r=michaelwoeristerGuillaume Gomez-57/+87
Add support for embedding pretty printers via `#[debugger_visualizer]` attribute Initial support for [RFC 3191](https://github.com/rust-lang/rfcs/pull/3191) in PR https://github.com/rust-lang/rust/pull/91779 was scoped to supporting embedding NatVis files using a new attribute. This PR implements the pretty printer support as stated in the RFC mentioned above. This change includes embedding pretty printers in the `.debug_gdb_scripts` just as the pretty printers for rustc are embedded today. Also added additional tests for embedded pretty printers. Additionally cleaned up error checking so all error checking is done up front regardless of the current target. RFC: https://github.com/rust-lang/rfcs/pull/3191
2022-05-26clippy::complexity fixesMatthias Krüger-1/+1
clone_on_copy useless_format bind_instead_of_map filter_map_identity useless_conversion map_flatten unnecessary_unwrap
2022-05-26Auto merge of #97369 - tmiasko:codgen-ssa-atomic-ordering, r=michaelwoeristerbors-8/+11
rustc_codegen_ssa: cleanup `AtomicOrdering` * Remove unused `NotAtomic` ordering. * Rename `Monotonic` to `Relaxed` - a Rust specific name. * Derive copy and clone.
2022-05-25Simplify implementation of `-Z gcc-ld`Vadim Petrochenkov-37/+15
- The logic is now unified for all targets (wasm targets should also be supported now) - Additional "symlink" files like `ld64` are eliminated - lld-wrapper is used for propagating the correct lld flavor - Cleanup "unwrap or exit" logic in lld-wrapper
2022-05-25rustc_codegen_ssa: derive copy and clone for various enumsTomasz Miąsko-0/+5
2022-05-25rustc_codegen_ssa: cleanup `AtomicOrdering`Tomasz Miąsko-8/+6
* Remove unused `NotAtomic` ordering. * Rename `Monotonic` to `Relaxed` - a Rust specific name.
2022-05-24Add support for embedding pretty printers via the `#[debugger_visualizer]` ↵ridwanabdillahi-57/+87
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-24Add flag for stricter checks on uninit/zeroed5225225-3/+5
2022-05-23Refactor call terminator to always hold a destination placeJakob Degen-17/+19
2022-05-19Rollup merge of #97062 - bjorn3:cg_ssa_driver_refactor, r=compiler-errorsYuki Okushi-33/+24
Couple of refactorings to cg_ssa::base::codegen_crate This makes the code simpler and easier to read.
2022-05-17Change `Successors` to `impl Iterator<Item = BasicBlock>`SparrowLii-1/+1
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-13Auto merge of #96930 - ayrtonm:mips32-tmp-file, r=petrochenkovbors-10/+18
Fix e_flags for 32-bit MIPS targets in generated object file In #95604 the compiler started generating a temporary symbols.o which is added to the linker invocation. This object file has an `e_flags` which is invalid for 32-bit MIPS targets. Even though symbols.o doesn't contain code, linking these targets with [lld fails](https://github.com/llvm/llvm-project/blob/main/lld/ELF/Arch/MipsArchTree.cpp#L76-L79) with ``` rust-lld: error: foo-cgu.0.rcgu.o: ABI 'o32' is incompatible with target ABI 'n64' ``` because it omits the ABI bits (`EF_MIPS_ABI_O32`) so lld assumes it's using the N64 ABI. This breaks linking on nightly for the out-of-tree [mipsel-sony-psx target](https://github.com/ayrtonm/psx-sdk-rs/issues/9), the builtin mipsel-sony-psp target (cc `@overdrivenpotato)` and probably any other 32-bit MIPS target using lld. This PR sets the ABI in `e_flags` to O32 since that's the only ABI for 32-bit MIPS that LLVM supports. It also sets other `e_flags` bits based on the target to avoid similar issues with the object file arch and PIC. I had to bump the object crate version since some of these constants were [added recently](https://github.com/gimli-rs/object/pull/433). I'm not sure if this PR needs a test, but I can confirm that it fixes the linking issue on both targets I mentioned.
2022-05-11Add `unsigned_offset_from` on pointersScott McMurray-7/+14
Like we have `add`/`sub` which are the `usize` version of `offset`, this adds the `usize` equivalent of `offset_from`. Like how `.add(d)` replaced a whole bunch of `.offset(d as isize)`, you can see from the changes here that it's fairly common that code actually knows the order between the pointers and *wants* a `usize`, not an `isize`. As a bonus, this can do `sub nuw`+`udiv exact`, rather than `sub`+`sdiv exact`, which can be optimized slightly better because it doesn't have to worry about negatives. That's why the slice iterators weren't using `offset_from`, though I haven't updated that code in this PR because slices are so perf-critical that I'll do it as its own change. This is an intrinsic, like `offset_from`, so that it can eventually be allowed in CTFE. It also allows checking the extra safety condition -- see the test confirming that CTFE catches it if you pass the pointers in the wrong order.
2022-05-11Only compile #[used] as llvm.compiler.used for ELF targetsThom Chiovoloni-1/+3
2022-05-10Fix e_flags for 32-bit MIPS targets in generated object fileAyrton-10/+18
In #95604 the compiler started generating a temporary symbols.o which is added to the linker invocation. This object file has an `e_flags` which may be invalid for 32-bit MIPS targets. Even though symbols.o doesn't contain code, linking with [lld fails](https://github.com/llvm/llvm-project/blob/main/lld/ELF/Arch/MipsArchTree.cpp#L79) with ``` rust-lld: error: foo-cgu.0.rcgu.o: ABI 'o32' is incompatible with target ABI 'n64' ``` because it omits the ABI bits (EF_MIPS_ABI_O32) so lld assumes it's using the N64 ABI. This breaks linking on nightly for the out-of-tree [psx target](https://github.com/ayrtonm/psx-sdk-rs/issues/9), the builtin mipsel-sony-psp target (cc @overdrivenpotato) and any other 32-bit MIPS target using lld. This PR sets the ABI in `e_flags` to O32 since that's the only ABI for 32-bit MIPS that LLVM supports. It also sets other `e_flags` bits based on the target. I had to bump the object crate version since some of these constants were [added recently](https://github.com/gimli-rs/object/pull/433). I'm not sure if this PR needs a test, but I can confirm that it fixes the linking issue on both targets I mentioned.
2022-05-05Auto merge of #91779 - ridwanabdillahi:natvis, r=michaelwoeristerbors-11/+83
Add a new Rust attribute to support embedding debugger visualizers Implemented [this RFC](https://github.com/rust-lang/rfcs/pull/3191) to add support for embedding debugger visualizers into a PDB. Added a new attribute `#[debugger_visualizer]` and updated the `CrateMetadata` to store debugger visualizers for crate dependencies. RFC: https://github.com/rust-lang/rfcs/pull/3191
2022-05-04Stabilize `bool::then_some`Josh Triplett-1/+0
2022-05-03Add support for a new attribute `#[debugger_visualizer]` to support ↵ridwanabdillahi-11/+83
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-05-03Auto merge of #96601 - tmiasko:ssa-rpo, r=davidtwcobors-2/+2
Use reverse postorder in `non_ssa_locals` The reverse postorder, unlike preorder, is now cached inside the MIR body. Code generation uses reverse postorder anyway, so it might be a small perf improvement to use it here as well.
2022-05-03Rollup merge of #96587 - bjorn3:refactor_backend_write, r=michaelwoeristerYuki Okushi-30/+15
Refactor the WriteBackendMethods and ExtraBackendMethods traits The new interface is slightly less confusing and is easier to implement for non-LLVM backends.
2022-05-02Auto merge of #96436 - petrochenkov:nowhole2, r=wesleywiserbors-44/+8
linker: Stop using whole-archive on dependencies of dylibs https://github.com/rust-lang/rust/pull/95604 implemented a better and more fine-grained way of keeping exported symbols alive. Addresses the second question from https://github.com/rust-lang/rust/pull/93901#issuecomment-1041325522. r? `@wesleywiser`
2022-05-01Use reverse postorder in `non_ssa_locals`Tomasz Miąsko-2/+2
The reverse postorder, unlike preorder, is now cached inside the MIR body. Code generation uses reverse postorder anyway, so it might be a small perf improvement to use it here as well.
2022-04-30Merge new_metadata into codegen_allocatorbjorn3-15/+4
2022-04-30Remove config parameter of optimize_fat and avoid interior mutability for modulebjorn3-5/+3
2022-04-30Let LtoModuleCodegen::optimize take self by valuebjorn3-9/+8
2022-04-30Rename run_lto_pass_manager to optimize_fat and remove thin parameterbjorn3-6/+5
2022-04-30Auto merge of #96500 - SparrowLii:rpo, r=tmiaskobors-1/+0
Reduce duplication of RPO calculation of mir Computing the RPO of mir is not a low-cost thing, but it is duplicate in many places. In particular the `iterate_to_fixpoint` method which is called multiple times when computing the data flow. This PR reduces the number of times the RPO is recalculated as much as possible, which should save some compile time.
2022-04-30Eliminate duplication of RPO calculation for mirSparrowLii-1/+0
add `postorder_cache` to mir Body add `ReversePostorderCache` struct correct struct name and comments
2022-04-29Auto merge of #96474 - SparrowLii:langcall, r=lcnrbors-29/+14
Eliminate duplication code of building panic langcall during codegen From the FIXME in the `codegen_panic_intrinsic` func.