about summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa/src
AgeCommit message (Collapse)AuthorLines
2024-07-02Rollup merge of #127168 - DianQK:cast-size, r=workingjubileeMatthias Krüger-6/+24
Use the aligned size for alloca at args/ret when the pass mode is cast Fixes #75839. Fixes #121028. The `load` and `store` instructions in LLVM access the aligned size. For example, `load { i64, i32 }` accesses 16 bytes on x86_64: https://alive2.llvm.org/ce/z/n8CHAp. BTW, this example is expected to be optimized to immediate UB by Alive2: https://rust.godbolt.org/z/b7xK7hv1c and https://alive2.llvm.org/ce/z/vZDtZH. r? compiler
2024-07-02Rollup merge of #127136 - compiler-errors:coroutine-closure-env-shim, r=oli-obkMatthias Krüger-1/+1
Fix `FnMut::call_mut`/`Fn::call` shim for async closures that capture references I adjusted async closures to be able to implement `Fn` and `FnMut` *even if* they capture references, as long as those references did not need to borrow data from the closure captures themselves. See #125259. However, when I did this, I didn't actually relax an assertion in the `build_construct_coroutine_by_move_shim` shim code, which builds the `Fn`/`FnMut`/`FnOnce` implementations for async closures. Therefore, if we actually tried to *call* `FnMut`/`Fn` on async closures, it would ICE. This PR adjusts this assertion to ensure that we only capture immutable references in closures if they implement `Fn`/`FnMut`. It also adds a bunch of tests and makes more of the async-closure tests into `build-pass` since we often care about these tests actually generating the right closure shims and stuff. I think it might be excessive to *always* use build-pass here, but 🤷 it's not that big of a deal. Fixes #127019 Fixes #127012 r? oli-obk
2024-07-02linker: Link dylib crates by pathVadim Petrochenkov-85/+94
2024-07-02chore: remove duplicate wordshattizai-1/+1
2024-07-02Use the aligned size for alloca at ret when the pass mode is cast.DianQK-5/+23
2024-07-02Use the aligned size for alloca at args when the pass mode is cast.DianQK-1/+1
The `load` and `store` instructions in LLVM access the aligned size.
2024-07-01linker: Bail out of rpath logic early if the target doesn't support rpathVadim Petrochenkov-10/+4
2024-07-01linker: Refactor interface for passing arguments to linkerVadim Petrochenkov-373/+314
2024-06-29Fix FnMut/Fn shim for coroutine-closures that capture referencesMichael Goulet-1/+1
2024-06-29Rollup merge of #123237 - bjorn3:debuginfo_refactor, r=compiler-errorsMatthias Krüger-75/+40
Various rustc_codegen_ssa cleanups
2024-06-28Rollup merge of #124741 - nebulark:patchable-function-entries-pr, ↵Matthias Krüger-2/+78
r=estebank,workingjubilee patchable-function-entry: Add unstable compiler flag and attribute Tracking issue: #123115 Add the -Z patchable-function-entry compiler flag and the #[patchable_function_entry(prefix_nops = m, entry_nops = n)] attribute. Rebased and adjusted the canditate implementation to match changes in the RFC.
2024-06-27Updated diagnostic messagesFlorian Schmiderer-16/+36
2024-06-27Rollup merge of #126721 - Zalathar:nested-cov-attr, r=oli-obkJacob Pratt-17/+0
coverage: Make `#[coverage(..)]` apply recursively to nested functions This PR makes the (currently-unstable) `#[coverage(off)]` and `#[coverage(on)]` attributes apply recursively to all nested functions/closures, instead of just the function they are directly attached to. Those attributes can now also be applied to modules and to impl/impl-trait blocks, where they have no direct effect, but will be inherited by all enclosed functions/closures/methods that don't override the inherited value. --- Fixes #126625.
2024-06-26coverage: Detach `#[coverage(..)]` from codegen attribute handlingZalathar-17/+0
2024-06-25Updated code for changes to RFC, added additional error handling, addedFlorian Schmiderer-15/+47
tests
2024-06-25Support `#[patchable_function_entries]`Matthew Maurer-1/+25
See [RFC](https://github.com/maurer/rust-rfcs/blob/patchable-function-entry/text/0000-patchable-function-entry.md) (yet to be numbered) TODO before submission: * Needs an RFC * Improve error reporting for malformed attributes
2024-06-25Rollup merge of #126943 - Urgau:dedup-all, r=petrochenkovMatthias Krüger-5/+2
De-duplicate all consecutive native libs regardless of their options Address https://github.com/rust-lang/rust/pull/126913#issuecomment-2188184011 by no longer de-duplicating based on the "options" but by only looking at the generated link args, as to avoid consecutive libs that originated from different native-lib with different options (like `raw-dylib` on Windows) but isn't relevant for `--print=native-static-libs`. r? ``@petrochenkov``
2024-06-25De-duplicate all consecutive native libs regardless of their optionsUrgau-5/+2
2024-06-24Rollup merge of #126682 - Zalathar:coverage-attr, r=lcnrMichael Goulet-14/+4
coverage: Overhaul validation of the `#[coverage(..)]` attribute This PR makes sweeping changes to how the (currently-unstable) coverage attribute is validated: - Multiple coverage attributes on the same item/expression are now treated as an error. - The attribute must always be `#[coverage(off)]` or `#[coverage(on)]`, and the error messages for this are more consistent. - A trailing comma is still allowed after off/on, since that's part of the normal attribute syntax. - Some places that silently ignored a coverage attribute now produce an error instead. - These cases were all clearly bugs. - Some places that ignored a coverage attribute (with a warning) now produce an error instead. - These were originally added as lints, but I don't think it makes much sense to knowingly allow new attributes to be used in meaningless places. - Some of these errors might soon disappear, if it's easy to extend recursive coverage attributes to things like modules and impl blocks. --- One of the goals of this PR is to lay a more solid foundation for making the coverage attribute recursive, so that it applies to all nested functions/closures instead of just the one it is directly attached to. Fixes #126658. This PR incorporates #126659, which adds more tests for validation of the coverage attribute. `@rustbot` label +A-code-coverage
2024-06-24Rollup merge of #124712 - Enselic:deprecate-inline-threshold, r=pnkfelixMichael Goulet-2/+0
Deprecate no-op codegen option `-Cinline-threshold=...` This deprecates `-Cinline-threshold` since using it has no effect. This has been the case since the new LLVM pass manager started being used, more than 2 years ago. Recommend using `-Cllvm-args=--inline-threshold=...` instead. Closes #89742 which is E-help-wanted.
2024-06-24coverage: Tighten validation of `#[coverage(off)]` and `#[coverage(on)]`Zalathar-14/+4
2024-06-21Fix doc commentbjorn3-2/+2
2024-06-21Remove type_i1 and type_struct from cg_ssabjorn3-2/+0
They are not representable by Cranelift
2024-06-21Remove check_overflow method from MiscMethodsbjorn3-2/+1
It can be retrieved from the Session too.
2024-06-21Move all intrinsic handling code in codegen_call_terminators togetherbjorn3-25/+19
2024-06-21Dedup some intrinsic handling code for caller_locationbjorn3-25/+12
2024-06-21Remove const_bitcast from ConstMethodsbjorn3-1/+0
2024-06-21Remove PrintBackendInfo traitbjorn3-22/+2
It is only implemented for a single type. Directly passing this type is simpler and avoids overhead from indirect calls.
2024-06-21Move vcall_visibility_metadata optimization hint out of a debuginfo ↵bjorn3-0/+8
generation method
2024-06-20More GVN for PtrMetadataScott McMurray-1/+3
`PtrMetadata` doesn't care about `*const`/`*mut`/`&`/`&mut`, so GVN away those casts in its argument. This includes updating MIR to allow calling PtrMetadata on references too, not just raw pointers. That means that `[T]::len` can be just `_0 = PtrMetadata(_1)`, for example. # Conflicts: # tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-abort.mir # tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-unwind.mir
2024-06-20Rollup merge of #126717 - nnethercote:rustfmt-use-pre-cleanups, r=jieyouxuMatthias Krüger-0/+1
Clean up some comments near `use` declarations #125443 will reformat all `use` declarations in the repository. There are a few edge cases involving comments on `use` declarations that require care. This PR cleans up some clumsy comment cases, taking us a step closer to #125443 being able to merge. r? ``@lqd``
2024-06-20Add blank lines after module-level `//!` comments.Nicholas Nethercote-0/+1
Most modules have such a blank line, but some don't. Inserting the blank line makes it clearer that the `//!` comments are describing the entire module, rather than the `use` declaration(s) that immediately follows.
2024-06-19`bug!` more uses of these in runtime stuffScott McMurray-5/+6
2024-06-19Rollup merge of #126594 - zetanumbers:fix-cross-crate-async-drop-glue, r=oli-obkLeón Orell Valerian Liehr-10/+13
Make async drop code more consistent with regular drop code Fixes #126573 Relates to #126482 r? ````@petrochenkov````
2024-06-18Use a dedicated type instead of a reference for the diagnostic contextOli Scherer-15/+22
This paves the way for tracking more state (e.g. error tainting) in the diagnostic context handle
2024-06-18Apply suggestions from oli-obk's reviewDaria Sukhonina-10/+4
Co-authored-by: Oli Scherer <github35764891676564198441@oli-obk.de>
2024-06-18Make async drop code more consistent with regular drop codeDaria Sukhonina-5/+14
Fixes #126573
2024-06-16Rename InstanceDef -> InstanceKindMichael Goulet-12/+12
2024-06-14Only compute vtable information during codegenMichael Goulet-2/+1
2024-06-14rustc_codegen_ssa: Remove unused ModuleConfig::inline_thresholdMartin Nordholts-2/+0
2024-06-12Use `tidy` to sort crate attributes for all compiler crates.Nicholas Nethercote-3/+5
We already do this for a number of crates, e.g. `rustc_middle`, `rustc_span`, `rustc_metadata`, `rustc_span`, `rustc_errors`. For the ones we don't, in many cases the attributes are a mess. - There is no consistency about order of attribute kinds (e.g. `allow`/`deny`/`feature`). - Within attribute kind groups (e.g. the `feature` attributes), sometimes the order is alphabetical, and sometimes there is no particular order. - Sometimes the attributes of a particular kind aren't even grouped all together, e.g. there might be a `feature`, then an `allow`, then another `feature`. This commit extends the existing sorting to all compiler crates, increasing consistency. If any new attribute line is added there is now only one place it can go -- no need for arbitrary decisions. Exceptions: - `rustc_log`, `rustc_next_trait_solver` and `rustc_type_ir_macros`, because they have no crate attributes. - `rustc_codegen_gcc`, because it's quasi-external to rustc (e.g. it's ignored in `rustfmt.toml`).
2024-06-10ScalarInt: size mismatches are a bug, do not delay the panicRalf Jung-1/+1
2024-06-08offset_of: allow (unstably) taking the offset of slice tail fieldsRalf Jung-1/+4
2024-06-06Revert "Rollup merge of #124976 - petrochenkov:usedcrates, r=oli-obk"Rémy Rakic-3/+3
This reverts commit eda4a35f365535af72118118a3597edf5a13c12d, reversing changes made to eb6b35b5bcb3c2a594cb29cd478aeb2893f49d30.
2024-06-05Add `Ty` to `mir::Const::Ty`Boxy-1/+1
2024-06-05Add `Ty` to `ConstKind::Value`Boxy-35/+39
2024-06-05Basic removal of `Ty` from places (boring)Boxy-1/+2
2024-06-05Rollup merge of #125861 - name1e5s:fix/rpath_null_panic, r=michaelwoeristerMatthias Krüger-0/+21
rustc_codegen_ssa: fix `get_rpath_relative_to_output` panic when lib only contains file name <!-- If this PR is related to an unstable feature or an otherwise tracked effort, please link to the relevant tracking issue here. If you don't know of a related tracking issue or there are none, feel free to ignore this. This PR will get automatically assigned to a reviewer. In case you would like a specific user to review your work, you can assign it to them by using r​? <reviewer name> --> When compiles program with `-C rpath=yes` but with no output filename specified, or with filename ONLY, we will get an ICE for now. Fix it by treat empty `output` path in `get_rpath_relative_to_output` as current dir. Before this patch: ```bash rustc -C prefer_dynamic=yes -C rpath=yes -O h.rs # ICE, no output filename specified rustc -o hello -C prefer_dynamic=yes -C rpath=yes -O h.rs # ICE, output filename has no path rustc -o ./hello -C prefer_dynamic=yes -C rpath=yes -O h.rs # Works ``` All those examples work after the patch. Close #119571. Close #125785.
2024-06-05Rollup merge of #125920 - bjorn3:allow_static_mut_linkage_def, r=UrgauJubilee-12/+13
Allow static mut definitions with #[linkage] Unlike static declarations with #[linkage], for definitions rustc doesn't rewrite it to add an extra indirection. This was accidentally disallowed in https://github.com/rust-lang/rust/pull/125046. cc https://github.com/rust-lang/rust/pull/125800#issuecomment-2143776298
2024-06-04Rollup merge of #125750 - compiler-errors:expect, r=lcnr许杰友 Jieyou Xu (Joe)-1/+1
Align `Term` methods with `GenericArg` methods, add `Term::expect_*` * `Term::ty` -> `Term::as_type`. * `Term::ct` -> `Term::as_const`. * Adds `Term::expect_type` and `Term::expect_const`, and uses them in favor of `.ty().unwrap()`, etc. I could also shorten these to `as_ty` and then do `GenericArg::as_ty` as well, but I do think the `as_` is important to signal that this is a conversion method, and not a getter, like `Const::ty` is. r? types