Commit Graph

1084 Commits

Author SHA1 Message Date
bors 079e544174 Auto merge of #109025 - cjgillot:refprop-dbg, r=JakobDegen
Enable MIR reference propagation by default
2023-07-14 17:32:59 +00:00
Mahdi Dibaiee e55583c4b8 refactor(rustc_middle): Substs -> GenericArg 2023-07-14 13:27:35 +01:00
Michael Woerister 457b787a52 Introduce ExtentUnord trait for collections that can safely consume UnordItems. 2023-07-14 10:10:15 +02:00
Mark Rousskov cc907f80b9 Re-format let-else per rustfmt update 2023-07-12 21:49:27 -04:00
Ralf Jung dd453a6a99 miri: protect Move() function arguments during the call 2023-07-11 21:59:01 +02:00
Camille GILLOT a5031d569e Call super for debuginfo. 2023-07-10 16:01:19 +00:00
Camille GILLOT b4c342edea Simplify visit_place. 2023-07-10 16:01:19 +00:00
Camille GILLOT 4de2d8fb66 Perform reference propagation earlier. 2023-07-10 16:01:18 +00:00
Camille GILLOT b74a144a5f Enable by default. 2023-07-10 16:01:18 +00:00
Nilstrieb 2beabbbf6f Rename `adjustment::PointerCast` and variants using it to `PointerCoercion`
It makes it sound like the `ExprKind` and `Rvalue` are supposed to represent all pointer related
casts, when in reality their just used to share a some enum variants. Make it clear there these
are only coercion to make it clear why only some pointer related "casts" are in the enum.
2023-07-07 18:17:16 +02:00
Boxy 12138b8e5e Move `TyCtxt::mk_x` to `Ty::new_x` where applicable 2023-07-05 20:27:07 +01:00
bors d5a74249c8 Auto merge of #112882 - DrMeepster:new_un_derefer, r=oli-obk
Rewrite `UnDerefer`

Currently, `UnDerefer` is used by drop elaboration to undo the effects of the `Derefer` pass. However, it just recreates the original places with derefs in the middle of the projection. Because `ProjectionElem::Deref` is intended to be removed completely in the future, this will not work forever.

This PR introduces a `deref_chain` method that returns the places behind `DerefTemp` locals in a place and rewrites the move path code to use this. In the process, `UnDerefer` was merged into `MovePathLookup`. Now that move paths use the same places as in the MIR, the other uses of `UnDerefer` no longer require it.

See #98145
cc `@ouz-a`
r? `@oli-obk`
2023-07-03 02:46:39 +00:00
DrMeepster 4fbd6d5af4 Merge `un_derefer` into `MovePathLookup` 2023-06-29 22:14:27 -07:00
bors 8aed93d912 Auto merge of #113116 - nnethercote:codegen-opts, r=oli-obk
A mish-mash of micro-optimizations

These were aimed at speeding up LLVM codegen, but ended up affecting other places as well.

r? `@bjorn3`
2023-06-30 00:35:19 +00:00
Nicholas Nethercote 7e786e81b0 Avoid cloning `LocalDecls`.
`DerefChecker` can just hold a reference instead. This avoids quite a
lot of allocations for some benchmarks.
2023-06-29 11:53:41 +10:00
bors bb95b7dcd6 Auto merge of #112307 - lcnr:operand-ref, r=compiler-errors
mir opt + codegen: handle subtyping

fixes #107205

the same issue was caused in multiple places:
- mir opts: both copy and destination propagation
- codegen: assigning operands to locals (which also propagates values)

I changed codegen to always update the type in the operands used for locals which should guard against any new occurrences of this bug going forward. I don't know how to make mir optimizations more resilient here. Hopefully the added tests will be enough to detect any trivially wrong optimizations going forward.
2023-06-28 00:41:37 +00:00
bors 6b46c996e1 Auto merge of #113105 - matthiaskrgr:rollup-rci0uym, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #112207 (Add trustzone and virtualization target features for aarch32.)
 - #112454 (Make compiletest aware of targets without dynamic linking)
 - #112628 (Allow comparing `Box`es with different allocators)
 - #112692 (Provide more context for `rustc +nightly -Zunstable-options` on stable)
 - #112972 (Make `UnwindAction::Continue` explicit in MIR dump)
 - #113020 (Add tests impl via obj unless denied)
 - #113084 (Simplify some conditions)
 - #113103 (Normalize types when applying uninhabited predicate.)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-06-27 21:31:47 +00:00
Matthias Krüger d505582ce2
Rollup merge of #113084 - WaffleLapkin:less_map_or, r=Nilstrieb
Simplify some conditions

