]> git.lizzy.rs Git - rust.git/log
rust.git
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

3 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>

3 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

3 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

3 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

3 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

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

3 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.

3 years agoAdd first cut of functionality for #58713: support for #[link(kind = "raw-dylib")].
Richard Cobbe [Mon, 8 Mar 2021 20:42:54 +0000 (12:42 -0800)]
Add first cut of functionality for #58713: support for #[link(kind = "raw-dylib")].

This does not yet support #[link_name] attributes on functions, the #[link_ordinal]
attribute, #[link(kind = "raw-dylib")] on extern blocks in bin crates, or
stdcall functions on 32-bit x86.

3 years agoMove crate_name field from OngoingCodegen to CrateInfo
bjorn3 [Sat, 29 May 2021 15:37:38 +0000 (17:37 +0200)]
Move crate_name field from OngoingCodegen to CrateInfo

3 years agoMove windows_subsystem field from CodegenResults to CrateInfo
bjorn3 [Sat, 29 May 2021 15:08:46 +0000 (17:08 +0200)]
Move windows_subsystem field from CodegenResults to CrateInfo

3 years agoAllow printing the version of the default codegen backend if it isn't llvm
bjorn3 [Sat, 29 May 2021 13:14:05 +0000 (15:14 +0200)]
Allow printing the version of the default codegen backend if it isn't llvm

3 years agoProvide default MetadataLoader
bjorn3 [Sat, 29 May 2021 13:00:18 +0000 (15:00 +0200)]
Provide default MetadataLoader

3 years agoProvide a default provide* implementation for CodegenBackend
bjorn3 [Sat, 29 May 2021 12:51:27 +0000 (14:51 +0200)]
Provide a default provide* implementation for CodegenBackend

Both cg_llvm and cg_clif don't override it. cg_spirv does override it,
so it needs to be preserved.

3 years agoDrop metadata_encoding_version.
Camille GILLOT [Sat, 29 May 2021 20:49:59 +0000 (22:49 +0200)]
Drop metadata_encoding_version.

3 years agoRevert "Reduce the amount of untracked state in TyCtxt"
Camille Gillot [Tue, 1 Jun 2021 07:05:22 +0000 (09:05 +0200)]
Revert "Reduce the amount of untracked state in TyCtxt"

3 years agoDrop metadata_encoding_version.
Camille GILLOT [Sat, 29 May 2021 20:49:59 +0000 (22:49 +0200)]
Drop metadata_encoding_version.

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 agoMerge commit '40dd3e2b7089b5e96714e064b731f6dbf17c61a9' into sync_cg_clif-2021-05-27
bjorn3 [Thu, 27 May 2021 11:08:14 +0000 (13:08 +0200)]
Merge commit '40dd3e2b7089b5e96714e064b731f6dbf17c61a9' into sync_cg_clif-2021-05-27

3 years agoChange the ice hook for cg_clif to refer to cg_clif's issue tracker
bjorn3 [Mon, 24 May 2021 16:55:30 +0000 (18:55 +0200)]
Change the ice hook for cg_clif to refer to cg_clif's issue tracker

3 years ago(try to) fix cranelift
Ralf Jung [Sun, 23 May 2021 10:44:05 +0000 (12:44 +0200)]
(try to) fix cranelift

3 years agoAdd BPF target
Alessandro Decina [Mon, 30 Nov 2020 19:41:57 +0000 (19:41 +0000)]
Add BPF target

This change adds the bpfel-unknown-none and bpfeb-unknown-none targets
which can be used to generate little endian and big endian BPF

3 years agoCTFE core engine allocation & memory API improvemenets
Ralf Jung [Sun, 16 May 2021 16:53:20 +0000 (18:53 +0200)]
CTFE core engine allocation & memory API improvemenets

- make Allocation API offset-based (no more Pointer)
- make Memory API higher-level (combine checking for access and getting access into one operation)

