]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoOn ARM, use relocation_model to detect whether r9 should be reserved
Amanieu d'Antras [Thu, 17 Feb 2022 14:16:52 +0000 (14:16 +0000)]
On ARM, use relocation_model to detect whether r9 should be reserved

The previous approach of checking for the reserve-r9 target feature
didn't actually work because LLVM only sets this feature very late when
initializing the per-function subtarget.

2 years agoMove ty::print methods to Drop-based scope guards
Mark Rousskov [Wed, 16 Feb 2022 18:04:48 +0000 (13:04 -0500)]
Move ty::print methods to Drop-based scope guards

2 years agoOverhaul `Const`.
Nicholas Nethercote [Wed, 2 Feb 2022 03:24:45 +0000 (14:24 +1100)]
Overhaul `Const`.

Specifically, rename the `Const` struct as `ConstS` and re-introduce `Const` as
this:
```
pub struct Const<'tcx>(&'tcx Interned<ConstS>);
```
This now matches `Ty` and `Predicate` more closely, including using
pointer-based `eq` and `hash`.

Notable changes:
- `mk_const` now takes a `ConstS`.
- `Const` was copy, despite being 48 bytes. Now `ConstS` is not, so need a
  we need separate arena for it, because we can't use the `Dropless` one any
  more.
- Many `&'tcx Const<'tcx>`/`&Const<'tcx>` to `Const<'tcx>` changes
- Many `ct.ty` to `ct.ty()` and `ct.val` to `ct.val()` changes.
- Lots of tedious sigil fiddling.

2 years agoOverhaul `RegionKind` and `Region`.
Nicholas Nethercote [Fri, 28 Jan 2022 00:25:15 +0000 (11:25 +1100)]
Overhaul `RegionKind` and `Region`.

Specifically, change `Region` from this:
```
pub type Region<'tcx> = &'tcx RegionKind;
```
to this:
```
pub struct Region<'tcx>(&'tcx Interned<RegionKind>);
```

This now matches `Ty` and `Predicate` more closely.

Things to note
- Regions have always been interned, but we haven't been using pointer-based
  `Eq` and `Hash`. This is now happening.
- I chose to impl `Deref` for `Region` because it makes pattern matching a lot
  nicer, and `Region` can be viewed as just a smart wrapper for `RegionKind`.
- Various methods are moved from `RegionKind` to `Region`.
- There is a lot of tedious sigil changes.
- A couple of types like `HighlightBuilder`, `RegionHighlightMode` now have a
  `'tcx` lifetime because they hold a `Ty<'tcx>`, so they can call `mk_region`.
- A couple of test outputs change slightly, I'm not sure why, but the new
  outputs are a little better.

2 years agoOverhaul `TyS` and `Ty`.
Nicholas Nethercote [Tue, 25 Jan 2022 03:13:38 +0000 (14:13 +1100)]
Overhaul `TyS` and `Ty`.

Specifically, change `Ty` from this:
```
pub type Ty<'tcx> = &'tcx TyS<'tcx>;
```
to this
```
pub struct Ty<'tcx>(Interned<'tcx, TyS<'tcx>>);
```
There are two benefits to this.
- It's now a first class type, so we can define methods on it. This
  means we can move a lot of methods away from `TyS`, leaving `TyS` as a
  barely-used type, which is appropriate given that it's not meant to
  be used directly.
- The uniqueness requirement is now explicit, via the `Interned` type.
  E.g. the pointer-based `Eq` and `Hash` comes from `Interned`, rather
  than via `TyS`, which wasn't obvious at all.

Much of this commit is boring churn. The interesting changes are in
these files:
- compiler/rustc_middle/src/arena.rs
- compiler/rustc_middle/src/mir/visit.rs
- compiler/rustc_middle/src/ty/context.rs
- compiler/rustc_middle/src/ty/mod.rs

Specifically:
- Most mentions of `TyS` are removed. It's very much a dumb struct now;
  `Ty` has all the smarts.
- `TyS` now has `crate` visibility instead of `pub`.
- `TyS::make_for_test` is removed in favour of the static `BOOL_TY`,
  which just works better with the new structure.
- The `Eq`/`Ord`/`Hash` impls are removed from `TyS`. `Interned`s impls
  of `Eq`/`Hash` now suffice. `Ord` is now partly on `Interned`
  (pointer-based, for the `Equal` case) and partly on `TyS`
  (contents-based, for the other cases).
- There are many tedious sigil adjustments, i.e. adding or removing `*`
  or `&`. They seem to be unavoidable.

2 years agoUnconditionally update symbols
bjorn3 [Thu, 10 Feb 2022 17:27:18 +0000 (18:27 +0100)]
Unconditionally update symbols

All paths to an ArchiveBuilder::build call update_symbols first.

