summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa
AgeCommit message (Collapse)AuthorLines
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-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.
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.
2022-04-29Rollup merge of #96523 - nbdd0121:windows, r=petrochenkovDylan DPC-0/+23
Add `@feat.00` symbol to symbols.o for COFF Fix #96498 This is based on top of #96444. r? ``@petrochenkov``
2022-04-29Auto merge of #96444 - nbdd0121:used2, r=petrochenkovbors-2/+77
Use decorated names for linked_symbols on Windows Fix #96423 r? `@petrochenkov`
2022-04-28Add `@feat.00` symbol to symbols.o for COFFGary Guo-0/+23
2022-04-28use tcx.require_lang_item() insteadSparrowLii-12/+5
2022-04-28Rollup merge of #96432 - SparrowLii:dbg_scope, r=davidtwcoDylan DPC-9/+3
not need `Option` for `dbg_scope` This PR fixes a few FIXME about not using `Option` in `dbg_scope` field of `DebugScope`, during `create_function_debug_context` func in codegen parts. Added a `BitSet<SourceScope>` parameter to `make_mir_scope` to indicate whether the `DebugScope` has been instantiated. cc ````@eddyb````
2022-04-27Use decorated names for linked_symbols on WindowsGary Guo-2/+77
2022-04-27Eliminate duplication of building panic langcall in codegenSparrowLii-24/+16
2022-04-26linker: Generate `symbols.o` for dylibsVadim Petrochenkov-2/+2
2022-04-26linker: Stop using whole-archive on dependencies of dylibsVadim Petrochenkov-42/+6
https://github.com/rust-lang/rust/pull/95604 implemented a better and more fine-grained way of keeping exported symbols alive.
2022-04-26not need `Option` for `dbg_scope`SparrowLii-9/+3
2022-04-25Auto merge of #95604 - nbdd0121:used2, r=petrochenkovbors-56/+240
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-25Stop exporting rust_eh_personality and friends from cdylibGary Guo-15/+9
2022-04-24Fix MSVC hang issueGary Guo-0/+6
2022-04-21Auto merge of #95612 - davidtwco:split-debuginfo-in-bootstrap, r=Mark-Simulacrumbors-1/+1
bootstrap: add split-debuginfo config Replace `run-dysutil` option with more general `split-debuginfo` option that works on all platforms. r? `@Mark-Simulacrum`
2022-04-19Rollup merge of #96142 - cjgillot:no-crate-def-index, r=petrochenkovDylan DPC-15/+2
Stop using CRATE_DEF_INDEX outside of metadata encoding. `CRATE_DEF_ID` and `CrateNum::as_def_id` are almost always what we want. We should not manipulate raw `DefIndex` outside of metadata encoding.
2022-04-18Conditionally export msan symbols only if they are definedGary Guo-2/+10
* `__msan_keep_going` is defined when `-Zsanitizer-recover=memory`. * `__msan_track_origins` is defined when `-Zsanitizer-memory-track-origins`.
2022-04-18Refactor exported_symbols and linked_symbols for code reuseGary Guo-44/+26
2022-04-18Synthesis object file for `#[used]` and exported symbolsGary Guo-8/+172
2022-04-18Add `SymbolExportInfo`Gary Guo-21/+51
This is currently a wrapper to `SymbolExportLevel` but it allows later addition of extra information.
2022-04-18ssa: don't pack debuginfo on windows not only msvcDavid Wood-1/+1
Small fix that prevents `thorin` from running on platforms where it definitely shouldn't be running. Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-17Stop using CRATE_DEF_INDEX.Camille GILLOT-15/+2
`CRATE_DEF_ID` and `CrateNum::as_def_id` are almost always what we want.
2022-04-17Auto merge of #96010 - eduardosm:Unique-on-top-of-NonNull, r=m-ou-se,tmiaskobors-2/+6
Implement `core::ptr::Unique` on top of `NonNull` Removes the use `rustc_layout_scalar_valid_range_start` and some `unsafe` blocks.
2022-04-15Add codegen for global_asm! sym operandsAmanieu d'Antras-6/+30
2022-04-14Add additional `extract_field` / `project_field` to take into account extra ↵Eduardo Sánchez Muñoz-2/+6
level of struct nesting.
2022-04-13Auto merge of #95968 - davidtwco:translation-lazy-fallback, r=oli-obkbors-1/+1
errors: lazily load fallback fluent bundle Addresses (hopefully) https://github.com/rust-lang/rust/pull/95667#issuecomment-1094794087. Loading the fallback bundle in compilation sessions that won't go on to emit any errors unnecessarily degrades compile time performance, so lazily create the Fluent bundle when it is first required. r? `@ghost` (just for perf initially)
2022-04-13Auto merge of #95656 - cjgillot:no-id-hashing-mode, r=Aaron1011bors-6/+1
Remove NodeIdHashingMode. r? `@ghost`
2022-04-13errors: lazily load fallback fluent bundleDavid Wood-1/+1
Loading the fallback bundle in compilation sessions that won't go on to emit any errors unnecessarily degrades compile time performance, so lazily create the Fluent bundle when it is first required. Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-12Remove NodeIdHashingMode.Camille GILLOT-6/+1
2022-04-11Add new `MutatatingUseContext`s for deinit and `SetDiscriminant`Jakob Degen-0/+2
2022-04-11Add new `Deinit` statement kindJakob Degen-0/+6
2022-04-08check_doc_keyword: don't alloc string for emptiness checkklensy-4/+4
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-04-05Auto merge of #94527 - oli-obk:undef_scalars, r=nagisa,erikdesjardinbors-18/+23
Let CTFE to handle partially uninitialized unions without marking the entire value as uninitialized. follow up to #94411 To fix https://github.com/rust-lang/rust/issues/69488 and by extension fix https://github.com/rust-lang/rust/issues/94371, we should stop treating types like `MaybeUninit<usize>` as something that the `Scalar` type in the interpreter engine can represent. So we add a new field to `abi::Primitive` that records whether the primitive is nested in a union cc `@RalfJung` r? `@ghost`
2022-04-05Mark scalar layout unions so that backends that do not support partially ↵Oli Scherer-18/+23
initialized scalars can special case them.