3 years agoAuto merge of #85178 - cjgillot:local-crate, r=oli-obk
bors [Mon, 17 May 2021 01:42:03 +0000 (01:42 +0000)]
Auto merge of #85178 - cjgillot:local-crate, r=oli-obk

Remove CrateNum parameter for queries that only work on local crate

The pervasive `CrateNum` parameter is a remnant of the multi-crate rustc idea.

Using `()` as query key in those cases avoids having to worry about the validity of the query key.

3 years agoAuto merge of #83640 - bjorn3:shared_metadata_reader, r=nagisa
bors [Fri, 14 May 2021 12:58:58 +0000 (12:58 +0000)]
Auto merge of #83640 - bjorn3:shared_metadata_reader, r=nagisa

Use the object crate for metadata reading

This allows sharing the metadata reader between cg_llvm, cg_clif and other codegen backends.

This is not currently useful for rlib reading with cg_spirv ([rust-gpu](https://github.com/EmbarkStudios/rust-gpu/)) as it uses tar rather than ar as .rlib format, but it is useful for dylib reading required for loading proc macros. (cc `@eddyb)`

The object crate is already trusted as dependency of libstd through backtrace. As far as I know it supports reading all object file formats used by targets for which we support rust dylibs with crate metadata, but I am not certain. If this happens to not be the case, I could keep using LLVM for reading dylib metadata.

Marked as WIP for a perf run and as it is based on #83637.

3 years agoAdd support for const operands and options to global_asm!
Amanieu d'Antras [Sun, 11 Apr 2021 19:51:28 +0000 (20:51 +0100)]
Add support for const operands and options to global_asm!

On x86, the default syntax is also switched to Intel to match asm!

3 years agoUse () for codegen queries.
Camille GILLOT [Tue, 11 May 2021 12:39:04 +0000 (14:39 +0200)]
Use () for codegen queries.

3 years agoUse () for entry_fn.
Camille GILLOT [Tue, 11 May 2021 10:00:59 +0000 (12:00 +0200)]
Use () for entry_fn.

3 years agoUse () in dependency_formats.
Camille GILLOT [Tue, 11 May 2021 09:26:52 +0000 (11:26 +0200)]
Use () in dependency_formats.

3 years agoAuto merge of #83813 - cbeuw:remap-std, r=michaelwoerister
bors [Wed, 12 May 2021 11:05:56 +0000 (11:05 +0000)]
Auto merge of #83813 - cbeuw:remap-std, r=michaelwoerister

Fix `--remap-path-prefix` not correctly remapping `rust-src` component paths and unify handling of path mapping with virtualized paths

This PR fixes #73167 ("Binaries end up containing path to the rust-src component despite `--remap-path-prefix`") by preventing real local filesystem paths from reaching compilation output if the path is supposed to be remapped.

`RealFileName::Named` introduced in #72767 is now renamed as `LocalPath`, because this variant wraps a (most likely) valid local filesystem path.

`RealFileName::Devirtualized` is renamed as `Remapped` to be used for remapped path from a real path via `--remap-path-prefix` argument, as well as real path inferred from a virtualized (during compiler bootstrapping) `/rustc/...` path. The `local_path` field is now an `Option<PathBuf>`, as it will be set to `None` before serialisation, so it never reaches any build output. Attempting to serialise a non-`None` `local_path` will cause an assertion faliure.

When a path is remapped, a `RealFileName::Remapped` variant is created. The original path is preserved in `local_path` field and the remapped path is saved in `virtual_name` field. Previously, the `local_path` is directly modified which goes against its purpose of "suitable for reading from the file system on the local host".

`rustc_span::SourceFile`'s fields `unmapped_path` (introduced by #44940) and `name_was_remapped` (introduced by #41508 when `--remap-path-prefix` feature originally added) are removed, as these two pieces of information can be inferred from the `name` field: if it's anything other than a `FileName::Real(_)`, or if it is a `FileName::Real(RealFileName::LocalPath(_))`, then clearly `name_was_remapped` would've been false and `unmapped_path` would've been `None`. If it is a `FileName::Real(RealFileName::Remapped{local_path, virtual_name})`, then `name_was_remapped` would've been true and `unmapped_path` would've been `Some(local_path)`.

cc `@eddyb` who implemented `/rustc/...` path devirtualisation

3 years agoAuto merge of #83610 - bjorn3:driver_cleanup, r=cjgillot
bors [Wed, 12 May 2021 08:38:03 +0000 (08:38 +0000)]
Auto merge of #83610 - bjorn3:driver_cleanup, r=cjgillot

rustc_driver cleanup

Best reviewed one commit at a time.

3 years agoUse the object crate for metadata reading
bjorn3 [Mon, 29 Mar 2021 09:39:13 +0000 (11:39 +0200)]
Use the object crate for metadata reading

3 years agoImplement RFC 2951: Native link modifiers
Luqman Aden [Thu, 25 Mar 2021 04:45:09 +0000 (21:45 -0700)]
Implement RFC 2951: Native link modifiers

This commit implements both the native linking modifiers infrastructure
as well as an initial attempt at the individual modifiers from the RFC.
It also introduces a feature flag for the general syntax along with
individual feature flags for each modifier.

3 years agoUse local and remapped paths where appropriate
Andy Wang [Mon, 19 Apr 2021 22:27:02 +0000 (23:27 +0100)]
Use local and remapped paths where appropriate

3 years agoRevamp RealFileName public methods
Andy Wang [Wed, 14 Apr 2021 13:12:39 +0000 (14:12 +0100)]
Revamp RealFileName public methods

3 years agoUse RealFileName for Session::working_dir as it may also be remapped
Andy Wang [Sat, 10 Apr 2021 12:48:06 +0000 (13:48 +0100)]
Use RealFileName for Session::working_dir as it may also be remapped

3 years agoPass target_cpu to LinkerInfo::new instead of link_binary
bjorn3 [Sun, 28 Mar 2021 20:14:09 +0000 (22:14 +0200)]
Pass target_cpu to LinkerInfo::new instead of link_binary

This is one step towards separating the linking code from codegen backends

3 years agoMerge commit '15c8d31392b9fbab3b3368b67acc4bbe5983115a' into cranelift-rebase
Erin Power [Fri, 30 Apr 2021 16:46:59 +0000 (18:46 +0200)]
Merge commit '15c8d31392b9fbab3b3368b67acc4bbe5983115a' into cranelift-rebase

3 years ago[cg_clif] Fix run_jit from sync
Erin Power [Fri, 30 Apr 2021 13:27:05 +0000 (15:27 +0200)]
[cg_clif] Fix run_jit from sync

3 years agoSync rustc_codegen_cranelift 'ddd4ce25535cf71203ba3700896131ce55fde795'
Erin Power [Fri, 30 Apr 2021 12:49:58 +0000 (14:49 +0200)]
Sync rustc_codegen_cranelift 'ddd4ce25535cf71203ba3700896131ce55fde795'

3 years agoImplement RFC 1260 with feature_name `imported_main`.
Charles Lew [Sun, 25 Apr 2021 17:09:35 +0000 (01:09 +0800)]
Implement RFC 1260 with feature_name `imported_main`.

3 years agoAdd more SIMD math.h intrinsics
Jubilee Young [Wed, 14 Apr 2021 22:07:36 +0000 (15:07 -0700)]
Add more SIMD math.h intrinsics

LLVM supports many functions from math.h in its IR. Many of these have
single-instruction variants on various platforms. So, let's add them so
std::arch can use them.

Yes, exact comparison is intentional: rounding must always return a
valid integer-equal value, except for inf/NAN.

3 years agoFix outdated crate names in compiler docs
pierwill [Wed, 7 Apr 2021 19:47:01 +0000 (14:47 -0500)]
Fix outdated crate names in compiler docs

Changes `librustc_X` to `rustc_X`, only in documentation comments.
Plain code comments are left unchanged.

Also fix incorrect file paths.

3 years agoAdd an Mmap wrapper to rustc_data_structures
bjorn3 [Mon, 29 Mar 2021 09:18:52 +0000 (11:18 +0200)]
Add an Mmap wrapper to rustc_data_structures

This wrapper implements StableAddress and falls back to directly reading
the file on wasm32

3 years agoMerge commit '0969bc6dde001e01e7e1f58c8ccd7750f8a49ae1' into sync_cg_clif-2021-03-29
bjorn3 [Mon, 29 Mar 2021 08:45:09 +0000 (10:45 +0200)]
Merge commit '0969bc6dde001e01e7e1f58c8ccd7750f8a49ae1' into sync_cg_clif-2021-03-29

3 years agoupdate `const_eval_resolve`
lcnr [Sat, 13 Mar 2021 15:31:38 +0000 (16:31 +0100)]
update `const_eval_resolve`

3 years agoAdd simd_neg platform intrinsic
SparrowLii [Thu, 18 Mar 2021 18:16:21 +0000 (02:16 +0800)]
Add simd_neg platform intrinsic

3 years agos/ConstantSource/ConstantKind/
Oli Scherer [Mon, 15 Mar 2021 11:23:44 +0000 (11:23 +0000)]
s/ConstantSource/ConstantKind/

3 years agoPrepare mir::Constant for ty::Const only supporting valtrees
Oli Scherer [Mon, 8 Mar 2021 16:18:03 +0000 (16:18 +0000)]
Prepare mir::Constant for ty::Const only supporting valtrees

3 years agoAuto merge of #76570 - cratelyn:implement-rfc-2945-c-unwind-abi, r=Amanieu
bors [Wed, 10 Mar 2021 16:44:04 +0000 (16:44 +0000)]
Auto merge of #76570 - cratelyn:implement-rfc-2945-c-unwind-abi, r=Amanieu

Implement RFC 2945: "C-unwind" ABI

## Implement RFC 2945: "C-unwind" ABI

This branch implements [RFC 2945]. The tracking issue for this RFC is #74990.

The feature gate for the issue is `#![feature(c_unwind)]`.

This RFC was created as part of the ffi-unwind project group tracked at rust-lang/lang-team#19.

### Changes

Further details will be provided in commit messages, but a high-level overview
of the changes follows:

* A boolean `unwind` payload is added to the `C`, `System`, `Stdcall`,
and `Thiscall` variants, marking whether unwinding across FFI boundaries is
acceptable. The cases where each of these variants' `unwind` member is true
correspond with the `C-unwind`, `system-unwind`, `stdcall-unwind`, and
`thiscall-unwind` ABI strings introduced in RFC 2945 [3].

* This commit adds a `c_unwind` feature gate for the new ABI strings.
Tests for this feature gate are included in `src/test/ui/c-unwind/`, which
ensure that this feature gate works correctly for each of the new ABIs.
A new language features entry in the unstable book is added as well.

* We adjust the `rustc_middle::ty::layout::fn_can_unwind` function,
used to compute whether or not a `FnAbi` object represents a function that
should be able to unwind when `panic=unwind` is in use.

* Changes are also made to
`rustc_mir_build::build::should_abort_on_panic` so that the function ABI is
used to determind whether it should abort, assuming that the `panic=unwind`
strategy is being used, and no explicit unwind attribute was provided.

[RFC 2945]: https://github.com/rust-lang/rfcs/blob/master/text/2945-c-unwind-abi.md

3 years agorustc_target: add "unwind" payloads to `Abi`
katelyn a. martin [Thu, 27 Aug 2020 15:49:18 +0000 (11:49 -0400)]
rustc_target: add "unwind" payloads to `Abi`

 ### Overview

    This commit begins the implementation work for RFC 2945. For more
    information, see the rendered RFC [1] and tracking issue [2].

    A boolean `unwind` payload is added to the `C`, `System`, `Stdcall`,
    and `Thiscall` variants, marking whether unwinding across FFI
    boundaries is acceptable. The cases where each of these variants'
    `unwind` member is true correspond with the `C-unwind`,
    `system-unwind`, `stdcall-unwind`, and `thiscall-unwind` ABI strings
    introduced in RFC 2945 [3].

 ### Feature Gate and Unstable Book

    This commit adds a `c_unwind` feature gate for the new ABI strings.
    Tests for this feature gate are included in `src/test/ui/c-unwind/`,
    which ensure that this feature gate works correctly for each of the
    new ABIs.

    A new language features entry in the unstable book is added as well.

 ### Further Work To Be Done

    This commit does not proceed to implement the new unwinding ABIs,
    and is intentionally scoped specifically to *defining* the ABIs and
    their feature flag.

 ### One Note on Test Churn

    This will lead to some test churn, in re-blessing hash tests, as the
    deleted comment in `src/librustc_target/spec/abi.rs` mentioned,
    because we can no longer guarantee the ordering of the `Abi`
    variants.

    While this is a downside, this decision was made bearing in mind
    that RFC 2945 states the following, in the "Other `unwind` Strings"
    section [3]:

    >  More unwind variants of existing ABI strings may be introduced,
    >  with the same semantics, without an additional RFC.

    Adding a new variant for each of these cases, rather than specifying
    a payload for a given ABI, would quickly become untenable, and make
    working with the `Abi` enum prone to mistakes.

    This approach encodes the unwinding information *into* a given ABI,
    to account for the future possibility of other `-unwind` ABI
    strings.

 ### Ignore Directives

    `ignore-*` directives are used in two of our `*-unwind` ABI test
    cases.

    Specifically, the `stdcall-unwind` and `thiscall-unwind` test cases
    ignore architectures that do not support `stdcall` and
    `thiscall`, respectively.

    These directives are cribbed from
    `src/test/ui/c-variadic/variadic-ffi-1.rs` for `stdcall`, and
    `src/test/ui/extern/extern-thiscall.rs` for `thiscall`.

    This would otherwise fail on some targets, see:
    https://github.com/rust-lang-ci/rust/commit/fcf697f90206e9c87b39d494f94ab35d976bfc60

 ### Footnotes

[1]: https://github.com/rust-lang/rfcs/blob/master/text/2945-c-unwind-abi.md
[2]: https://github.com/rust-lang/rust/issues/74990
[3]: https://github.com/rust-lang/rfcs/blob/master/text/2945-c-unwind-abi.md#other-unwind-abi-strings

3 years agoClean up todos
kadmin [Fri, 26 Feb 2021 16:42:51 +0000 (16:42 +0000)]
Clean up todos

Also add some span_bugs where it is unreachable

3 years agoBuild StKind::CopyOverlapping
kadmin [Sat, 23 Jan 2021 03:55:41 +0000 (03:55 +0000)]
Build StKind::CopyOverlapping

This replaces where it was previously being constructed in intrinsics, with direct construction
of the Statement.

3 years agoUpdate cranelift
kadmin [Tue, 29 Dec 2020 02:00:04 +0000 (02:00 +0000)]
Update cranelift

3 years agoAuto merge of #82727 - oli-obk:shrinkmem, r=pnkfelix
bors [Mon, 8 Mar 2021 08:39:24 +0000 (08:39 +0000)]
Auto merge of #82727 - oli-obk:shrinkmem, r=pnkfelix

Test the effect of shrinking the size of Rvalue by 16 bytes

r? `@ghost`

3 years agoMerge commit '9a0c32934ebe376128230aa8da3275697b2053e7' into sync_cg_clif-2021-03-05
bjorn3 [Fri, 5 Mar 2021 18:12:59 +0000 (19:12 +0100)]
Merge commit '9a0c32934ebe376128230aa8da3275697b2053e7' into sync_cg_clif-2021-03-05

3 years agoShrink the size of Rvalue by 16 bytes
Oli Scherer [Fri, 5 Mar 2021 09:32:47 +0000 (09:32 +0000)]
Shrink the size of Rvalue by 16 bytes

3 years agoRollup merge of #81940 - jhpratt:stabilize-str_split_once, r=m-ou-se
Guillaume Gomez [Fri, 26 Feb 2021 14:52:29 +0000 (15:52 +0100)]
Rollup merge of #81940 - jhpratt:stabilize-str_split_once, r=m-ou-se

Stabilize str_split_once

Closes #74773

3 years agoUse a QueryContext for try_mark_green.
Camille GILLOT [Mon, 18 Jan 2021 22:53:42 +0000 (23:53 +0100)]
Use a QueryContext for try_mark_green.

3 years agoUse an ItemId inside mir::GlobalAsm.
Camille GILLOT [Sat, 30 Jan 2021 18:18:48 +0000 (19:18 +0100)]
Use an ItemId inside mir::GlobalAsm.

3 years agoStabilize str_split_once
Jacob Pratt [Tue, 9 Feb 2021 22:30:37 +0000 (17:30 -0500)]
Stabilize str_split_once

3 years agoAdd a new ABI to support cmse_nonsecure_call
Hugues de Valon [Sun, 24 Jan 2021 17:15:05 +0000 (17:15 +0000)]
Add a new ABI to support cmse_nonsecure_call

This commit adds a new ABI to be selected via `extern
"C-cmse-nonsecure-call"` on function pointers in order for the compiler to
apply the corresponding cmse_nonsecure_call callsite attribute.
For Armv8-M targets supporting TrustZone-M, this will perform a
non-secure function call by saving, clearing and calling a non-secure
function pointer using the BLXNS instruction.

See the page on the unstable book for details.

Signed-off-by: Hugues de Valon <hugues.devalon@arm.com>
3 years agoRollup merge of #81618 - bjorn3:sync_cg_clif-2021-02-01, r=bjorn3
Jonas Schievink [Mon, 1 Feb 2021 13:29:47 +0000 (14:29 +0100)]
Rollup merge of #81618 - bjorn3:sync_cg_clif-2021-02-01, r=bjorn3

Sync rustc_codegen_cranelift

The highlight of this sync are abi compatibility with cg_llvm allowing mixing of cg_clif and cg_llvm compiled crates and switching to the x64 cranelift backend based on the new backend framework.

r? ``@ghost``

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

3 years agoMerge commit 'd556c56f792756dd7cfec742b9f2e07612dc10f4' into sync_cg_clif-2021-02-01
bjorn3 [Mon, 1 Feb 2021 09:11:46 +0000 (10:11 +0100)]
Merge commit 'd556c56f792756dd7cfec742b9f2e07612dc10f4' into sync_cg_clif-2021-02-01

3 years agoIndicate both start and end of pass RSS in time-passes output
Tyson Nottingham [Mon, 25 Jan 2021 20:56:21 +0000 (12:56 -0800)]
Indicate both start and end of pass RSS in time-passes output

Previously, only the end of pass RSS was indicated. This could easily
lead one to believe that the change in RSS from one pass to the next was
attributable to the second pass, when in fact it occurred between the
end of the first pass and the start of the second.

Also, improve alignment of columns.

3 years agoRollup merge of #81333 - RalfJung:const-err-simplify, r=oli-obk
Yuki Okushi [Fri, 29 Jan 2021 00:17:38 +0000 (09:17 +0900)]
Rollup merge of #81333 - RalfJung:const-err-simplify, r=oli-obk

clean up some const error reporting around promoteds

These are some error reporting simplifications enabled by https://github.com/rust-lang/rust/pull/80579.

Further simplifications are possible but could be blocked on making `const_err` a hard error.

r? ``````@oli-obk``````

3 years agoclean up some const error reporting around promoteds
Ralf Jung [Sun, 24 Jan 2021 11:50:30 +0000 (12:50 +0100)]
clean up some const error reporting around promoteds

3 years agoUse ty::{IntTy,UintTy,FloatTy} in rustc
LeSeulArtichaut [Sat, 12 Dec 2020 14:32:30 +0000 (15:32 +0100)]
Use ty::{IntTy,UintTy,FloatTy} in rustc

3 years agocodegen_cranelift: Fix redundant semicolon warn
Ömer Sinan Ağacan [Sat, 16 Jan 2021 04:17:13 +0000 (07:17 +0300)]
codegen_cranelift: Fix redundant semicolon warn

3 years agoMerge commit 'dbee13661efa269cb4cd57bb4c6b99a19732b484' into sync_cg_clif-2020-12-27
bjorn3 [Sun, 27 Dec 2020 09:30:38 +0000 (10:30 +0100)]
Merge commit 'dbee13661efa269cb4cd57bb4c6b99a19732b484' into sync_cg_clif-2020-12-27

3 years agoMake BoundRegion have a kind of BoungRegionKind
Jack Huey [Fri, 18 Dec 2020 18:24:55 +0000 (13:24 -0500)]
Make BoundRegion have a kind of BoungRegionKind

3 years agoAuto merge of #79945 - jackh726:existential_trait_ref, r=nikomatsakis
bors [Thu, 17 Dec 2020 18:21:20 +0000 (18:21 +0000)]
Auto merge of #79945 - jackh726:existential_trait_ref, r=nikomatsakis

Move binder for dyn to each list item

This essentially changes `ty::Binder<&'tcx List<ExistentialTraitRef>>` to `&'tcx List<ty::Binder<ExistentialTraitRef>>`.

This is a first step in moving the `dyn Trait` representation closer to Chalk, which we've talked about in `@rust-lang/wg-traits.`

r? `@nikomatsakis`

3 years agocg_clif: fix build with split dwarf
David Wood [Sun, 8 Nov 2020 14:01:23 +0000 (14:01 +0000)]
cg_clif: fix build with split dwarf

This commit makes minor changes to the cranelift backend so that it can
build given changes in cg_ssa for Split DWARF.

Signed-off-by: David Wood <david@davidtw.co>
3 years agoMove binder for dyn to each list item
Jack Huey [Fri, 11 Dec 2020 20:02:46 +0000 (15:02 -0500)]
Move binder for dyn to each list item

3 years agoAuto merge of #77611 - oli-obk:atomic_miri_leakage, r=nagisa
bors [Wed, 9 Dec 2020 19:53:23 +0000 (19:53 +0000)]
Auto merge of #77611 - oli-obk:atomic_miri_leakage, r=nagisa

Directly use raw pointers in `AtomicPtr` store/load

I was unable to find any reason for this limitation in the latest source of LLVM or in the documentation [here](http://llvm.org/docs/Atomics.html#libcalls-atomic).

fixes https://github.com/rust-lang/miri/issues/1574

3 years agoAllow cranelift to handle atomic pointers
oli [Sun, 29 Nov 2020 14:56:19 +0000 (14:56 +0000)]
Allow cranelift to handle atomic pointers

3 years agoMerge commit '5988bbd24aa87732bfa1d111ba00bcdaa22c481a' into sync_cg_clif-2020-11-27
bjorn3 [Fri, 27 Nov 2020 19:48:53 +0000 (20:48 +0100)]
Merge commit '5988bbd24aa87732bfa1d111ba00bcdaa22c481a' into sync_cg_clif-2020-11-27

3 years agoAuto merge of #79336 - camelid:rename-feature-oibit-to-auto, r=oli-obk
bors [Wed, 25 Nov 2020 07:25:19 +0000 (07:25 +0000)]
Auto merge of #79336 - camelid:rename-feature-oibit-to-auto, r=oli-obk

Rename `optin_builtin_traits` to `auto_traits`

They were originally called "opt-in, built-in traits" (OIBITs), but
people realized that the name was too confusing and a mouthful, and so
they were renamed to just "auto traits". The feature flag's name wasn't
updated, though, so that's what this PR does.

There are some other spots in the compiler that still refer to OIBITs,
but I don't think changing those now is worth it since they are internal
and not particularly relevant to this PR.

Also see <https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/opt-in.2C.20built-in.20traits.20(auto.20traits).20feature.20name>.

r? `@oli-obk` (feel free to re-assign if you're not the right reviewer for this)