about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2025-01-11[mir-opt] simplify `Repeat`s that don't actually repeat the operandScott McMurray-11/+30
2025-01-11Make MIR cleanup for functions with impossible predicates into a real MIR passMichael Goulet-46/+59
2025-01-11Remove a bunch of diagnostic stashing that doesn't do anythingMichael Goulet-63/+14
2025-01-11Suggest typos when trait path expression is typodMichael Goulet-2/+49
2025-01-11Remove allocations from case-insensitive comparison to keywordsMark Rousskov-3/+5
2025-01-11Rollup merge of #135314 - compiler-errors:eagerly-mono-closures, r=wesleywiserMatthias Krüger-0/+44
Eagerly collect mono items for non-generic closures This allows users to use `-Zprint-mono-items=eager` to eagerly monomorphize closures and coroutine bodies, in case they want to inspect the LLVM or ASM for those items. `-Zprint-mono-items`, which used to be called `-Zprint-trans-items`, was originally added in https://github.com/rust-lang/rust/pull/30900: > Eager mode is meant to be used in conjunction with incremental compilation > where a stable set of translation items is more important than a minimal > one. Thus, eager mode will instantiate drop-glue for every drop-able type > in the crate, even of no drop call for that type exists (yet). It will > also instantiate default implementations of trait methods, something that > otherwise is only done on demand. Although it remains an unstable option, its purpose has somewhat expanded since then, and as far as I can tell it's generally useful for cases when you want to monomorphize as many items as possible, even if they're unreachable. Specifically, it's useful for debugging since you can look at the codegen'd body of a function, since we don't emit items that are not reachable in monomorphization. And even more specifically, it would be very to monomorphize the coroutine body of an async fn, since those you can't easily call those without a runtime. This PR enables this usecase since we now monomorphize `DefKind::Closure`.
2025-01-11Rollup merge of #135205 - lqd:bitsets, r=Mark-SimulacrumMatthias Krüger-362/+379
Rename `BitSet` to `DenseBitSet` r? `@Mark-Simulacrum` as you requested this in https://github.com/rust-lang/rust/pull/134438#discussion_r1890659739 after such a confusion. This PR renames `BitSet` to `DenseBitSet` to make it less obvious as the go-to solution for bitmap needs, as well as make its representation (and positives/negatives) clearer. It also expands the comments there to hopefully make it clearer when it's not a good fit, with some alternative bitsets types. (This migrates the subtrees cg_gcc and clippy to use the new name in separate commits, for easier review by their respective owners, but they can obvs be squashed)
2025-01-11Rollup merge of #134776 - estebank:vanilla-ice, r=lcnrMatthias Krüger-51/+76
Avoid ICE: Account for `for<'a>` types when checking for non-structural type in constant as pattern When we encounter a constant in a pattern, we check if it is non-structural. If so, we check if the type implements `PartialEq`, but for types with escaping bound vars the check would be incorrect as is, so we break early. This is ok because these types would be filtered anyways. Slight tweak to output to remove unnecessary context as a drive-by. Fix #134764.
2025-01-11Rollup merge of #134030 - folkertdev:min-fn-align, r=workingjubileeMatthias Krüger-3/+34
add `-Zmin-function-alignment` tracking issue: https://github.com/rust-lang/rust/issues/82232 This PR adds the `-Zmin-function-alignment=<align>` flag, that specifies a minimum alignment for all* functions. ### Motivation This feature is requested by RfL [here](https://github.com/rust-lang/rust/issues/128830): > i.e. the equivalents of `-fmin-function-alignment` ([GCC](https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html#index-fmin-function-alignment_003dn), Clang does not support it) / `-falign-functions` ([GCC](https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html#index-falign-functions), [Clang](https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang1-falign-functions)). > > For the Linux kernel, the behavior wanted is that of GCC's `-fmin-function-alignment` and Clang's `-falign-functions`, i.e. align all functions, including cold functions. > > There is [`feature(fn_align)`](https://github.com/rust-lang/rust/issues/82232), but we need to do it globally. ### Behavior The `fn_align` feature does not have an RFC. It was decided at the time that it would not be necessary, but maybe we feel differently about that now? In any case, here are the semantics of this flag: - `-Zmin-function-alignment=<align>` specifies the minimum alignment of all* functions - the `#[repr(align(<align>))]` attribute can be used to override the function alignment on a per-function basis: when `-Zmin-function-alignment` is specified, the attribute's value is only used when it is higher than the value passed to `-Zmin-function-alignment`. - the target may decide to use a higher value (e.g. on x86_64 the minimum that LLVM generates is 16) - The highest supported alignment in rust is `2^29`: I checked a bunch of targets, and they all emit the `.p2align 29` directive for targets that align functions at all (some GPU stuff does not have function alignment). *: Only with `build-std` would the minimum alignment also be applied to `std` functions. --- cc `@ojeda` r? `@workingjubilee` you were active on the tracking issue
2025-01-11collect diag suggestions instead of pushing into vector repeatedlyYotam Ofek-12/+9
2025-01-11improve clunky grammar in borrowck diagnosticYotam Ofek-1/+1
2025-01-11fix `it's` -> `its` in doc commentYotam Ofek-1/+1
2025-01-11migrate `rustc_codegen_gcc` to the `DenseBitSet` nameRémy Rakic-5/+5
2025-01-11document the use-cases of `DenseBitSet` a bit moreRémy Rakic-1/+7
2025-01-11rename `BitSet` to `DenseBitSet`Rémy Rakic-356/+367
This should make it clearer that this bitset is dense, with the advantages and disadvantages that it entails.
2025-01-11Auto merge of #135274 - saethlin:array-repeats, r=compiler-errorsbors-0/+30
Add an InstSimplify for repetitive array expressions I noticed in https://github.com/rust-lang/rust/pull/135068#issuecomment-2569955426 that GVN's implementation of this same transform was quite profitable on the deep-vector benchmark. But of course GVN doesn't run in unoptimized builds, so this is my attempt to write a version of this transform that benefits the deep-vector case and is fast enough to run in InstSimplify. The benchmark suite indicates that this is effective.
2025-01-11Minor simplificationspore-1/+1
Apply eta-reduction on map to simplify code and make the style more consistent
2025-01-11Auto merge of #135258 - oli-obk:push-ktzskvxuwnlt, r=saethlinbors-7/+21
Use llvm.memset.p0i8.* to initialize all same-bytes arrays Similar to #43488 debug builds can now handle `0x0101_u16` and other multi-byte scalars that have all the same bytes (instead of special casing just `0`)
2025-01-11review comments and make test `run-rustfix`Esteban Küber-74/+64
2025-01-11On unused assign lint, detect `mut arg: &Ty` meant to be `arg: &mut Ty`Esteban Küber-5/+98
``` error: value assigned to `object` is never read --> $DIR/mut-arg-of-borrowed-type-meant-to-be-arg-of-mut-borrow.rs:11:5 | LL | object = &object2; | ^^^^^^ | note: the lint level is defined here --> $DIR/mut-arg-of-borrowed-type-meant-to-be-arg-of-mut-borrow.rs:1:9 | LL | #![deny(unused_assignments, unused_variables)] | ^^^^^^^^^^^^^^^^^^ help: you might have meant to mutate the pointed at value being passed in, instead of changing the reference in the local binding | LL ~ fn change_object2(object: &mut Object) { LL | let object2 = Object; LL ~ *object = object2; | ``` This might be the first thing someone tries to write to mutate the value *behind* an argument, trying to avoid an E0308.
2025-01-11On E0308, detect `mut arg: &Ty` meant to be `arg: &mut Ty`Esteban Küber-0/+105
``` error[E0308]: mismatched types --> $DIR/mut-arg-of-borrowed-type-meant-to-be-arg-of-mut-borrow.rs:6:14 | LL | fn change_object(mut object: &Object) { | ------- expected due to this parameter type LL | let object2 = Object; LL | object = object2; | ^^^^^^^ expected `&Object`, found `Object` | help: you might have meant to mutate the pointed at value being passed in, instead of changing the reference in the local binding | LL ~ fn change_object(object: &mut Object) { LL | let object2 = Object; LL ~ *object = object2; | ``` This might be the first thing someone tries to write to mutate the value *behind* an argument. We avoid suggesting `object = &object2;`, as that is less likely to be what was intended.
2025-01-11review commentsEsteban Küber-57/+67
Replace tuple with struct and remove unnecessary early return.
2025-01-11Avoid unnecessary note when type has escaping boundsEsteban Küber-3/+9
2025-01-11Avoid duplicated noteEsteban Küber-6/+8
2025-01-11Account for `for<'a>` types when checking for non-structural type in ↵Esteban Küber-3/+10
constant as pattern When we encounter a constant in a pattern, we check if it is non-structural. If so, we check if the type implements `PartialEq`, but for types with escaping bound vars the check would be incorrect as is, so we break early. This is ok because these types would be filtered anyways. Fix #134764.
2025-01-10add `-Zmin-function-alignment`Folkert de Vries-3/+34
2025-01-10mir_build: check annotated functions w/out callersDavid Wood-45/+110
2025-01-10clarify `target_feature` + forced inliningDavid Wood-7/+9
2025-01-10don't collect `#[rustc_force_inline]` in eager modeDavid Wood-4/+6
2025-01-10inline: move should inline checkDavid Wood-5/+5
2025-01-10validator: move force inline checkDavid Wood-23/+10
2025-01-10inline: remove unnecessary promoted checkDavid Wood-4/+0
2025-01-10inline: re-introduce some callee body checksDavid Wood-2/+29
2025-01-10inline: force inlining shimsDavid Wood-12/+18
2025-01-10codegen_attrs: force inlining takes precedenceDavid Wood-28/+33
2025-01-10mir_transform: implement forced inliningDavid Wood-670/+1138
Adds `#[rustc_force_inline]` which is similar to always inlining but reports an error if the inlining was not possible, and which always attempts to inline annotated items, regardless of optimisation levels. It can only be applied to free functions to guarantee that the MIR inliner will be able to resolve calls.
2025-01-10Use llvm.memset.p0i8.* to initialize all same-bytes arraysOli Scherer-5/+9
2025-01-10Auto merge of #135328 - bjorn3:sync_cg_clif-2025-01-10, r=bjorn3bors-320/+93
Subtree sync for rustc_codegen_cranelift This has a couple of changes that will conflict with https://github.com/rust-lang/rust/pull/134338. r? `@ghost` `@rustbot` label +A-codegen +A-cranelift +T-compiler
2025-01-10Auto merge of #135327 - jhpratt:rollup-5uyir52, r=jhprattbors-245/+311
Rollup of 7 pull requests Successful merges: - #132607 (Used pthread name functions returning result for FreeBSD and DragonFly) - #134693 (proc_macro: Use `ToTokens` trait in `quote` macro) - #134732 (Unify conditional-const error reporting with non-const error reporting) - #135083 (Do not ICE when encountering predicates from other items in method error reporting) - #135251 (Only treat plain literal patterns as short) - #135320 (Fix typo in `#[coroutine]` gating error) - #135321 (remove more redundant into() conversions) r? `@ghost` `@rustbot` modify labels: rollup
2025-01-10Respect --sysroot for rustc -vV and -Cpasses=listbjorn3-14/+20
This is necessary when the specified codegen backend is in a custom sysroot.
2025-01-10fix ZST handling for Windows ABIs on MSVC targetRalf Jung-33/+78
2025-01-10Stable Hash: Ignore all HirIds that just identify the node itselfOli Scherer-2/+20
2025-01-10Merge commit 'e39eacd2d415803ef82de3b6a314e4f2d0fbc4dc' into ↵bjorn3-320/+93
sync_cg_clif-2025-01-10
2025-01-10Fix cycle error only occurring with -Zdump-mirOli Scherer-9/+15
2025-01-10Rollup merge of #135321 - matthiaskrgr:out_of_into, r=lqdJacob Pratt-5/+4
remove more redundant into() conversions
2025-01-10Rollup merge of #135320 - camelid:coroutines-typo, r=lqdJacob Pratt-1/+1
Fix typo in `#[coroutine]` gating error
2025-01-10Rollup merge of #135083 - compiler-errors:invalid-predicate-source, r=camelidJacob Pratt-3/+7
Do not ICE when encountering predicates from other items in method error reporting See the comments I left in the code and the test file. Fixes https://github.com/rust-lang/rust/issues/124350
2025-01-10Rollup merge of #134732 - ↵Jacob Pratt-236/+299
compiler-errors:unify-conditional-const-error-reporting, r=RalfJung Unify conditional-const error reporting with non-const error reporting This PR unifies the error reporting between `ConditionallyConstCall` and `FnCallNonConst` so that the former will refer to syntactical sugar like operators by their sugared name, rather than calling all operators "methods". We achieve this by making the "non-const" part of the error message generic over the "non" part so we can plug in "conditionally" instead. This should ensure that as we constify traits in the standard library, we don't regress error messages for things like `==`. r? fmease or reassign
2025-01-10Auto merge of #135273 - dianne:argument-patterns-are-not-boring, r=lqdbors-13/+0
Remove special-casing for argument patterns in MIR typeck (attempt to fix perf regression of #133858) See [my comment](https://github.com/rust-lang/rust/pull/133858#issuecomment-2579029618) on #133858 for more information. This is just a guess as to what went wrong, and I haven't been able to get the profiler running locally, so I'll need a perf run to make sure this actually helps. There's one test's stderr that suffers a bit, but this was just papering over the issue anyway. Making region errors point to the correct constraints in the presence of invariance/contravariance is a broader problem; the current way it's handled is mostly based on guesswork, luck, and hoping it works out. Properly handling that (somehow) would improve the test's stderr without the hack that this PR reverts.
2025-01-10Pull element init into a reusable closureOli Scherer-14/+21