Commit Graph

291 Commits

Author SHA1 Message Date
Antoni Boucher
0fb350f37c Fix shift of unsigned integer by signed integer 2022-03-19 12:15:26 -04:00
antoyo
d63ea3e037
Merge pull request #137 from rust-lang/fix/box-alloc-ice
Fix ice in box alloc
2022-03-19 00:11:45 -04:00
antoyo
b3e50bde9d
Merge pull request #139 from rust-lang/fix/compiler-builtin-version
Fix version of compiler_builtins to fix compilation failure
2022-03-19 00:01:41 -04:00
Antoni Boucher
be9789bf01 Fix ice in box alloc 2022-03-18 23:31:48 -04:00
Antoni Boucher
12f782edfa Fix version of compiler_builtins to fix compilation failure 2022-03-18 23:31:02 -04:00
bors
fadd1c536a Auto merge of #88098 - Amanieu:oom_panic, r=nagisa
Implement -Z oom=panic

This PR removes the `#[rustc_allocator_nounwind]` attribute on `alloc_error_handler` which allows it to unwind with a panic instead of always aborting. This is then used to implement `-Z oom=panic` as per RFC 2116 (tracking issue #43596).

Perf and binary size tests show negligible impact.
2022-03-18 03:01:46 +00:00
Michael Woerister
1c389322d2 debuginfo: Refactor debuginfo generation for types -- Rename DebugInfoMethods::create_vtable_metadata() to DebugInfoMethods::create_vtable_debuginfo() 2022-03-14 17:25:24 +01:00
Nicholas Nethercote
64012a1c2e Improve AdtDef interning.
This commit makes `AdtDef` use `Interned`. Much the commit is tedious
changes to introduce getter functions. The interesting changes are in
`compiler/rustc_middle/src/ty/adt.rs`.
2022-03-11 13:31:24 +11:00
antoyo
0cff1d0331
Merge pull request #136 from light4/clean_test
Stop removing the llvm-asm tests in test.sh since they don't exist anymore
2022-03-08 08:43:43 -05:00
lightning1141
7c1f863d74
Stop removing the llvm-asm tests in test.sh since they don't exist anymore 2022-03-08 11:40:28 +08:00
bors
3e7035fa86 Auto merge of #94690 - nnethercote:clarify-Layout-interning, r=fee1-dead
Clarify `Layout` interning.

`Layout` is another type that is sometimes interned, sometimes not, and
we always use references to refer to it so we can't take any advantage
of the uniqueness properties for hashing or equality checks.

This commit renames `Layout` as `LayoutS`, and then introduces a new
`Layout` that is a newtype around an `Interned<LayoutS>`. It also
interns more layouts than before. Previously layouts within layouts
(via the `variants` field) were never interned, but now they are. Hence
the lifetime on the new `Layout` type.

Unlike other interned types, these ones are in `rustc_target` instead of
`rustc_middle`. This reflects the existing structure of the code, which
does layout-specific stuff in `rustc_target` while `TyAndLayout` is
generic over the `Ty`, allowing the type-specific stuff to occur in
`rustc_middle`.

The commit also adds a `HashStable` impl for `Interned`, which was
needed. It hashes the contents, unlike the `Hash` impl which hashes the
pointer.

r? `@fee1-dead`
2022-03-07 15:25:42 +00:00
Nicholas Nethercote
d35fc85a44 Clarify Layout interning.
`Layout` is another type that is sometimes interned, sometimes not, and
we always use references to refer to it so we can't take any advantage
of the uniqueness properties for hashing or equality checks.

This commit renames `Layout` as `LayoutS`, and then introduces a new
`Layout` that is a newtype around an `Interned<LayoutS>`. It also
interns more layouts than before. Previously layouts within layouts
(via the `variants` field) were never interned, but now they are. Hence
the lifetime on the new `Layout` type.

Unlike other interned types, these ones are in `rustc_target` instead of
`rustc_middle`. This reflects the existing structure of the code, which
does layout-specific stuff in `rustc_target` while `TyAndLayout` is
generic over the `Ty`, allowing the type-specific stuff to occur in
`rustc_middle`.

The commit also adds a `HashStable` impl for `Interned`, which was
needed. It hashes the contents, unlike the `Hash` impl which hashes the
pointer.
2022-03-07 13:41:47 +11:00
bors
0e36868bc7 Auto merge of #94638 - erikdesjardins:noextranull, r=nagisa
cleanup: remove unused ability to have LLVM null-terminate const strings

(and the copied function in rustc_codegen_gcc)

Noticed this while writing https://github.com/rust-lang/rust/pull/94450#issuecomment-1059687348.

r? `@nagisa`
2022-03-07 02:07:36 +00:00
Nicholas Nethercote
92d1850f17 Introduce ConstAllocation.
Currently some `Allocation`s are interned, some are not, and it's very
hard to tell at a use point which is which.

This commit introduces `ConstAllocation` for the known-interned ones,
which makes the division much clearer. `ConstAllocation::inner()` is
used to get the underlying `Allocation`.

In some places it's natural to use an `Allocation`, in some it's natural
to use a `ConstAllocation`, and in some places there's no clear choice.
I've tried to make things look as nice as possible, while generally
favouring `ConstAllocation`, which is the type that embodies more
information. This does require quite a few calls to `inner()`.

The commit also tweaks how `PartialOrd` works for `Interned`. The
previous code was too clever by half, building on `T: Ord` to make the
code shorter. That caused problems with deriving `PartialOrd` and `Ord`
for `ConstAllocation`, so I changed it to build on `T: PartialOrd`,
which is slightly more verbose but much more standard and avoided the
problems.
2022-03-07 08:25:50 +11:00
Erik Desjardins
a19138f1f9 cleanup: remove unused ability to have LLVM null-terminate const strings 2022-03-06 12:28:46 -05:00
Amanieu d'Antras
6fcfc3d877 Add -Z oom={panic,abort} command-line option 2022-03-03 12:58:38 +00:00
cuishuang
8238b91402 all: fix some typos
Signed-off-by: cuishuang <imcusg@gmail.com>
2022-03-03 19:47:23 +08:00
mark
081bf75aea rename ErrorReported -> ErrorGuaranteed 2022-03-02 09:45:25 -06:00
bors
7df92e44c0 Auto merge of #87402 - nagisa:nagisa/request-feature-requests-for-features, r=estebank
Direct users towards using Rust target feature names in CLI

This PR consists of a couple of changes on how we handle target features.

In particular there is a bug-fix wherein we avoid passing through features that aren't prefixed by `+` or `-` to LLVM. These appear to be causing LLVM to assert, which is pretty poor a behaviour (and also makes it pretty clear we expect feature names to be prefixed).

The other commit, I anticipate to be somewhat more controversial is outputting a warning when users specify a LLVM-specific, or otherwise unknown, feature name on the CLI. In those situations we request users to either replace it with a known Rust feature name (e.g. `bmi` -> `bmi1`) or file a feature request. I've a couple motivations for this: first of all, if users are specifying these features on the command line, I'm pretty confident there is also a need for these features to be usable via `#[cfg(target_feature)]` machinery.  And second, we're growing a fair number of backends recently and having ability to provide some sort of unified-ish interface in this place seems pretty useful to me.

Sponsored by: standard.ai
2022-03-02 03:03:22 +00:00
Simonas Kazlauskas
4f132cb340 Querify global_backend_features
At the very least this serves to deduplicate the diagnostics that are
output about unknown target features provided via CLI.
2022-03-01 01:57:25 +02:00
Erik Desjardins
962b8cf38b Revert "Auto merge of #92419 - erikdesjardins:coldland, r=nagisa"
This reverts commit 4f49627c6f, reversing
changes made to 028c6f1454.
2022-02-27 23:11:03 -05:00
antoyo
f4ea709249
Merge pull request #135 from rust-lang/feature/byval-params
Add support for on_stack parameters
2022-02-27 22:56:46 -05:00
Antoni Boucher
dcc0853a34 Add support for on_stack parameters 2022-02-27 22:23:03 -05:00
antoyo
1a9ae8d473
Merge pull request #133 from bjorn3/less_exports
Don't export global allocs which are not statics
2022-02-27 10:28:28 -05:00
bjorn3
beb1767842 Don't export global allocs which are not statics
They aren't be referenced outside of the current cgu anyway. This should make
optimizations a bit more effective.
2022-02-27 10:14:50 +01:00
antoyo
710b7415cd
Merge pull request #132 from bjorn3/panic_unwind
Support -Cpanic=unwind without unwinding
2022-02-27 00:14:57 -05:00
bjorn3
ac4baf3fd6 Allow unreachable blocks for now
The cleanup blocks normally executed when unwinding are unreachable for
now as unwinding is not yet implemented.
2022-02-26 19:35:33 +01:00
bjorn3
f7063174a4 Support -Cpanic=unwind without unwinding 2022-02-26 19:35:33 +01:00
antoyo
1fb9821f82
Merge pull request #131 from bjorn3/fix_non_singleton_builder
Fix miscompilation when cg_ssa is using multiple builders at the same time
2022-02-26 13:02:18 -05:00
bjorn3
9d098424cd Add and change a TODO 2022-02-26 18:30:07 +01:00
bjorn3
3e35fab71e Fix inttoptr 2022-02-26 09:41:37 +01:00
bjorn3
a7c1c47c83 Fix review comments 2022-02-25 17:25:32 +01:00
bjorn3
62e9b50f8d Remove current_block field of CodegenCx
This field often had the wrong value when using multiple builders at the
same time.
2022-02-25 15:38:23 +01:00
bjorn3
07afdb8c0d Use bitcast for ptrtoint and inttoptr
This works now
2022-02-25 15:36:08 +01:00
bjorn3
b48ed38482 Make bx.block non-optional 2022-02-25 15:30:07 +01:00
bjorn3
ff6b398f1b Use bx.switch_to_block where possible 2022-02-25 15:28:56 +01:00
antoyo
ddbbded08f
Merge pull request #130 from bjorn3/rustup
Rustup to rustc 1.61.0-nightly (4b043faba 2022-02-24)
2022-02-25 09:12:31 -05:00
bjorn3
d565f60054 Rustup to rustc 1.61.0-nightly (4b043faba 2022-02-24) 2022-02-25 11:29:57 +01:00
bjorn3
471234f8aa Sync from rust 3d127e2040 2022-02-24 19:25:07 +01:00
bors
648d038c86 Auto merge of #94123 - bjorn3:cg_ssa_singleton_builder, r=tmiasko
Partially move cg_ssa towards using a single builder

Not all codegen backends can handle hopping between blocks well. For example Cranelift requires blocks to be terminated before switching to building a new block. Rust-gpu requires a `RefCell` to allow hopping between blocks and cg_gcc currently has a buggy implementation of hopping between blocks. This PR reduces the amount of cases where cg_ssa switches between blocks before they are finished and mostly fixes the block hopping in cg_gcc. (~~only `scalar_to_backend` doesn't handle it correctly yet in cg_gcc~~ fixed that one.)

`@antoyo` please review the cg_gcc changes.
2022-02-24 12:28:19 +00:00
bjorn3
18c34e41a4 Introduce Bx::switch_to_block 2022-02-24 12:18:21 +01:00
bjorn3
56b7080bdb Remove build_sibling_block 2022-02-20 13:38:15 +01:00
antoyo
164aa39fbe
Merge pull request #127 from JBBgameich/readme-compiler-rt
README: Add compiler-rt cloning step
2022-02-19 14:02:18 -05:00
Jonah Brüchert
4cdcf035a6
README: Add compiler-rt cloning step 2022-02-19 19:59:03 +01:00
Mark Rousskov
e855e2d15c Move ty::print methods to Drop-based scope guards 2022-02-16 17:24:23 -05:00
bjorn3
40d30ceb43 Unconditionally update symbols
All paths to an ArchiveBuilder::build call update_symbols first.
2022-02-10 18:27:18 +01:00
bors
22a30689ed Auto merge of #93511 - cjgillot:query-copy, r=oli-obk
Ensure that queries only return Copy types.

This should pervent the perf footgun of returning a result with an expensive `Clone` impl (like a `Vec` of a hash map).

I went for the stupid solution of allocating on an arena everything that was not `Copy`. Some query results could be made Copy easily, but I did not really investigate.
2022-02-10 09:37:07 +00:00
Camille GILLOT
1b2337c19d Make FnAbiError Copy. 2022-02-09 20:11:29 +01:00
Camille GILLOT
96340e5668 Ensure that queries only return Copy types. 2022-02-09 20:07:38 +01:00
cynecx
20506e31ab #[used(linker)] attribute (https://github.com/dtolnay/linkme/issues/41) 2022-02-06 20:23:23 +01:00