2 years agoMake FnAbiError Copy.
Camille GILLOT [Tue, 1 Feb 2022 17:44:45 +0000 (18:44 +0100)]
Make FnAbiError Copy.

2 years agoEnsure that queries only return Copy types.
Camille GILLOT [Mon, 31 Jan 2022 18:55:34 +0000 (19:55 +0100)]
Ensure that queries only return Copy types.

2 years agoUse an `indexmap` to avoid sorting `LocalDefId`s
pierwill [Thu, 6 Jan 2022 19:27:59 +0000 (13:27 -0600)]
Use an `indexmap` to avoid sorting `LocalDefId`s

Update `indexmap` to 1.8.0.

Bless test

2 years agoremove `is_noop`
lcnr [Wed, 19 Jan 2022 09:33:23 +0000 (10:33 +0100)]
remove `is_noop`

2 years agoPass target_features set instead of has_feature closure
bjorn3 [Mon, 10 Jan 2022 14:48:05 +0000 (15:48 +0100)]
Pass target_features set instead of has_feature closure

This avoids unnecessary monomorphizations in codegen backends

2 years agoUse Symbol for target features in asm handling
bjorn3 [Mon, 10 Jan 2022 14:32:45 +0000 (15:32 +0100)]
Use Symbol for target features in asm handling

This saves a couple of Symbol::intern calls

2 years agoAuto merge of #92816 - tmiasko:rm-llvm-asm, r=Amanieu
bors [Mon, 17 Jan 2022 09:40:29 +0000 (09:40 +0000)]
Auto merge of #92816 - tmiasko:rm-llvm-asm, r=Amanieu

Remove deprecated LLVM-style inline assembly

The `llvm_asm!` was deprecated back in #87590 1.56.0, with intention to remove
it once `asm!` was stabilized, which already happened in #91728 1.59.0. Now it
is time to remove `llvm_asm!` to avoid continued maintenance cost.

Closes #70173.
Closes #92794.
Closes #87612.
Closes #82065.

cc `@rust-lang/wg-inline-asm`

r? `@Amanieu`

2 years agoinitial revert
Ellen [Wed, 12 Jan 2022 03:19:52 +0000 (03:19 +0000)]
initial revert

2 years agoRemove deprecated LLVM-style inline assembly
Tomasz Miąsko [Wed, 12 Jan 2022 00:00:00 +0000 (00:00 +0000)]
Remove deprecated LLVM-style inline assembly

2 years agoStore a `Symbol` instead of an `Ident` in `VariantDef`/`FieldDef`
Aaron Hill [Mon, 3 Jan 2022 03:37:05 +0000 (22:37 -0500)]
Store a `Symbol` instead of an `Ident` in `VariantDef`/`FieldDef`

The field is also renamed from `ident` to `name. In most cases,
we don't actually need the `Span`. A new `ident` method is added
to `VariantDef` and `FieldDef`, which constructs the full `Ident`
using `tcx.def_ident_span()`. This method is used in the cases
where we actually need an `Ident`.

This makes incremental compilation properly track changes
to the `Span`, without all of the invalidations caused by storing
a `Span` directly via an `Ident`.

2 years agoRollup merge of #90102 - nbdd0121:box3, r=jonas-schievink
Matthias Krüger [Mon, 3 Jan 2022 13:44:15 +0000 (14:44 +0100)]
Rollup merge of #90102 - nbdd0121:box3, r=jonas-schievink

Remove `NullOp::Box`

Follow up of #89030 and MCP rust-lang/compiler-team#460.

~1 month later nothing seems to be broken, apart from a small regression that #89332 (1aac85bb716c09304b313d69d30d74fe7e8e1a8e) shows could be regained by remvoing the diverging path, so it shall be safe to continue and remove `NullOp::Box` completely.

r? `@jonas-schievink`
`@rustbot` label T-compiler

2 years agoMerge commit '40b00f4200fbdeefd11815398cb46394b8cb0a5e' into sync_cg_clif-2021-12-30
bjorn3 [Thu, 30 Dec 2021 13:53:41 +0000 (14:53 +0100)]
Merge commit '40b00f4200fbdeefd11815398cb46394b8cb0a5e' into sync_cg_clif-2021-12-30

2 years agoMerge commit '97e504549371d7640cf011d266e3c17394fdddac' into sync_cg_clif-2021-12-20
bjorn3 [Mon, 20 Dec 2021 17:56:35 +0000 (18:56 +0100)]
Merge commit '97e504549371d7640cf011d266e3c17394fdddac' into sync_cg_clif-2021-12-20

2 years agoAuto merge of #91957 - nnethercote:rm-SymbolStr, r=oli-obk
bors [Sun, 19 Dec 2021 09:31:37 +0000 (09:31 +0000)]
Auto merge of #91957 - nnethercote:rm-SymbolStr, r=oli-obk

Remove `SymbolStr`

This was originally proposed in https://github.com/rust-lang/rust/pull/74554#discussion_r466203544. As well as removing the icky `SymbolStr` type, it allows the removal of a lot of `&` and `*` occurrences.

Best reviewed one commit at a time.

r? `@oli-obk`

2 years agoRemove unnecessary sigils around `Symbol::as_str()` calls.
Nicholas Nethercote [Wed, 15 Dec 2021 03:39:23 +0000 (14:39 +1100)]
Remove unnecessary sigils around `Symbol::as_str()` calls.

2 years agoRemove `SymbolStr`.
Nicholas Nethercote [Tue, 14 Dec 2021 21:32:21 +0000 (08:32 +1100)]
Remove `SymbolStr`.

By changing `as_str()` to take `&self` instead of `self`, we can just
return `&str`. We're still lying about lifetimes, but it's a smaller lie
than before, where `SymbolStr` contained a (fake) `&'static str`!