r? `@Nilstrieb`

Some things taken out of my `is_none_or` pr.
2023-06-27 22:10:15 +02:00
Matthias Krüger 526326e10d
Rollup merge of #113079 - Zalathar:as-operand-id, r=oli-obk
Use `CoverageKind::as_operand_id` instead of manually reimplementing it

These two pieces of code are functionally equivalent to the `CoverageKind::as_operand_id` method that already exists, and is already used elsewhere in this file.

This slightly reduces the amount of code that manually pattern-matches on `CoverageKind`.
2023-06-27 17:48:46 +02:00
bors f42f19b6d3 Auto merge of #113078 - saethlin:mention-the-function, r=RalfJung
Mention the panic function in CheckAlignment

Per https://github.com/rust-lang/rust/pull/112599#discussion_r1242333935
r? `@RalfJung`
2023-06-27 09:43:37 +00:00
Maybe Waffle ef05533c39 Simplify some conditions 2023-06-27 07:40:47 +00:00
bors b5e51db16d Auto merge of #112938 - compiler-errors:clause-3, r=oli-obk
Migrate `TyCtxt::predicates_of` and `ParamEnv::caller_bounds` to `Clause`

The last big change in the series.

I will follow-up with additional filed issues once this PR lands:
- [ ] Investigate making `TypeFoldable<TyCtxt<'tcx>> for ty::Clause<'tcx>` implementation less weird: 2efe091705/compiler/rustc_middle/src/ty/structural_impls.rs (L672)
- [ ] Clean up the elaborator since it should only be emitting child clauses, not predicates
- [ ] Rename identifiers like `pred` and `predicates` to `clause` if they're actually clauses around the codebase
- [ ] Validate that all of the `ToPredicate` impls are acutally still needed, or prune them if they're not

r? `@ghost` until the other branch lands
2023-06-27 03:14:45 +00:00
Zalathar fbb2079a24 Use `CoverageKind::as_operand_id` instead of manually reimplementing it 2023-06-27 12:51:42 +10:00
Ben Kimock cdaac8799b Mention the panic function in CheckAlignment 2023-06-26 22:20:41 -04:00
bors b9ad9b78a2 Auto merge of #112693 - ericmarkmartin:use-more-placeref, r=spastorino
Use PlaceRef abstractions more often

Associated issue: https://github.com/rust-lang/rust/issues/80647

r? `@spastorino`
2023-06-27 00:34:49 +00:00
Michael Goulet fbdef58414 Migrate predicates_of and caller_bounds to Clause 2023-06-26 23:12:03 +00:00
Eric Mark Martin c07c10d1e4 use PlaceRef abstractions more consistently 2023-06-25 20:38:01 -04:00
Michael Goulet 46a650f4e0 Migrate item_bounds to ty::Clause 2023-06-22 18:34:23 +00:00
bors 38b44eb233 Auto merge of #112834 - oli-obk:mir_opts_considered_unsound, r=cjgillot
Disable two mir opts that are known to be unsound

closes #112460 (does not fix the underlying issue)

r? `@cjgillot`
2023-06-21 10:53:30 +00:00
Oli Scherer c409f05636 Disable two mir opts that are known to be unsound 2023-06-21 07:41:09 +00:00
Nilstrieb 82e6a16e33
Rollup merge of #112844 - Vanille-N:unique, r=RalfJung
Add retag in MIR transform: `Adt` for `Unique` may contain a reference

Following #112662 , `may_contain_reference` in `rustc_mir_transform::add_retag` underapproximates too much the types that require retagging.

r? ``@RalfJung``
2023-06-21 07:37:03 +02:00
Nilstrieb a98c14f3a9
Rollup merge of #112772 - compiler-errors:clauses-1, r=lcnr
Add a fully fledged `Clause` type, rename old `Clause` to `ClauseKind`

