Commit graph

143 commits

Author SHA1 Message Date
Mark Rousskov
c746be2219 Migrate to 2021 2021-09-20 22:21:42 -04:00
Mark Rousskov
5e1a614b53 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.
2021-09-20 08:45:39 -04:00
Eduard-Mihai Burtescu
c1837ef1c5 Querify fn_abi_of_{fn_ptr,instance}. 2021-09-18 04:41:33 +03:00
Eduard-Mihai Burtescu
e9b68304ef ty::layout: replicate layout_of setup for fn_abi_of_{fn_ptr,instance}. 2021-09-18 04:41:29 +03:00
Eduard-Mihai Burtescu
344df76fed ty::layout: intern FnAbis as &'tcx. 2021-09-18 01:42:45 +03:00
bors
96dee2825e 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.
2021-09-12 23:49:24 +00:00
Gary Guo
1c3409f333 Introduce NullOp::AlignOf 2021-09-13 00:08:35 +01:00
Andreas Liljeqvist
5b2f757dae Make abi::Abi Copy and remove a *lot* of refs
fix

fix

Remove more refs and clones

fix

more

fix
2021-09-09 10:41:19 +02:00
Camille GILLOT
fd9c04fe32 Move the dataflow framework to its own crate. 2021-09-07 19:57:07 +02:00
Camille GILLOT
81a600b6b7 Move monomorphize code to its own crate. 2021-09-07 19:53:04 +02:00
bors
e2750baf53 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`
2021-09-05 16:14:41 +00:00
bors
d32dc80bb6 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.
2021-09-05 04:37:12 +00:00
bors
97f2698484 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`
2021-09-03 00:23:10 +00:00
bjorn3
b86a2ee036 Use in_incr_comp_dir_sess in cg_clif 2021-09-02 12:29:12 +02:00
Eduard-Mihai Burtescu
f53c93cf65 ty::layout: split LayoutOf into required and (blanket) provided halves. 2021-09-02 01:17:14 +03:00
Eduard-Mihai Burtescu
1e02262dcc ty::layout: implement layout_of automatically as a default method. 2021-09-02 01:17:14 +03:00
Eduard-Mihai Burtescu
4ce933f13f rustc_target: move LayoutOf to ty::layout. 2021-09-02 01:17:14 +03:00
bjorn3
977f279553 Move add_rlib and add_native_library to cg_ssa
This deduplicates logic between codegen backends
2021-09-01 14:43:27 +02:00
Eduard-Mihai Burtescu
8e6d126b7d rustc_target: TyAndLayout::field should never error. 2021-08-30 00:44:09 +03:00
Eduard-Mihai Burtescu
83d986aa28 rustc_target: add lifetime parameter to LayoutOf. 2021-08-27 13:09:32 +03:00
Michael Woerister
af1b65cb18 Path remapping: Make behavior of diagnostics output dependent on presence of --remap-path-prefix. 2021-08-27 11:50:44 +02:00
lcnr
bfaf13af4e make unevaluated const substs optional 2021-08-26 11:00:30 +02:00
bors
d3e2578c31 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`
2021-08-21 21:14:07 +00:00
Marcel Hellwig
0f081832b4 remove box_syntax uses from cranelift and tools 2021-08-18 09:31:51 +02:00
Charles Lew
6b1c52ff25 Fold vtable_trait_upcasting_coercion_new_vptr_slot logic into obligation processing. 2021-08-18 13:00:27 +08:00
Aaron Hill
179fd38bb5
Update rustc_codegen_cratelift for working_dir change 2021-08-15 15:17:37 -05:00
Gary Guo
1fb1643129 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`.
2021-08-12 16:16:57 +01:00
bjorn3
279f486960 Merge commit '05677b6bd6c938ed760835d9b1f6514992654ae3' into sync_cg_clif-2021-08-06 2021-08-06 16:26:56 +02:00
bors
c6bc102fea 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`
2021-08-03 16:58:56 +00:00
Charles Lew
63ed625313 Implement pointer casting. 2021-08-03 01:09:37 +08:00
Jade
3cf820e17d 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.
2021-07-29 14:56:05 -07:00
Yuki Okushi
81d0b70402
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.
2021-07-18 14:21:56 +09:00
Richard Cobbe
ce59f1aac5 Consider all fields when comparing DllImports, to remove nondetermininsm in multiple-definitions test 2021-07-16 11:10:31 -07:00
Ralf Jung
172abb29b1 fix cranelift 2021-07-14 18:17:49 +02:00
Scott McMurray
6444f24a29 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>
2021-07-08 14:55:58 -07:00
Scott McMurray
3d2869c6ff PR Feedback: Don't put SSA-only types in CValues 2021-07-08 14:55:58 -07:00
Scott McMurray
12163534a9 Implement the raw_eq intrinsic in codegen_cranelift 2021-07-08 14:55:57 -07:00
bjorn3
d531f3d6ee Merge commit '3a31c6d8272c14388a34622193baf553636fe470' into sync_cg_clif-2021-07-07 2021-07-07 11:14:20 +02:00
bjorn3
56ee9864c1 Don't pass local_crate_name to link_binary separately
It is already part of CodegenResults
2021-07-06 17:49:23 +02:00
bjorn3
323a74779f Move LinkerInfo into CrateInfo 2021-07-06 15:31:38 +02:00
bjorn3
8748e37d35 Remove LibSource
The information is stored in used_crate_source too anyway
2021-07-05 10:49:07 +02:00
bors
e98897e5dc 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`
2021-06-29 15:52:21 +00:00
Charles Lew
d3ff497bec Update other codegens to use tcx managed vtable allocations. 2021-06-28 19:39:48 +08:00
bors
345530412f Auto merge of #85909 - cjgillot:alloc-kind-query, r=Aaron1011
Make allocator_kind a query.

Part of #85153

r? `@Aaron1011`
2021-06-28 01:20:01 +00:00
bors
50a9081216 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
2021-06-25 04:06:32 +00:00
Camille GILLOT
6a371d2c89 Make allocator_kind a query. 2021-06-20 11:52:51 +02:00
bors
2336406b38 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`
2021-06-16 07:20:27 +00:00
LeSeulArtichaut
e3ca81fd5a Use the now available implementation of IntoIterator for arrays 2021-06-14 23:40:09 +02:00
Charles Lew
a86d3a7e45 Refactor to make interpreter and codegen backend neutral to vtable internal representation. 2021-06-15 01:59:00 +08:00
bors
1639a16ebf Auto merge of #85910 - cjgillot:no-meta-version, r=Aaron1011
Drop metadata_encoding_version.

Part of #85153

r? `@Aaron1011`
2021-06-10 00:39:25 +00:00