about summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa
AgeCommit message (Collapse)AuthorLines
2024-07-07use "bootstrap" instead of "rustbuild" in comments and docsonur-ozkan-1/+1
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2024-07-03Auto merge of #126094 - petrochenkov:libsearch, r=michaelwoeristerbors-85/+94
linker: Link dylib crates by path Linkers seem to support linking dynamic libraries by path. Not sure why the previous scheme with splitting the path into a directory (passed with `-L`) and a name (passed with `-l`) was used (upd: likely due to https://github.com/rust-lang/rust/pull/126094#issuecomment-2155063414). When we split a library path `some/dir/libfoo.so` into `-L some/dir` and `-l foo` we add `some/dir` to search directories for *all* libraries looked up by the linker, not just `foo`, and `foo` is also looked up in *all* search directories not just `some/dir`. Technically we may find some unintended libraries this way. Therefore linking dylibs via a full path is both simpler and more reliable. It also makes the set of search directories more easily reproducible when we need to lookup some native library manually (like in https://github.com/rust-lang/rust/pull/123436).
2024-07-03Auto merge of #125507 - compiler-errors:type-length-limit, r=lcnrbors-1/+3
Re-implement a type-size based limit r? lcnr This PR reintroduces the type length limit added in #37789, which was accidentally made practically useless by the caching changes to `Ty::walk` in #72412, which caused the `walk` function to no longer walk over identical elements. Hitting this length limit is not fatal unless we are in codegen -- so it shouldn't affect passes like the mir inliner which creates potentially very large types (which we observed, for example, when the new trait solver compiles `itertools` in `--release` mode). This also increases the type length limit from `1048576 == 2 ** 20` to `2 ** 24`, which covers all of the code that can be reached with craterbot-check. Individual crates can increase the length limit further if desired. Perf regression is mild and I think we should accept it -- reinstating this limit is important for the new trait solver and to make sure we don't accidentally hit more type-size related regressions in the future. Fixes #125460
2024-07-02Fix spansMichael Goulet-3/+3
2024-07-02Give Instance::expect_resolve a spanMichael Goulet-0/+2
2024-07-02Rollup merge of #127230 - hattizai:patch01, r=saethlinMatthias Krüger-1/+1
chore: remove duplicate words remove duplicate words in comments to improve readability.
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-16/+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-16/+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.