Does two basic things before I put up a more delicate set of PRs (along the lines of #112714, but hopefully much cleaner) that migrate existing usages of `ty::Predicate` to `ty::Clause` (`predicates_of`/`item_bounds`/`ParamEnv::caller_bounds`).

1. Rename `Clause` to `ClauseKind`, so it's parallel with `PredicateKind`.
2. Add a new `Clause` type which is parallel to `Predicate`.
    * This type exposes `Clause::kind(self) -> Binder<'tcx, ClauseKind<'tcx>>` which is parallel to `Predicate::kind` 😸

The new `Clause` type essentially acts as a newtype wrapper around `Predicate` that asserts that it is specifically a `PredicateKind::Clause`. Turns out from experimentation[^1] that this is not negative performance-wise, which is wonderful, since this a much simpler design than something that requires encoding the discriminant into the alignment bits of a predicate kind, or something else like that...

r? ``@lcnr`` or ``@oli-obk``

[^1]: https://github.com/rust-lang/rust/pull/112714#issuecomment-1595653910
2023-06-21 07:37:01 +02:00
Nilstrieb 34c8e53d7a
Rollup merge of #112759 - cjgillot:closure-names, r=oli-obk
Make closure_saved_names_of_captured_variables a query.

As we will start removing debuginfo during MIR optimizations, we need to keep them somewhere.
2023-06-21 07:37:01 +02:00
Neven Villani 74aad5ce56
`Adt` for `Unique` may contain a reference 2023-06-20 16:30:44 +02:00
Ziru Niu 8fb4c41f35 merge `BorrowKind::Unique` into `BorrowKind::Mut` 2023-06-20 20:55:31 +08:00
Michael Goulet 31d1fbf8d2
Rollup merge of #112232 - fee1-dead-contrib:match-eq-const-msg, r=b-naber
Better error for non const `PartialEq` call generated by `match`

Resolves #90237
2023-06-19 17:53:33 -07:00
Camille GILLOT 3a1edd8212 Store generator field names in GeneratorLayout. 2023-06-19 16:50:52 +00:00
Michael Goulet fca56a8d2c s/Clause/ClauseKind 2023-06-19 14:57:42 +00:00
Scott McMurray 39788e07ba Promote unchecked_add/sub/mul/shl/shr to mir::BinOp 2023-06-19 01:47:03 -07:00
lcnr 46973c9c8a add FIXME's for a later refactoring 2023-06-19 09:16:26 +02:00
lcnr 0589cd0f0a mir opt: fix subtype handling 2023-06-19 09:06:42 +02:00
lcnr be33ad8848 fix types in shim building 2023-06-19 09:06:32 +02:00
bors 677710eaf0 Auto merge of #112638 - lqd:rpo, r=cjgillot
Switch the BB CFG cache from postorder to RPO

The `BasicBlocks` CFG cache is interesting:
- it stores a postorder, but `traversal::postorder` doesn't use it
- `traversal::reverse_postorder` does traverse the postorder cache backwards
- we do more RPO traversals than postorder traversals (around 20x on the perf.rlo benchmarks IIRC) but it's not cached
- a couple places here and there were manually reversing the non-cached postorder traversal

This PR switches the order of the cache, and makes a bit more use of it. This is a tiny win locally, but it's also for consistency and aesthetics.

r? `@ghost`
2023-06-18 12:45:41 +00:00
Deadbeef 89c24af133 Better error for non const `PartialEq` call generated by `match` 2023-06-18 05:24:38 +00:00
bors 0c2c243342 Auto merge of #112599 - saethlin:cleaner-panics, r=thomcc
Launch a non-unwinding panic for misaligned pointer deref

This panic already never unwinds, but that's only because it always hits the unwind guard that's created by our `UnwindAction::Terminate`. Hitting the unwind guard generates a huge double-panic backtrace. Now we generate a normal-looking panic message when this check is hit.

r? `@thomcc`
2023-06-18 01:58:51 +00:00
bors 670a0edaa9 Auto merge of #112716 - compiler-errors:rollup-h77daia, r=compiler-errors
Rollup of 7 pull requests

Successful merges:

 - #111074 (Relax implicit `T: Sized` bounds on `BufReader<T>`, `BufWriter<T>` and `LineWriter<T>`)
 - #112226 (std: available_parallelism using native netbsd api first)
 - #112474 (Support 128-bit enum variant in debuginfo codegen)
 - #112662 (`#[lang_item]` for `core::ptr::Unique`)
 - #112665 (Make assumption functions in new solver take `Binder<'tcx, Clause<'tcx>>`)
 - #112684 (Disable alignment checks on i686-pc-windows-msvc)
 - #112706 (Add `SyntaxContext::is_root`)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-06-16 21:14:24 +00:00
Ben Kimock c153f3a356 Ignore the always part of #[inline(always)] in MIR inlining 2023-06-16 11:36:02 -04:00
Wesley Wiser 4ef316f397
Update compiler/rustc_mir_transform/src/check_alignment.rs 2023-06-16 09:55:23 -04:00
Ben Kimock 7a2490eba3 Launch a non-unwinding panic for misaligned pointer deref 2023-06-16 09:20:33 -04:00
Ben Kimock c54672e25f Disable alignment checks on i686-pc-windows-msvc 2023-06-16 09:06:12 -04:00