about summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa/src
AgeCommit message (Collapse)AuthorLines
2024-01-03Rename some `Diagnostic` setters.Nicholas Nethercote-28/+28
`Diagnostic` has 40 methods that return `&mut Self` and could be considered setters. Four of them have a `set_` prefix. This doesn't seem necessary for a type that implements the builder pattern. This commit removes the `set_` prefixes on those four methods.
2024-01-02Address review commentsNikita Popov-7/+5
2023-12-30Update to bitflags 2 in the compilerNilstrieb-0/+1
This involves lots of breaking changes. There are two big changes that force changes. The first is that the bitflag types now don't automatically implement normal derive traits, so we need to derive them manually. Additionally, bitflags now have a hidden inner type by default, which breaks our custom derives. The bitflags docs recommend using the impl form in these cases, which I did.
2023-12-30is_coroutine -> is_coroutine_or_closureMichael Goulet-3/+3
2023-12-30Auto merge of #118705 - WaffleLapkin:codegen-atomic-exhange-untuple, r=cjgillotbors-4/+2
Change `rustc_codegen_ssa`'s `atomic_cmpxchg` interface to return a pair of values Doesn't change much, but a little nicer that way.
2023-12-28Change `rustc_codegen_ssa`'s `atomic_cmpxchg` interface to return a pair of ↵Bernd Schmidt-4/+2
values
2023-12-26Auto merge of #119258 - compiler-errors:closure-kind, r=eholkbors-1/+1
Make closures carry their own ClosureKind Right now, we use the "`movability`" field of `hir::Closure` to distinguish a closure and a coroutine. This is paired together with the `CoroutineKind`, which is located not in the `hir::Closure`, but the `hir::Body`. This is strange and redundant. This PR introduces `ClosureKind` with two variants -- `Closure` and `Coroutine`, which is put into `hir::Closure`. The `CoroutineKind` is thus removed from `hir::Body`, and `Option<Movability>` no longer needs to be a stand-in for "is this a closure or a coroutine". r? eholk
2023-12-25Only regular coroutines have movabilityMichael Goulet-1/+1
2023-12-24Remove more `Session` methods that duplicate `DiagCtxt` methods.Nicholas Nethercote-10/+11
2023-12-24Remove `Session` methods that duplicate `DiagCtxt` methods.Nicholas Nethercote-111/+111
Also add some `dcx` methods to types that wrap `TyCtxt`, for easier access.
2023-12-22Rollup merge of #119198 - compiler-errors:desugaring, r=eholkMichael Goulet-10/+26
Split coroutine desugaring kind from source What a coroutine is desugared from (gen/async gen/async) should be separate from where it comes (fn/block/closure).
2023-12-23Remove all uses of `DiagnosticBuilder::forget_guarantee()`.Nicholas Nethercote-7/+7
There are only three. It's simpler to make the type `DiagnosticBuilder<'_, ()>` from the start, no matter the level, than to change the guarantee later.
2023-12-23Improve some names.Nicholas Nethercote-4/+4
Lots of vectors of messages called `message` or `msg`. This commit pluralizes them. Note that `emit_message_default` and `emit_messages_default` both already existed, and both process a vector, so I renamed the former `emit_messages_default_inner` because it's called by the latter.
2023-12-22Split coroutine desugaring kind from sourceMichael Goulet-10/+26
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-15Separate immediate and in-memory ScalarPair representationNikita Popov-14/+8
Currently, we assume that ScalarPair is always represented using a two-element struct, both as an immediate value and when stored in memory. This currently works fairly well, but runs into problems with https://github.com/rust-lang/rust/pull/116672, where a ScalarPair involving an i128 type can no longer be represented as a two-element struct in memory. For example, the tuple `(i32, i128)` needs to be represented in-memory as `{ i32, [3 x i32], i128 }` to satisfy alignment requirement. Using `{ i32, i128 }` instead will result in the second element being stored at the wrong offset (prior to LLVM 18). Resolve this issue by no longer requiring that the immediate and in-memory type for ScalarPair are the same. The in-memory type will now look the same as for normal struct types (and will include padding filler and similar), while the immediate type stays a simple two-element struct type. This also means that booleans in immediate ScalarPair are now represented as i1 rather than i8, just like we do everywhere else. The core change here is to llvm_type (which now treats ScalarPair as a normal struct) and immediate_llvm_type (which returns the two-element struct that llvm_type used to produce). The rest is fixing things up to no longer assume these are the same. In particular, this switches places that try to get pointers to the ScalarPair elements to use byte-geps instead of struct-geps.
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