Implemented preserves_flags on powerpc by making it do
nothing. This prevents having two different ways to mark
`cr0` as clobbered. clang and gcc alias `cr0` to `cc`.
The gcc inline documentation does not state what this does
on powerpc* targets, but inspection of the source shows
it is equivalent to condition register field `cr0`, so it
should not be added.
Where supported, VSX is a 64x128b register set which encompasses
both the floating point and vector registers.
In the type tests, xvsqrtdp is used as it is the only two-argument
vsx opcode supported by all targets on llvm. If you need to copy
a vsx register, the preferred way is "xxlor xt, xa, xa".
fix 2 search graph bugs
wooooooooops, i should really run the fuzzer even when not changing the structure of the search graph as a whole :3 fixes the `ml-kem` ICE in the next-solver crater run
r? ````@BoxyUwU````
Rollup of 7 pull requests
Successful merges:
- rust-lang/rust#144266 (Supress swapping lhs and rhs in equality suggestion in extern macro )
- rust-lang/rust#147471 (Assert that non-extended temporaries and `super let` bindings have scopes)
- rust-lang/rust#147533 (Renumber return local after state transform)
- rust-lang/rust#147566 (rewrite outlives placeholder constraints to outlives static when handling opaque types)
- rust-lang/rust#147613 (Make logging filters work again by moving EnvFilter into its own layer)
- rust-lang/rust#147615 (reduce calls to attr.span() in old doc attr parsing)
- rust-lang/rust#147636 (miri subtree update)
r? `@ghost`
`@rustbot` modify labels: rollup
reduce calls to attr.span() in old doc attr parsing
r? `@oli-obk`
should be trivial, can also delegate to `@GuillaumeGomez` or `@JonathanBrouwer.`
As part of making span() return an option I want to reduce the number of places we call span in without it being known what specific attr it's for. This makes that more obvious for doc. Part of a chain of PRs that's coming.
https://github.com/rust-lang/rust/issues/131229#issuecomment-3395316064
Make logging filters work again by moving EnvFilter into its own layer
`tracing` at the time of writing has a feature (?) in its Filter implementation, so that filters like EnvFilter are consulted for status of a span or event and whether it is marked as interesting for logging. Combining a Filter with another layer through the `with_filter` combinator produces a filtered layer that enables an event unless it is statically determined that the event is uninteresting. However, if the filter is dynamic, because of filtering on span names or field values as an example, events are **always** enabled by design. There is an `event_enabled` predicate on `EnvFilter` implementation but it falls back to default and, thus, the dynamic filters are **unused**.
Previously, `RUSTC_LOG=[]` or `RUSTC_LOG=[garbage]` enables all events, even when spans do not match.
This patch re-enables span- and field-based filters. With `RUSTC_LOG=[garbage]` one should expect no events are enabled again. This will help with development greatly because we can meaningfully filter internal logs again.
Renumber return local after state transform
The current implementation of `StateTransform` renames `_0` before analyzing liveness. This is inconsistent, as a `return` terminator hardcodes a read of `_0`.
This PR proposes to perform such rename *after* analyzing the body, in fact after the whole transform. The implementation is not much more complicated.
Assert that non-extended temporaries and `super let` bindings have scopes
This PR clarifies a point of confusion in the compiler: all bodies have an outer temporary drop scope, including `static` and `const` item bodies[^1]. Whenever a temporary should be dropped in its enclosing temporary scope, it should have a temporary scope to be dropped in so that its drop can be scheduled[^2]. As such, I've updated some relevant comments and made `ScopeTree::default_temporary_scope` and `RvalueScopes::temporary_scope` panic when an enclosing temporary scope isn't found instead of allowing potential bugs where potentially-drop-sensitive temporaries are effectively given static lifetimes.
Since non-extended `super let` bindings are dropped in their block's enclosing temporary scope, this applies to them as well: the enclosing temporary scope should exist.
[^1]: See https://github.com/rust-lang/rust/blob/master/compiler/rustc_hir_analysis/src/check/region.rs#L773-L778 for non-`fn`/closure bodies. The `this.cx.var_parent = None;` enables [lifetime extension to `'static` lifetimes](https://doc.rust-lang.org/stable/reference/destructors.html#r-destructors.scope.lifetime-extension.static) and the `ScopeData::Destruction` scope ensures non-extended temporaries are dropped in the body expression's scope.
[^2]: For certain borrowed temporaries, drops that don't require running destructors may later be removed by constant promotion. That is unrelated to this PR.
Rollup of 6 pull requests
Successful merges:
- rust-lang/rust#147514 (repr_transparent_external_private_fields: normalize types during traversal)
- rust-lang/rust#147605 (Add doc links between `{integer}::from_str_radix` and `from_str`)
- rust-lang/rust#147608 (cg_llvm: Use `LLVMDIBuilderCreateGlobalVariableExpression`)
- rust-lang/rust#147623 (Clear `ChunkedBitSet` without reallocating)
- rust-lang/rust#147625 (Add a warning when running tests with the GCC backend and debug assertions are enabled)
- rust-lang/rust#147626 (Generalize configuring LLD as the default linker in bootstrap)
r? `@ghost`
`@rustbot` modify labels: rollup
Generalize configuring LLD as the default linker in bootstrap
Reopen of https://github.com/rust-lang/rust/pull/147157, because apparently bors can't deal with it for some reason.
r? ``@ghost``
Clear `ChunkedBitSet` without reallocating
There doesn't appear to be any reason to clear a ChunkedBitSet via its constructor (which allocates a new list of chunks), when we could just fill the existing allocation with `Chunk::Zeros` instead.
For comparison, the `insert_all` impl added by the same PR (rust-lang/rust#93984) does the simple thing here and just overwrites every chunk with `Chunk::Ones`.
(That fill was then made somewhat easier by rust-lang/rust#145480, which removes the chunk size from all-zero/all-one chunks.)
r? nnethercote (or compiler)
cg_llvm: Use `LLVMDIBuilderCreateGlobalVariableExpression`
- Part of rust-lang/rust#134001
- Follow-up to rust-lang/rust#146763
---
This PR dismantles the somewhat complicated `LLVMRustDIBuilderCreateStaticVariable` function, and replaces it with equivalent calls to `LLVMDIBuilderCreateGlobalVariableExpression` and `LLVMGlobalSetMetadata`.
A key difference is that the new code does not replicate the attempted downcast of `InitVal`. As far as I can tell, those downcasts were actually dead, because `llvm::ConstantInt` and `llvm::ConstantFP` are not subclasses of `llvm::GlobalVariable`. I tried replacing those code paths with fatal errors, and was unable to induce failure in any of the relevant test suites I ran.
I have also confirmed that if the calls to `create_static_variable` are commented out, debuginfo tests will fail, demonstrating some amount of relevant test coverage.
The new `DIBuilder` methods have been added via an extension trait, not as inherent methods, to avoid impeding rust-lang/rust#142897.
repr_transparent_external_private_fields: normalize types during traversal
Determining whether a type is a 1-ZST will internally do full normalization, so we better do the same when scanning for non-exhaustive types.
r? ``@lcnr``
Split overlapping_{inherent,trait}_impls
This yielded some perf improvement for me. Reduces some calls to `impl_trait_header` query. But I think the llvm optimization is more relevant.
Fix normalization overflow ICEs in monomorphization
Fixesrust-lang/rust#92004Fixesrust-lang/rust#92470Fixesrust-lang/rust#95134Fixesrust-lang/rust#105275Fixesrust-lang/rust#105937
Fixes rust-lang/rust#117696-2
Fixesrust-lang/rust#118590Fixesrust-lang/rust#122823Fixesrust-lang/rust#131342Fixesrust-lang/rust#139659
## Analysis:
The causes of these issues are similar. They contain generic recursive functions that can be instantiated with different args infinitely at monomorphization stage.
Ideally this should be caught by the [`check_recursion_limit`](c0bb3b98bb/compiler/rustc_monomorphize/src/collector.rs (L468)) function. The reality is that normalization can reach recursion limit earlier than monomorphization's check because they calculate depths in different ways.
Since normalization is called everywhere, ICEs appear in different locations.
## Fix:
If we abort on overflow with `TypingMode::PostAnalysis` in the trait solver, it would also catch these errors.
The main challenge is providing good diagnostics for them. So it's quite natural to put the check right before these normalization happening.
I first tried to check the whole MIR body's normalization and `references_error`. (As elaborate_drop handles normalization failure by [returning `ty::Error`](c0bb3b98bb/compiler/rustc_mir_transform/src/elaborate_drop.rs (L514-L519)).)
It turns out that checking all `Local`s seems sufficient.
These types are gonna be normalized anyway. So with cache, these checks shouldn't be expensive.
This fixes these ICEs for both the next and old solver, though I'm not sure the change I made to the old solver is proper. Its overflow handling looks convoluted thus I didn't try to fix it more "upstream".
`tracing` at the time of writing has a feature (?) in its Filter
implementation, so that filters like EnvFilter are consulted for status
of a span or event and whether it is marked as interesting for logging.
Combining a Filter with another layer through the `with_filter`
combinator produces a filtered layer that enables an event unless it is
statically determined that the event is uninteresting.
However, if the filter is dynamic, because of filtering on span names or
field values as an example, events are **always** enabled.
There is an `event_enabled` predicate on `EnvFilter` implementation but
it falls back to default and, thus, the dynamic filters are **unused**.
This patch re-enables span- and field-based filters.
Perform unused assignment and unused variables lints on MIR.
Rebase of https://github.com/rust-lang/rust/pull/101500
Fixes https://github.com/rust-lang/rust/issues/51003.
The first commit moves detection of uninhabited types from the current liveness pass to MIR building.
In order to keep the same level of diagnostics, I had to instrument MIR a little more:
- keep for which original local a guard local is created;
- store in the `VarBindingForm` the list of introducer places and whether this was a shorthand pattern.
I am not very proud of the handling of self-assignments. The proposed scheme is in two parts: first detect probable self-assignments, by pattern matching on MIR, and second treat them specially during dataflow analysis. I welcome ideas.
Please review carefully the changes in tests. There are many small changes to behaviour, and I'm not sure all of them are desirable.
Note that the code in `LLVMRustDIBuilderCreateStaticVariable` that tried to
downcast `InitVal` appears to have been dead, because `llvm::ConstantInt` and
`llvm::ConstantFP` are not subclasses of `llvm::GlobalVariable`.
Replace `LLVMRustContextCreate` with normal LLVM-C API calls
Since `LLVMRustContextCreate` can easily be replaced with a call to `LLVMContextCreate` and `LLVMContextSetDiscardValueNames`.
Work towards https://github.com/rust-lang/rust/issues/46437
Extract most code from `define_feedable!`
This PR extracts most of the non-trivial code from the `define_feedable!` macro (which defines the `TyCtxtFeed::$query` methods), and moves it to a helper function `query_feed_inner` written in ordinary non-macro code.
Doing so should make that code easier to read and modify, because it now gets proper IDE support and has explicit trait bounds.
---
There should be no change in compiler behaviour.
I've structured the commits so that the actual extraction part is mostly just whitespace changes, making it easier to review individually with whitespace changes hidden.