2 years agoRollup merge of #91868 - tmiasko:llvm-time-trace-out, r=oli-obk
Matthias Krüger [Wed, 15 Dec 2021 00:28:06 +0000 (01:28 +0100)]
Rollup merge of #91868 - tmiasko:llvm-time-trace-out, r=oli-obk

Use `OutputFilenames` to generate output file for `-Zllvm-time-trace`

The resulting profile will include the crate name and will be stored in
the `--out-dir` directory.

This implementation makes it convenient to use LLVM time trace together
with cargo, in the contrast to the previous implementation which would
overwrite profiles or store them in `.cargo/registry/..`.

2 years agoRemove invalid doc links.
Amanieu d'Antras [Mon, 13 Dec 2021 20:40:17 +0000 (20:40 +0000)]
Remove invalid doc links.

2 years agoUse `OutputFilenames` to generate output file for `-Zllvm-time-trace`
Tomasz Miąsko [Mon, 13 Dec 2021 00:00:00 +0000 (00:00 +0000)]
Use `OutputFilenames` to generate output file for `-Zllvm-time-trace`

The resulting profile will include the crate name and will be stored in
the `--out-dir` directory.

This implementation makes it convenient to use LLVM time trace together
with cargo, in the contrast to the previous implementation which would
overwrite profiles or store them in `.cargo/registry/..`.

2 years agoUse IntoIterator for array impl everywhere.
Mara Bos [Fri, 3 Sep 2021 10:36:33 +0000 (12:36 +0200)]
Use IntoIterator for array impl everywhere.

2 years agocg_cranelift: check may_unwind flag instead of cleanup
cynecx [Sat, 4 Sep 2021 20:14:09 +0000 (22:14 +0200)]
cg_cranelift: check may_unwind flag instead of cleanup

2 years agoLLVM codgen support for unwinding inline assembly
cynecx [Sat, 4 Sep 2021 17:25:09 +0000 (19:25 +0200)]
LLVM codgen support for unwinding inline assembly

2 years agofix sparc64 ABI for aggregates with floating point members
Petr Sumbera [Wed, 1 Dec 2021 09:03:45 +0000 (10:03 +0100)]
fix sparc64 ABI for aggregates with floating point members

2 years agoRemove NullOp::Box
Gary Guo [Sun, 26 Sep 2021 16:38:05 +0000 (17:38 +0100)]
Remove NullOp::Box

2 years agoMake hash_result an Option.
Camille GILLOT [Sat, 16 Oct 2021 20:31:48 +0000 (22:31 +0200)]
Make hash_result an Option.

2 years agoRemove alloc::prelude
Amanieu d'Antras [Thu, 14 Oct 2021 23:41:31 +0000 (01:41 +0200)]
Remove alloc::prelude

As per the libs team decision in #58935.

Closes #58935

2 years agoAdd const_eval_select intrinsic
Deadbeef [Tue, 12 Oct 2021 05:06:37 +0000 (05:06 +0000)]
Add const_eval_select intrinsic

2 years agoAuto merge of #89619 - michaelwoerister:incr-vtables, r=nagisa
bors [Fri, 8 Oct 2021 09:04:06 +0000 (09:04 +0000)]
Auto merge of #89619 - michaelwoerister:incr-vtables, r=nagisa

Turn vtable_allocation() into a query

This PR removes the untracked vtable-const-allocation cache from the `tcx` and turns the `vtable_allocation()` method into a query.

The change is pretty straightforward and should be backportable without too much effort.

Fixes https://github.com/rust-lang/rust/issues/89598.

2 years agoTurn tcx.vtable_allocation() into a query.
Michael Woerister [Thu, 7 Oct 2021 09:29:01 +0000 (11:29 +0200)]
Turn tcx.vtable_allocation() into a query.

