about summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa
AgeCommit message (Collapse)AuthorLines
2023-12-22Auto merge of #119097 - nnethercote:fix-EmissionGuarantee, r=compiler-errorsbors-47/+48
Fix `EmissionGuarantee` There are some problems with the `DiagCtxt` API related to `EmissionGuarantee`. This PR fixes them. r? `@compiler-errors`
2023-12-21Auto merge of #119056 - cjgillot:codegen-overalign, r=wesleywiserbors-1/+1
Tolerate overaligned MIR constants for codegen. Fixes https://github.com/rust-lang/rust/issues/117761 cc `@saethlin`
2023-12-20Rollup merge of #118973 - Enselic:fix-IncorrectCguReuseType, r=michaelwoeristerMatthias Krüger-2/+2
rustc_codegen_ssa: Don't drop `IncorrectCguReuseType` , make `rustc_expected_cgu_reuse` attr work In [100753], `IncorrectCguReuseType` accidentally stopped being emitted by removing `diag.span_err(...)`. Begin emitting it again rather than just blindly dropping it, and adjust tests accordingly. We assume that there are no bugs and that the currently actual CGU reuse is correct. If there are bugs, they will be discovered and fixed eventually, and the tests will then be updated. [100753]: https://github.com/rust-lang/rust/pull/100753/commits/706452eba74026c51e8d0fa30aee2497c69eafc0#diff-048389738ddcbe0f9765291a29db1fed9a5f03693d4781cfb5aaa97ffb3c7f84 Closes #118972
2023-12-19rustc_codegen_ssa: Don't let `IncorrectCguReuseType` errors get lostMartin Nordholts-2/+2
In [100753], `IncorrectCguReuseType` accidentally stopped being emitted. Begin emitting it again rather than just blindly dropping it, and adjust tests accordingly. [100753]: https://github.com/rust-lang/rust/pull/100753/commits/706452eba74026c51e8d0fa30aee2497c69eafc0#diff-048389738ddcbe0f9765291a29db1fed9a5f03693d4781cfb5aaa97ffb3c7f84
2023-12-19Add `level` arg to `into_diagnostic`.Nicholas Nethercote-47/+48
And make all hand-written `IntoDiagnostic` impls generic, by using `DiagnosticBuilder::new(dcx, level, ...)` instead of e.g. `dcx.struct_err(...)`. This means the `create_*` functions are the source of the error level. This change will let us remove `struct_diagnostic`. Note: `#[rustc_lint_diagnostics]` is added to `DiagnosticBuilder::new`, it's necessary to pass diagnostics tests now that it's used in `into_diagnostic` functions.
2023-12-18Auto merge of #119069 - matthiaskrgr:rollup-xxk4m30, r=matthiaskrgrbors-10/+14
Rollup of 5 pull requests Successful merges: - #118852 (coverage: Skip instrumenting a function if no spans were extracted from MIR) - #118905 ([AIX] Fix XCOFF metadata) - #118967 (Add better ICE messages for some undescriptive panics) - #119051 (Replace `FileAllocationInfo` with `FileEndOfFileInfo`) - #119059 (Deny `~const` trait bounds in inherent impl headers) r? `@ghost` `@rustbot` modify labels: rollup
2023-12-18Rollup merge of #118905 - bzEq:revert-u64-on-xcoff, r=WaffleLapkinMatthias Krüger-10/+14
[AIX] Fix XCOFF metadata #118344 accidentally changed the way to get metadata from XCOFF file and broken our internal CI. This PR reverts part of #118344 .
2023-12-18Rename many `DiagCtxt` and `EarlyDiagCtxt` locals.Nicholas Nethercote-10/+9
2023-12-18Rename many `DiagCtxt` arguments.Nicholas Nethercote-49/+48
2023-12-18Rename `CodegenContext::create_diag_handler` as `CodegenContext::create_dcx`.Nicholas Nethercote-9/+5
2023-12-18Rename `Session::span_diagnostic` as `Session::dcx`.Nicholas Nethercote-32/+22
2023-12-18Rename `Handler` as `DiagCtxt`.Nicholas Nethercote-13/+13
2023-12-18Address commentKai Luo-1/+1
2023-12-17Tolerate overaligned MIR constants for codegen.Camille GILLOT-1/+1
2023-12-15Don't pass lint back out of lint decoratorMichael Goulet-1/+3
2023-12-14Rollup merge of #118933 - nnethercote:cleanup-errors-even-more, ↵Jubilee-1/+1
r=compiler-errors Cleanup errors handlers even more A sequel to #118587. r? `@compiler-errors`
2023-12-14Rollup merge of #118908 - Urgau:check-cfg-target-features, ↵Jubilee-428/+6
r=TaKO8Ki,GuillaumeGomez,workingjubilee Add all known `target_feature` configs to check-cfg This PR adds all the known `target_feature` from ~~`rustc_codegen_ssa`~~ `rustc_target` to the well known list of check-cfg. It does so by moving the list from `rustc_codegen_ssa` to `rustc_target` ~~`rustc_session` (I not sure about this, but some of the moved function take a `Session`)~~, then using it the `fill_well_known` function. This already proved to be useful since portable-simd had a bad cfg. cc `@nnethercote` (since we discussed it in https://github.com/rust-lang/rust/pull/118494)
2023-12-15Split `Handler::emit_diagnostic` in two.Nicholas Nethercote-1/+1
Currently, `emit_diagnostic` takes `&mut self`. This commit changes it so `emit_diagnostic` takes `self` and the new `emit_diagnostic_without_consuming` function takes `&mut self`. I find the distinction useful. The former case is much more common, and avoids a bunch of `mut` and `&mut` occurrences. We can also restrict the latter with `pub(crate)` which is nice.
2023-12-14Rollup merge of #118945 - Enselic:remove-trailing, r=compiler-errorsMatthias Krüger-2/+2
rustc_codegen_ssa: Remove trailing spaces in Display impl for CguReuse Otherwise errors will look like this: error: CGU-reuse for `cgu_invalidated_via_import-bar` is `PreLto ` but should be `PostLto ` ### Background I noticed that error messages looked wonky while investigating if https://github.com/rust-lang/rust/blob/529047cfc3f4f7b3ea5aaac054408f368d153727/compiler/rustc_codegen_ssa/src/assert_module_sources.rs#L281-L287 should not be wrapped by `sess.emit_err(...)`. Right now it looks like the error is accidentally ignored. It looks like https://github.com/rust-lang/rust/pull/100753/commits/706452eba74026c51e8d0fa30aee2497c69eafc0 might have accidentally started ignoring it (by removing the `diag.span_err()` call). I am still investigating, but regardless of the outcome we should fix the trailing whitespace.
2023-12-14rustc_codegen_ssa: Remove trailing spaces in Display impl for CguReuseMartin Nordholts-2/+2
Otherwise errors will look like this: error: CGU-reuse for `cgu_invalidated_via_import-bar` is `PreLto ` but should be `PostLto `
2023-12-14Move rustc_codegen_ssa target features to rustc_targetUrgau-428/+6
2023-12-14Address commentKai Luo-2/+5
2023-12-13fix computing the dynamic alignment of packed structs with dyn trait tailsRalf Jung-23/+39
2023-12-13Auto merge of #118534 - RalfJung:extern-type-size-of-val, r=WaffleLapkinbors-36/+53
codegen: panic when trying to compute size/align of extern type The alignment is also computed when accessing a field of extern type at non-zero offset, so we also panic in that case. Previously `size_of_val` worked because the code path there assumed that "thin pointer" means "sized". But that's not true any more with extern types. The returned size and align are just blatantly wrong, so it seems better to panic than returning wrong results. We use a non-unwinding panic since code probably does not expect size_of_val to panic.
2023-12-13Fix XCOFF metadataKai Luo-10/+11
2023-12-12reject projecting to fields whose offset we cannot computeRalf Jung-12/+7
2023-12-12codegen: panic when trying to compute size/align of extern typeRalf Jung-24/+46
2023-12-11Auto merge of #118344 - saethlin:rmeta-header-pos, r=WaffleLapkinbors-9/+9
Use a u64 for the rmeta root position Waffle noticed this in https://github.com/rust-lang/rust/pull/117301#discussion_r1405410174 We've upgraded the other file offsets to u64, and this one only costs 4 bytes per file. Also the way the truncation was being done before was extremely easy to miss, I sure missed it! It's not clear to me if not having this change effectively made the other upgrades from u32 to u64 ineffective, but we can have it now. r? `@WaffleLapkin`
2023-12-10Apply suggestions from code reviewBen Kimock-1/+1
Co-authored-by: Waffle Maybe <waffle.lapkin@gmail.com>
2023-12-10Auto merge of #118791 - saethlin:use-immediate-type, r=nikicbors-1/+1
Use immediate_backend_type when reading from a const alloc Fixes https://github.com/rust-lang/rust/issues/118047 r? `@nikic`
2023-12-10remove redundant importssurechen-1/+0
detects redundant imports that can be eliminated. for #117772 : In order to facilitate review and modification, split the checking code and removing redundant imports code into two PR.
2023-12-09Use immediate_backend_type when reading from a const allocBen Kimock-1/+1
2023-12-09Rollup merge of #118610 - krasimirgg:llvm-18-dec, r=nikicJubilee-1/+1
update target feature following LLVM API change LLVM commit https://github.com/llvm/llvm-project/commit/e81796671890b59c110f8e41adc7ca26f8484d20 renamed* the `unaligned-scalar-mem` target feature to `fast-unaligned-access`. (*) technically the commit folded two previous features into one, but there are no references to the other one in rust.
2023-12-09Auto merge of #117873 - quininer:android-emutls, r=Amanieubors-2/+36
Add emulated TLS support This is a reopen of https://github.com/rust-lang/rust/pull/96317 . many android devices still only use 128 pthread keys, so using emutls can be helpful. Currently LLVM uses emutls by default for some targets (such as android, openbsd), but rust does not use it, because `has_thread_local` is false. This commit has some changes to allow users to enable emutls: 1. add `-Zhas-thread-local` flag to specify that std uses `#[thread_local]` instead of pthread key. 2. when using emutls, decorate symbol names to find thread local symbol correctly. 3. change `-Zforce-emulated-tls` to `-Ztls-model=emulated` to explicitly specify whether to generate emutls. r? `@Amanieu`
2023-12-08Implement `async gen` blocksMichael Goulet-1/+8
2023-12-08update target feature following LLVM API changeKrasimir Georgiev-1/+1
LLVM commit https://github.com/llvm/llvm-project/commit/e81796671890b59c110f8e41adc7ca26f8484d20 renamed the `unaligned-scalar-mem` target feature to `fast-unaligned-access`.
2023-12-07Auto merge of #118568 - DianQK:no-builtins-symbols, r=pnkfelixbors-3/+15
Avoid adding builtin functions to `symbols.o` We found performance regressions in #113923. The problem seems to be that `--gc-sections` does not remove these symbols. I tested that lld removes these symbols, but ld and gold do not. I found that `used` adds symbols to `symbols.o` at https://github.com/rust-lang/rust/blob/3e202ead604be31f4c1a5798a296953d3159da7e/compiler/rustc_codegen_ssa/src/back/linker.rs#L1786-L1791. The PR removes builtin functions. Note that under LTO, ld still preserves these symbols. (lld will still remove them.) The first commit also fixes #118559. But I think the second commit also makes sense.
2023-12-07Auto merge of #118324 - RalfJung:ctfe-read-only-pointers, r=saethlinbors-1/+1
compile-time evaluation: detect writes through immutable pointers This has two motivations: - it unblocks https://github.com/rust-lang/rust/pull/116745 (and therefore takes a big step towards `const_mut_refs` stabilization), because we can now detect if the memory that we find in `const` can be interned as "immutable" - it would detect the UB that was uncovered in https://github.com/rust-lang/rust/pull/117905, which was caused by accidental stabilization of `copy` functions in `const` that can only be called with UB When UB is detected, we emit a future-compat warn-by-default lint. This is not a breaking change, so completely in line with [the const-UB RFC](https://rust-lang.github.io/rfcs/3016-const-ub.html), meaning we don't need t-lang FCP here. I made the lint immediately show up for dependencies since it is nearly impossible to even trigger this lint without `const_mut_refs` -- the accidentally stabilized `copy` functions are the only way this can happen, so the crates that popped up in #117905 are the only causes of such UB (in the code that crater covers), and the three cases of UB that we know about have all been fixed in their respective crates already. The way this is implemented is by making use of the fact that our interpreter is already generic over the notion of provenance. For CTFE we now use the new `CtfeProvenance` type which is conceptually an `AllocId` plus a boolean `immutable` flag (but packed for a more efficient representation). This means we can mark a pointer as immutable when it is created as a shared reference. The flag will be propagated to all pointers derived from this one. We can then check the immutable flag on each write to reject writes through immutable pointers. I just hope perf works out.
2023-12-07ctfe interpreter: extend provenance so that it can track whether a pointer ↵Ralf Jung-1/+1
is immutable
2023-12-07Add emulated TLS supportquininer-2/+36
Currently LLVM uses emutls by default for some targets (such as android, openbsd), but rust does not use it, because `has_thread_local` is false. This commit has some changes to allow users to enable emutls: 1. add `-Zhas-thread-local` flag to specify that std uses `#[thread_local]` instead of pthread key. 2. when using emutls, decorate symbol names to find thread local symbol correctly. 3. change `-Zforce-emulated-tls` to `-Ztls-model=emulated` to explicitly specify whether to generate emutls.
2023-12-05Consider only `#[no_mangle]` as builtin functionsDianQK-2/+3
2023-12-04Avoid adding compiler-used functions to `symbols.o`DianQK-1/+12
2023-12-04Rollup merge of #118573 - petrochenkov:pathdatakind, r=TaKO8KiTakayuki Maeda-1/+1
rustc: Harmonize `DefKind` and `DefPathData` Follow up to https://github.com/rust-lang/rust/pull/118188. `DefPathData::(ClosureExpr,ImplTrait)` are renamed to match `DefKind::(Closure,OpaqueTy)`. `DefPathData::ImplTraitAssocTy` is replaced with `DefPathData::TypeNS(kw::Empty)` because both correspond to `DefKind::AssocTy`. It's possible that introducing `(DefKind,DefPathData)::AssocOpaqueTy` instead could be a better solution, but that would be a much more invasive change. Const generic parameters introduced for effects are moved from `DefPathData::TypeNS` to `DefPathData::ValueNS`, because constants are values. `DefPathData` is no longer passed to `create_def` functions to avoid redundancy.
2023-12-04Rollup merge of #118551 - RalfJung:extern-types-bugs, r=compiler-errorsTakayuki Maeda-0/+1
more targeted errors when extern types end up in places they should not Cc https://github.com/rust-lang/rust/issues/115709 -- this does not fix that bug but it makes the panics less obscure and makes it more clear that this is a deeper issue than just a little codegen oversight. (In https://github.com/rust-lang/rust/pull/116115 we decided we'd stick to causing ICEs here for now, rather than nicer errors. We can't currently show any errors pre-mono and probably we don't want post-mono checks when this gets stabilized anyway.)
2023-12-04Rollup merge of #118540 - RalfJung:unsized-packed-offset, r=TaKO8KiTakayuki Maeda-10/+12
codegen, miri: fix computing the offset of an unsized field in a packed struct `#[repr(packed)]` strikes again. Fixes https://github.com/rust-lang/rust/issues/118537 Fixes https://github.com/rust-lang/miri/issues/3200 `@bjorn3` I assume cranelift needs the same fix.
2023-12-03Auto merge of #113730 - belovdv:jobserver-init-check, r=petrochenkovbors-1/+1
Report errors in jobserver inherited through environment variables This pr attempts to catch situations, when jobserver exists, but is not being inherited. r? `@petrochenkov`
2023-12-03rustc: Harmonize `DefKind` and `DefPathData`Vadim Petrochenkov-1/+1
`DefPathData::(ClosureExpr,ImplTrait)` are renamed to match `DefKind::(Closure,OpaqueTy)`. `DefPathData::ImplTraitAssocTy` is replaced with `DefPathData::TypeNS(kw::Empty)` because both correspond to `DefKind::AssocTy`. It's possible that introducing `(DefKind,DefPathData)::AssocOpaqueTy` could be a better solution, but that would be a much more invasive change. Const generic parameters introduced for effects are moved from `DefPathData::TypeNS` to `DefPathData::ValueNS`, because constants are values. `DefPathData` is no longer passed to `create_def` functions to avoid redundancy.
2023-12-03codegen, miri: fix computing the offset of an unsized field in a packed structRalf Jung-10/+12
2023-12-03more targeted errors when extern types end up in places they should notRalf Jung-0/+1
2023-12-02Auto merge of #118470 - nnethercote:cleanup-error-handlers, r=compiler-errorsbors-4/+4
Cleanup error handlers Mostly by making function naming more consistent. More to do after this, but this is enough for one PR. r? compiler-errors