about summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa
AgeCommit message (Collapse)AuthorLines
2022-06-13Add Apple WatchOS compile targetsVladimir Michael Eatwell-2/+12
2022-06-11Use safer `strip=symbols`-flag for dylibs on macOSDavid Knaack-4/+8
2022-06-11Auto merge of #97905 - nnethercote:revert-infallible-encoder, r=bjorn3bors-5/+4
Revert part of #94372 to improve performance #94732 was supposed to give small but widespread performance improvements, as judged from three per-merge performance runs. But the performance run that occurred after merging included a roughly equal number of improvements and regressions, for unclear reasons. This PR is for a test run reverting those changes, to see what happens. r? `@ghost`
2022-06-10Revert dc08bc51f2c58a0f5f815a07f9bb3d671153b5a1.Nicholas Nethercote-1/+1
2022-06-10Revert b983e42936feab29f6333e9835913afc6b4a394e.Nicholas Nethercote-4/+3
2022-06-09Stabilize the `bundle` native library modifierVadim Petrochenkov-2/+2
2022-06-08Rename `rustc_serialize::opaque::Encoder` as `MemEncoder`.Nicholas Nethercote-3/+4
This avoids the name clash with `rustc_serialize::Encoder` (a trait), and allows lots qualifiers to be removed and imports to be simplified (e.g. fewer `as` imports).
2022-06-08Move `finish` out of the `Encoder` trait.Nicholas Nethercote-1/+1
This simplifies things, but requires making `CacheEncoder` non-generic.
2022-06-08Use delayed error handling for `Encodable` and `Encoder` infallible.Nicholas Nethercote-6/+6
There are two impls of the `Encoder` trait: `opaque::Encoder` and `opaque::FileEncoder`. The former encodes into memory and is infallible, the latter writes to file and is fallible. Currently, standard `Result`/`?`/`unwrap` error handling is used, but this is a bit verbose and has non-trivial cost, which is annoying given how rare failures are (especially in the infallible `opaque::Encoder` case). This commit changes how `Encoder` fallibility is handled. All the `emit_*` methods are now infallible. `opaque::Encoder` requires no great changes for this. `opaque::FileEncoder` now implements a delayed error handling strategy. If a failure occurs, it records this via the `res` field, and all subsequent encoding operations are skipped if `res` indicates an error has occurred. Once encoding is complete, the new `finish` method is called, which returns a `Result`. In other words, there is now a single `Result`-producing method instead of many of them. This has very little effect on how any file errors are reported if `opaque::FileEncoder` has any failures. Much of this commit is boring mechanical changes, removing `Result` return values and `?` or `unwrap` from expressions. The more interesting parts are as follows. - serialize.rs: The `Encoder` trait gains an `Ok` associated type. The `into_inner` method is changed into `finish`, which returns `Result<Vec<u8>, !>`. - opaque.rs: The `FileEncoder` adopts the delayed error handling strategy. Its `Ok` type is a `usize`, returning the number of bytes written, replacing previous uses of `FileEncoder::position`. - Various methods that take an encoder now consume it, rather than being passed a mutable reference, e.g. `serialize_query_result_cache`.
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/+7
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-11/+19
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-11/+19
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.