2 years agoMove rustc_middle::middle::cstore to rustc_session.
Camille GILLOT [Sat, 14 Nov 2020 02:02:03 +0000 (03:02 +0100)]
Move rustc_middle::middle::cstore to rustc_session.

2 years agoUpdate compiler/rustc_codegen_cranelift/scripts/filter_profile.rs
Camille Gillot [Tue, 28 Sep 2021 18:49:57 +0000 (20:49 +0200)]
Update compiler/rustc_codegen_cranelift/scripts/filter_profile.rs

Co-authored-by: bjorn3 <bjorn3@users.noreply.github.com>
2 years agoMove EncodedMetadata to rustc_metadata.
Camille GILLOT [Fri, 24 Sep 2021 16:15:36 +0000 (18:15 +0200)]
Move EncodedMetadata to rustc_metadata.

2 years agoMove encode_metadata out of CrateStore.
Camille GILLOT [Sat, 14 Nov 2020 00:59:00 +0000 (01:59 +0100)]
Move encode_metadata out of CrateStore.

2 years agoAuto merge of #89092 - bjorn3:sync_cg_clif-2021-09-19, r=bjorn3
bors [Sun, 26 Sep 2021 23:31:01 +0000 (23:31 +0000)]
Auto merge of #89092 - bjorn3:sync_cg_clif-2021-09-19, r=bjorn3

Sync rustc_codegen_cranelift

Nothing exciting this time. Mostly internal refactorings.

r? `@ghost`

`@rustbot` label +A-codegen +A-cranelift +T-compiler

2 years agoIntroduce `Rvalue::ShallowInitBox`
Gary Guo [Mon, 6 Sep 2021 17:33:23 +0000 (18:33 +0100)]
Introduce `Rvalue::ShallowInitBox`

2 years agoMigrate to 2021
Mark Rousskov [Sun, 19 Sep 2021 16:49:55 +0000 (12:49 -0400)]
Migrate to 2021

2 years agoAdjust to SourceType::InTree in several places
Mark Rousskov [Sun, 19 Sep 2021 14:36:17 +0000 (10:36 -0400)]
Adjust to SourceType::InTree in several places

These were left over in migrations to subtrees, which should generally be treated
as-if it was local.

Also fixes a warning caused by this change.

2 years agoMerge commit '61667dedf55e3e5aa584f7ae2bd0471336b92ce9' into sync_cg_clif-2021-09-19
bjorn3 [Sun, 19 Sep 2021 11:56:58 +0000 (13:56 +0200)]
Merge commit '61667dedf55e3e5aa584f7ae2bd0471336b92ce9' into sync_cg_clif-2021-09-19

2 years agoQuerify `fn_abi_of_{fn_ptr,instance}`.
Eduard-Mihai Burtescu [Wed, 1 Sep 2021 21:29:15 +0000 (00:29 +0300)]
Querify `fn_abi_of_{fn_ptr,instance}`.

2 years agoty::layout: replicate `layout_of` setup for `fn_abi_of_{fn_ptr,instance}`.
Eduard-Mihai Burtescu [Wed, 1 Sep 2021 21:09:34 +0000 (00:09 +0300)]
ty::layout: replicate `layout_of` setup for `fn_abi_of_{fn_ptr,instance}`.

2 years agoty::layout: intern `FnAbi`s as `&'tcx`.
Eduard-Mihai Burtescu [Thu, 26 Aug 2021 18:58:34 +0000 (21:58 +0300)]
ty::layout: intern `FnAbi`s as `&'tcx`.

2 years agoAuto merge of #88839 - nbdd0121:alignof, r=nagisa
bors [Sun, 12 Sep 2021 23:49:24 +0000 (23:49 +0000)]
Auto merge of #88839 - nbdd0121:alignof, r=nagisa

Introduce NullOp::AlignOf

This PR introduces `Rvalue::NullaryOp(NullOp::AlignOf, ty)`, which will be lowered from `align_of`, similar to `size_of` lowering to `Rvalue::NullaryOp(NullOp::SizeOf, ty)`.

The changes are originally part of #88700 but since it's not dependent on other changes and could have performance impact on its own, it's separated into its own PR.

2 years agoIntroduce NullOp::AlignOf
Gary Guo [Tue, 7 Sep 2021 15:06:07 +0000 (16:06 +0100)]
Introduce NullOp::AlignOf

2 years agoMake `abi::Abi` `Copy` and remove a *lot* of refs
Andreas Liljeqvist [Sun, 29 Aug 2021 09:06:55 +0000 (11:06 +0200)]
Make `abi::Abi` `Copy` and remove a *lot* of refs

fix

fix

Remove more refs and clones

fix

more

fix

2 years agoMove the dataflow framework to its own crate.
Camille GILLOT [Tue, 5 Jan 2021 18:53:07 +0000 (19:53 +0100)]
Move the dataflow framework to its own crate.

2 years agoMove monomorphize code to its own crate.
Camille GILLOT [Sat, 2 Jan 2021 13:42:15 +0000 (14:42 +0100)]
Move monomorphize code to its own crate.

2 years agoAuto merge of #88499 - eddyb:layout-off, r=nagisa
bors [Sun, 5 Sep 2021 16:14:41 +0000 (16:14 +0000)]
Auto merge of #88499 - eddyb:layout-off, r=nagisa

Provide `layout_of` automatically (given tcx + param_env + error handling).

After #88337, there's no longer any uses of `LayoutOf` within `rustc_target` itself, so I realized I could move the trait to `rustc_middle::ty::layout` and redesign it a bit.

This is similar to #88338 (and supersedes it), but at no ergonomic loss, since there's no funky `C: LayoutOf<Ty = Ty>` -> `Ty: TyAbiInterface<C>` generic `impl` chain, and each `LayoutOf` still corresponds to one `impl` (of `LayoutOfHelpers`) for the specific context.

After this PR, this is what's needed to get `trait LayoutOf` (with the `layout_of` method) implemented on some context type:
* `TyCtxt`, via `HasTyCtxt`
* `ParamEnv`, via `HasParamEnv`
* a way to transform `LayoutError`s into the desired error type
  * an error type of `!` can be paired with having `cx.layout_of(...)` return `TyAndLayout` *without* `Result<...>` around it, such as used by codegen
  * this is done through a new `LayoutOfHelpers` trait (and so is specifying the type of `cx.layout_of(...)`)

When going through this path (and not bypassing it with a manual `impl` of `LayoutOf`), the end result is that only the error case can be customized, the query itself and the success paths are guaranteed to be uniform.

(**EDIT**: just noticed that because of the supertrait relationship, you cannot actually implement `LayoutOf` yourself, the blanket `impl` fully covers all possible context types that could ever implement it)

Part of the motivation for this shape of API is that I've been working on querifying `FnAbi::of_*`, and what I want/need to introduce for that looks a lot like the setup in this PR - in particular, it's harder to express the `FnAbi` methods in `rustc_target`, since they're much more tied to `rustc` concepts.

r? `@nagisa` cc `@oli-obk` `@bjorn3`

2 years agoAuto merge of #88559 - bjorn3:archive_logic_dedup, r=cjgillot
bors [Sun, 5 Sep 2021 04:37:12 +0000 (04:37 +0000)]
Auto merge of #88559 - bjorn3:archive_logic_dedup, r=cjgillot

Move add_rlib and add_native_library to cg_ssa

This deduplicates logic between codegen backends.

cc `@antoyo` and `@khyperia` for cg_gcc and rust-gpu.

2 years agoAuto merge of #88363 - michaelwoerister:remapped-diagnostics, r=estebank
bors [Fri, 3 Sep 2021 00:23:10 +0000 (00:23 +0000)]
Auto merge of #88363 - michaelwoerister:remapped-diagnostics, r=estebank

Path remapping: Make behavior of diagnostics output dependent on presence of --remap-path-prefix.

This PR fixes a regression (#87745) with `--remap-path-prefix` where the flag stopped causing diagnostic messages to be remapped as well. The regression was introduced in https://github.com/rust-lang/rust/pull/83813 where we erroneously assumed that remapping of diagnostic messages was not desired anymore (because #70642 partially undid that functionality with nobody objecting).

The issue is fixed by making `--remap-path-prefix` remap diagnostic messages again, including for paths that have been remapped in upstream crates (e.g. the standard library). This means that "sysroot-localization" (implemented in #70642) is also disabled if `rustc` is invoked with `--remap-path-prefix`. The assumption is that once someone starts explicitly remapping paths they also don't want paths to their local Rust installation in their build output.

In the future we might want to give more fine-grained control over this behavior via compiler flags (see https://github.com/rust-lang/rfcs/pull/3127 for a related RFC). For now this PR is intended as a regression fix.

This PR is an alternative to https://github.com/rust-lang/rust/pull/88191, which makes diagnostic messages be remapped unconditionally. That approach, however, would effectively revert #70642.

Fixes https://github.com/rust-lang/rust/issues/87745.

cc `@cbeuw`
r? `@ghost`

2 years agoUse in_incr_comp_dir_sess in cg_clif
bjorn3 [Mon, 30 Aug 2021 13:06:56 +0000 (15:06 +0200)]
Use in_incr_comp_dir_sess in cg_clif

2 years agoty::layout: split `LayoutOf` into required and (blanket) provided halves.
Eduard-Mihai Burtescu [Mon, 30 Aug 2021 17:37:36 +0000 (20:37 +0300)]
ty::layout: split `LayoutOf` into required and (blanket) provided halves.

2 years agoty::layout: implement `layout_of` automatically as a default method.
Eduard-Mihai Burtescu [Mon, 30 Aug 2021 15:01:58 +0000 (18:01 +0300)]
ty::layout: implement `layout_of` automatically as a default method.

2 years agorustc_target: move `LayoutOf` to `ty::layout`.
Eduard-Mihai Burtescu [Mon, 30 Aug 2021 14:38:27 +0000 (17:38 +0300)]
rustc_target: move `LayoutOf` to `ty::layout`.

2 years agoMove add_rlib and add_native_library to cg_ssa
bjorn3 [Wed, 1 Sep 2021 12:38:37 +0000 (14:38 +0200)]
Move add_rlib and add_native_library to cg_ssa

This deduplicates logic between codegen backends

2 years agorustc_target: `TyAndLayout::field` should never error.
Eduard-Mihai Burtescu [Wed, 25 Aug 2021 15:05:10 +0000 (18:05 +0300)]
rustc_target: `TyAndLayout::field` should never error.

2 years agorustc_target: add lifetime parameter to `LayoutOf`.
Eduard-Mihai Burtescu [Wed, 25 Aug 2021 11:51:22 +0000 (14:51 +0300)]
rustc_target: add lifetime parameter to `LayoutOf`.

2 years agoPath remapping: Make behavior of diagnostics output dependent on presence of --remap...
Michael Woerister [Thu, 26 Aug 2021 10:46:01 +0000 (12:46 +0200)]
Path remapping: Make behavior of diagnostics output dependent on presence of --remap-path-prefix.

2 years agomake unevaluated const substs optional
lcnr [Mon, 15 Mar 2021 23:05:45 +0000 (00:05 +0100)]
make unevaluated const substs optional

2 years agoAuto merge of #88135 - crlf0710:trait_upcasting_part_3, r=nikomatsakis
bors [Sat, 21 Aug 2021 21:14:07 +0000 (21:14 +0000)]
Auto merge of #88135 - crlf0710:trait_upcasting_part_3, r=nikomatsakis

Trait upcasting coercion (part 3)

By using separate candidates for each possible choice, this fixes type-checking issues in previous commits.

r? `@nikomatsakis`

2 years agoremove box_syntax uses from cranelift and tools
Marcel Hellwig [Fri, 6 Aug 2021 15:14:27 +0000 (17:14 +0200)]
remove box_syntax uses from cranelift and tools

2 years agoFold `vtable_trait_upcasting_coercion_new_vptr_slot` logic into obligation processing.
Charles Lew [Wed, 18 Aug 2021 04:45:18 +0000 (12:45 +0800)]
Fold `vtable_trait_upcasting_coercion_new_vptr_slot` logic into obligation processing.

2 years agoUpdate rustc_codegen_cratelift for working_dir change
Aaron Hill [Thu, 12 Aug 2021 21:46:58 +0000 (16:46 -0500)]
Update rustc_codegen_cratelift for working_dir change

2 years agoImplement `black_box` using intrinsic
Gary Guo [Tue, 10 Aug 2021 10:50:33 +0000 (11:50 +0100)]
Implement `black_box` using intrinsic

The new implementation allows some `memcpy`s to be optimized away,
so the uninit value in ui/sanitize/memory.rs is constructed directly
onto the return place. Therefore the sanitizer now says that the
value is allocated by `main` rather than `random`.

2 years agoMerge commit '05677b6bd6c938ed760835d9b1f6514992654ae3' into sync_cg_clif-2021-08-06
bjorn3 [Fri, 6 Aug 2021 14:26:56 +0000 (16:26 +0200)]
Merge commit '05677b6bd6c938ed760835d9b1f6514992654ae3' into sync_cg_clif-2021-08-06

2 years agoAuto merge of #87515 - crlf0710:trait_upcasting_part2, r=bjorn3
bors [Tue, 3 Aug 2021 16:58:56 +0000 (16:58 +0000)]
Auto merge of #87515 - crlf0710:trait_upcasting_part2, r=bjorn3

Trait upcasting coercion (part2)

This is the second part of trait upcasting coercion implementation.

Currently this is blocked on #86264 .

The third part might be implemented using unsafety checking

r? `@bjorn3`

2 years agoImplement pointer casting.
Charles Lew [Sat, 31 Jul 2021 14:46:23 +0000 (22:46 +0800)]
Implement pointer casting.

2 years agorfc3052: Remove authors field from Cargo manifests
Jade [Tue, 27 Jul 2021 23:38:13 +0000 (16:38 -0700)]
rfc3052: Remove authors field from Cargo manifests

Since RFC 3052 soft deprecated the authors field anyway, hiding it from
crates.io, docs.rs, and making Cargo not add it by default, and it is
not generally up to date/useful information, we should remove it from
crates in this repo.

2 years agoRollup merge of #87092 - ricobbe:fix-raw-dylib-multiple-definitions, r=petrochenkov
Yuki Okushi [Sun, 18 Jul 2021 05:21:56 +0000 (14:21 +0900)]
Rollup merge of #87092 - ricobbe:fix-raw-dylib-multiple-definitions, r=petrochenkov

Remove nondeterminism in multiple-definitions test

Compare all fields in `DllImport` when sorting to avoid nondeterminism in the error for multiple inconsistent definitions of an extern function.  Restore the multiple-definitions test.

Resolves #87084.

2 years agoConsider all fields when comparing DllImports, to remove nondetermininsm in multiple...
Richard Cobbe [Mon, 12 Jul 2021 19:46:27 +0000 (12:46 -0700)]
Consider all fields when comparing DllImports, to remove nondetermininsm in multiple-definitions test

2 years agofix cranelift
Ralf Jung [Mon, 12 Jul 2021 22:41:10 +0000 (00:41 +0200)]
fix cranelift

2 years agoUse cranelift's `Type::int` instead of doing the match myself
Scott McMurray [Tue, 1 Jun 2021 13:19:49 +0000 (06:19 -0700)]
Use cranelift's `Type::int` instead of doing the match myself

<https://docs.rs/cranelift-codegen/0.74.0/cranelift_codegen/ir/types/struct.Type.html#method.int>

2 years agoPR Feedback: Don't put SSA-only types in `CValue`s
Scott McMurray [Mon, 31 May 2021 17:26:08 +0000 (10:26 -0700)]
PR Feedback: Don't put SSA-only types in `CValue`s

2 years agoImplement the raw_eq intrinsic in codegen_cranelift
Scott McMurray [Mon, 31 May 2021 01:04:07 +0000 (18:04 -0700)]
Implement the raw_eq intrinsic in codegen_cranelift

2 years agoMerge commit '3a31c6d8272c14388a34622193baf553636fe470' into sync_cg_clif-2021-07-07
bjorn3 [Wed, 7 Jul 2021 09:14:20 +0000 (11:14 +0200)]
Merge commit '3a31c6d8272c14388a34622193baf553636fe470' into sync_cg_clif-2021-07-07

2 years agoDon't pass local_crate_name to link_binary separately
bjorn3 [Tue, 6 Jul 2021 15:49:23 +0000 (17:49 +0200)]
Don't pass local_crate_name to link_binary separately

It is already part of CodegenResults

2 years agoMove LinkerInfo into CrateInfo
bjorn3 [Tue, 6 Jul 2021 13:31:38 +0000 (15:31 +0200)]
Move LinkerInfo into CrateInfo

2 years agoRemove LibSource
bjorn3 [Mon, 7 Jun 2021 10:18:28 +0000 (12:18 +0200)]
Remove LibSource

The information is stored in used_crate_source too anyway

3 years agoMake vtable_allocation always succeed
Smitty [Sat, 3 Jul 2021 15:14:19 +0000 (11:14 -0400)]
Make vtable_allocation always succeed

3 years agofix sess error
Smitty [Tue, 29 Jun 2021 23:17:14 +0000 (19:17 -0400)]
fix sess error

This passed x.py check locally, not sure why it wasn't rebased right...

3 years agoSupport allocation failures when interperting MIR
Smitty [Sat, 12 Jun 2021 23:49:48 +0000 (19:49 -0400)]
Support allocation failures when interperting MIR

Note that this breaks Miri.

Closes #79601

3 years agoAuto merge of #86475 - crlf0710:miri_vtable_refactor, r=bjorn3
bors [Tue, 29 Jun 2021 15:52:21 +0000 (15:52 +0000)]
Auto merge of #86475 - crlf0710:miri_vtable_refactor, r=bjorn3

Change vtable memory representation to use tcx allocated allocations.

This fixes https://github.com/rust-lang/rust/issues/86324. However i suspect there's more to change before it can land.

r? `@bjorn3`
cc `@rust-lang/miri`

3 years agoUpdate other codegens to use tcx managed vtable allocations.
Charles Lew [Sun, 20 Jun 2021 09:43:25 +0000 (17:43 +0800)]
Update other codegens to use tcx managed vtable allocations.

3 years agoAuto merge of #85909 - cjgillot:alloc-kind-query, r=Aaron1011
bors [Mon, 28 Jun 2021 01:20:01 +0000 (01:20 +0000)]
Auto merge of #85909 - cjgillot:alloc-kind-query, r=Aaron1011

Make allocator_kind a query.

Part of #85153

r? `@Aaron1011`

3 years agoAuto merge of #85640 - bjorn3:custom_ice_hook, r=jackh726
bors [Fri, 25 Jun 2021 04:06:32 +0000 (04:06 +0000)]
Auto merge of #85640 - bjorn3:custom_ice_hook, r=jackh726

Allow changing the bug report url for the ice hook

cc https://github.com/bjorn3/rustc_codegen_cranelift/issues/1174

3 years agoMake allocator_kind a query.
Camille GILLOT [Tue, 11 May 2021 20:05:54 +0000 (22:05 +0200)]
Make allocator_kind a query.

3 years agoAuto merge of #86291 - crlf0710:trait_vtbl_refactor, r=bjorn3
bors [Wed, 16 Jun 2021 07:20:27 +0000 (07:20 +0000)]
Auto merge of #86291 - crlf0710:trait_vtbl_refactor, r=bjorn3

Refactor vtable codegen

This refactor the codegen of vtables of miri interpreter, llvm, cranelift codegen backends.

This is preparation for the implementation of trait upcasting feature. cc #65991

Note that aside from code reorganization, there's an internal behavior change here that now InstanceDef::Virtual's index now include the three metadata slots, and now the first method is with index 3.

cc  `@RalfJung` `@bjorn3`

3 years agoUse the now available implementation of `IntoIterator` for arrays
LeSeulArtichaut [Mon, 14 Jun 2021 21:40:09 +0000 (23:40 +0200)]
Use the now available implementation of `IntoIterator` for arrays

3 years agoRefactor to make interpreter and codegen backend neutral to vtable internal represent...
Charles Lew [Mon, 14 Jun 2021 10:02:53 +0000 (18:02 +0800)]
Refactor to make interpreter and codegen backend neutral to vtable internal representation.

3 years agoAuto merge of #85910 - cjgillot:no-meta-version, r=Aaron1011
bors [Thu, 10 Jun 2021 00:39:25 +0000 (00:39 +0000)]
Auto merge of #85910 - cjgillot:no-meta-version, r=Aaron1011

Drop metadata_encoding_version.

Part of #85153

r? `@Aaron1011`

3 years agoRollup merge of #86016 - luqmana:infer-linker-flavor, r=petrochenkov
Yuki Okushi [Mon, 7 Jun 2021 06:21:03 +0000 (15:21 +0900)]
Rollup merge of #86016 - luqmana:infer-linker-flavor, r=petrochenkov

Unify duplicate linker_and_flavor methods in rustc_codegen_{cranelift,ssa}.

The two methods were exactly the same so this removes the cranelift copy. This will help make sure both they don't get out of sync.

3 years agoAuto merge of #85810 - bjorn3:further_driver_cleanup, r=varkor
bors [Mon, 7 Jun 2021 02:30:24 +0000 (02:30 +0000)]
Auto merge of #85810 - bjorn3:further_driver_cleanup, r=varkor

Driver improvements

This PR contains a couple of cleanups for the driver and a few small improvements for the custom codegen backend interface. It also implements `--version` and `-Cpasses=list` support for custom codegen backends.

3 years agoUnify duplicate linker_and_flavor methods in rustc_codegen_{cranelift,ssa}.
Luqman Aden [Sat, 5 Jun 2021 02:47:28 +0000 (19:47 -0700)]
Unify duplicate linker_and_flavor methods in rustc_codegen_{cranelift,ssa}.

3 years agoAuto merge of #84171 - ricobbe:raw-dylib-via-llvm, r=petrochenkov
bors [Sun, 6 Jun 2021 03:59:17 +0000 (03:59 +0000)]
Auto merge of #84171 - ricobbe:raw-dylib-via-llvm, r=petrochenkov

Partial support for raw-dylib linkage

First cut of functionality for issue #58713: add support for `#[link(kind = "raw-dylib")]` on `extern` blocks in lib crates compiled to .rlib files.  Does not yet support `#[link_name]` attributes on functions, or the `#[link_ordinal]` attribute, or `#[link(kind = "raw-dylib")]` on `extern` blocks in bin crates; I intend to publish subsequent PRs to fill those gaps.  It's also not yet clear whether this works for functions in `extern "stdcall"` blocks; I also intend to investigate that shortly and make any necessary changes as a follow-on PR.

This implementation calls out to an LLVM function to construct the actual `.idata` sections as temporary `.lib` files on disk and then links those into the generated .rlib.

3 years agoAuto merge of #79608 - alessandrod:bpf, r=nagisa
bors [Sun, 6 Jun 2021 01:02:32 +0000 (01:02 +0000)]
Auto merge of #79608 - alessandrod:bpf, r=nagisa

BPF target support

This adds `bpfel-unknown-none` and `bpfeb-unknown-none`, two new no_std targets that generate little and big endian BPF. The approach taken is very similar to the cuda target, where `TargetOptions::obj_is_bitcode` is enabled and code generation is done by the linker.

I added the targets to `dist-various-2`. There are [some tests](https://github.com/alessandrod/bpf-linker/tree/main/tests/assembly) in bpf-linker and I'm planning to add more. Those are currently not ran as part of rust CI.