Commit Graph

11302 Commits

Author SHA1 Message Date
Mark Rousskov
34319ff4e1 Avoid emitting full macro body into JSON 2022-02-24 11:16:45 -05:00
bors
3d127e2040 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
96cf7999ab Introduce Bx::switch_to_block 2022-02-24 12:18:21 +01:00
bors
7ccfe2ff1d Auto merge of #94129 - cjgillot:rmeta-table, r=petrochenkov
Back more metadata using per-query tables

r? `@ghost`
2022-02-24 10:02:26 +00:00
Matthias Krüger
a93be6def9
Rollup merge of #94292 - esp-rs:riscv32imc-esp-espidf-64bit-atomics, r=petrochenkov
riscv32imc_esp_espidf: set max_atomic_width to 64

For espidf targets without native atomics, there is atomic emulation inside [the newlib component of espidf](https://github.com/espressif/esp-idf/blob/master/components/newlib/stdatomic.c), this has been extended to support emulation up to 64bits therefore we are safe to increase the atomic width for the `riscv32imc_esp_espidf` target.

Closes https://github.com/esp-rs/rust/issues/107

cc: `@ivmarkov`
2022-02-24 07:48:10 +01:00
Matthias Krüger
ae27c4ab1f
Rollup merge of #94288 - Mark-Simulacrum:ser-opt, r=nnethercote
Cleanup a few Decoder methods

This is just some simple follow up to #93839.

r? `@nnethercote`
2022-02-24 07:48:09 +01:00
Matthias Krüger
3cd1dc1d6e
Rollup merge of #94270 - RalfJung:fn-ptrs, r=oli-obk
Miri: relax fn ptr check

As discussed in https://github.com/rust-lang/unsafe-code-guidelines/issues/72#issuecomment-1025407536, the function pointer check done by Miri is currently overeager: contrary to our usual principle of only checking rather uncontroversial validity invariants, we actually check that the pointer points to a real function.

So, this relaxes the check to what the validity invariant probably will be (and what the reference already says it is): the function pointer must be non-null, and that's it.

The check that CTFE does on the final value of a constant is unchanged -- CTFE recurses through references, so it makes some sense to also recurse through function pointers. We might still want to relax this in the future, but that would be a separate change.

r? `@oli-obk`
2022-02-24 07:48:06 +01:00
Matthias Krüger
8a42e3da0b
Rollup merge of #94267 - pierwill:fast-reject-bound, r=michaelwoerister
Remove unused ordering derivations and bounds for `SimplifiedTypeGen`

This is another small PR clearing the way for work on #90317.
2022-02-24 07:48:05 +01:00
Matthias Krüger
77a8e60dd7
Rollup merge of #89887 - arlosi:char-debug, r=wesleywiser
Change `char` type in debuginfo to DW_ATE_UTF

Rust previously encoded the `char` type as DW_ATE_unsigned_char. The more appropriate encoding is `DW_ATE_UTF`.

Clang also uses the DW_ATE_UTF for `char32_t` in C++.

This fixes the display of the `char` type in the Windows debuggers. Without this change, the variable did not show in the locals window.
![image](https://user-images.githubusercontent.com/704597/137368067-9b3e4dc8-a075-44ba-a687-bf3810a44e5a.png)

LLDB 13 is also able to display the char value, when before it failed with `need to add support for DW_TAG_base_type 'char' encoded with DW_ATE = 0x8, bit_size = 32`

r? `@wesleywiser`
2022-02-24 07:48:04 +01:00
bors
e780264e1e Auto merge of #94107 - tmiasko:fewer-types, r=davidtwco
Reapply cg_llvm: `fewer_names` in `uncached_llvm_type`

r? `@davidtwco` `@erikdesjardins`
2022-02-24 04:07:48 +00:00
bors
8ebec97e09 Auto merge of #93438 - spastorino:node_id_to_hir_id_refactor, r=oli-obk
Node id to hir id refactor

Related to #89278

r? `@oli-obk`
2022-02-24 01:26:57 +00:00
Ralf Jung
182d335870 Miri: relax fn ptr check 2022-02-23 15:11:38 -05:00
Arlo Siemsen
be454f056f Change char type in debuginfo to DW_ATE_UTF
Rust previously encoded the `char` type as DW_ATE_unsigned_char. The more
appropriate encoding is DW_ATE_UTF.

Clang uses this same debug encoding for char32_t.

This fixes the display of `char` types in Windows debuggers as well as LLDB.
2022-02-23 08:31:10 -08:00
Scott Mabin
65614e91ad riscv32imc_esp_espidf: set max_atomic_width to 64 2022-02-23 13:11:26 +00:00
Matthias Krüger
8f53bdb45f
Rollup merge of #94285 - bjorn3:sync_cg_clif-2022-02-23, r=bjorn3
Sync rustc_codegen_cranelift

r? `@ghost`

`@rustbot` label +A-codegen +A-cranelift +T-compiler
2022-02-23 12:26:48 +01:00
Matthias Krüger
ecf2faacff
Rollup merge of #94280 - tmiasko:should-print-region, r=oli-obk
Rename `region_should_not_be_omitted` to `should_print_region`

to avoid double negation
2022-02-23 12:26:47 +01:00
Matthias Krüger
81794bed12
Rollup merge of #94271 - RalfJung:downcast, r=oli-obk
Miri: extend comments on downcast operation

r? `@oli-obk`
2022-02-23 12:26:46 +01:00
Matthias Krüger
14ac74d438
Rollup merge of #94213 - digama0:patch-4, r=Dylan-DPC
fix names in feature(...) suggestion
2022-02-23 12:26:41 +01:00
Matthias Krüger
8bb6051317
Rollup merge of #94137 - aDotInTheVoid:abi-enum, r=CraftSpider
rustdoc-json: Better Header Type

- Make ABI an enum, instead of being stringly typed
- Replace Qualifier HashSet with 3 bools
- Merge ABI field into header, as they always occor together

r? ``@CraftSpider``

``@rustbot`` modify labels: +A-rustdoc-json +T-rustdoc
2022-02-23 12:26:41 +01:00
Matthias Krüger
0c676a8a84
Rollup merge of #94128 - mqy:master, r=Dylan-DPC
rustdoc: several minor fixes

``@rustbot`` label A-docs
2022-02-23 12:26:40 +01:00
bjorn3
f596dce542 Merge commit '35d9c6bf256968e1b40e0d554607928bdf9cebea' into sync_cg_clif-2022-02-23 2022-02-23 11:49:34 +01:00
Tomasz Miąsko
1113cd5bbe Rename region_should_not_be_omitted to should_print_region
to avoid double negation
2022-02-23 08:58:36 +01:00
pierwill
516e965bfd Remove unused ordering derivations and bounds for SimplifiedTypeGen 2022-02-22 22:29:13 -06:00
bors
bafe8d06e0 Auto merge of #93984 - nnethercote:ChunkedBitSet, r=Mark-Simulacrum
Introduce `ChunkedBitSet` and use it for some dataflow analyses.

This reduces peak memory usage significantly for some programs with very
large functions.

r? `@ghost`
2022-02-23 01:26:07 +00:00
Ralf Jung
d0192e6291 Miri: extend comments on downcast operation 2022-02-22 19:09:11 -05:00
Nicholas Nethercote
36b495f3cf Introduce ChunkedBitSet and use it for some dataflow analyses.
This reduces peak memory usage significantly for some programs with very
large functions, such as:
- `keccak`, `unicode_normalization`, and `match-stress-enum`, from
  the `rustc-perf` benchmark suite;
- `http-0.2.6` from crates.io.

The new type is used in the analyses where the bitsets can get huge
(e.g. 10s of thousands of bits): `MaybeInitializedPlaces`,
`MaybeUninitializedPlaces`, and `EverInitializedPlaces`.

Some refactoring was required in `rustc_mir_dataflow`. All existing
analysis domains are either `BitSet` or a trivial wrapper around
`BitSet`, and access in a few places is done via `Borrow<BitSet>` or
`BorrowMut<BitSet>`. Now that some of these domains are `ClusterBitSet`,
that no longer works. So this commit replaces the `Borrow`/`BorrowMut`
usage with a new trait `BitSetExt` containing the needed bitset
operations. The impls just forward these to the underlying bitset type.
This required fiddling with trait bounds in a few places.

The commit also:
- Moves `static_assert_size` from `rustc_data_structures` to
  `rustc_index` so it can be used in the latter; the former now
  re-exports it so existing users are unaffected.
- Factors out some common "clear excess bits in the final word"
  functionality in `bit_set.rs`.
- Uses `fill` in a few places instead of loops.
2022-02-23 10:18:49 +11:00
Mark Rousskov
f1bcb0f3af Delete Decoder::read_unit 2022-02-22 18:14:51 -05:00
Mark Rousskov
2098ea6eba Provide copy-free access to raw Decoder bytes 2022-02-22 18:11:59 -05:00
Mark Rousskov
da3b2ca956 Provide raw &str access from Decoder 2022-02-22 18:05:51 -05:00
bors
68369a041c Auto merge of #94254 - matthiaskrgr:rollup-7llbjhd, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #94169 (Fix several asm! related issues)
 - #94178 (tidy: fire less "ignoring file length unneccessarily" warnings)
 - #94179 (solarish current_exe using libc call directly)
 - #94196 (compiletest: Print process output info with less whitespace)
 - #94208 (Add the let else tests found missing in the stabilization report)
 - #94237 (Do not suggest wrapping an item if it has ambiguous un-imported methods)
 - #94246 (ScalarMaybeUninit is explicitly hexadecimal in its formatting)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-02-22 14:41:26 +00:00
Santiago Pastorino
d82a7bc1b5
local_id is always != 0 at this point 2022-02-22 09:37:47 -03:00
Matthias Krüger
e3814629c4
Rollup merge of #94246 - RalfJung:hex, r=oli-obk
ScalarMaybeUninit is explicitly hexadecimal in its formatting

This makes `ScalarMaybeUninit` consistent with `Scalar` after the changes in https://github.com/rust-lang/rust/pull/94189.

r? ``@oli-obk``
2022-02-22 12:16:34 +01:00
Matthias Krüger
396910a664
Rollup merge of #94237 - compiler-errors:dont-wrap-ambiguous-receivers, r=lcnr
Do not suggest wrapping an item if it has ambiguous un-imported methods

If the method is defined for the receiver we have, but is ambiguous during probe, then it probably comes from one of several traits that just weren't `use`d. Don't suggest wrapping the receiver in `Box`/etc., even if that makes the method probe unambiguous.

Fixes #94218
2022-02-22 12:16:33 +01:00
Matthias Krüger
1cf2e6993e
Rollup merge of #94169 - Amanieu:asm_stuff, r=nagisa
Fix several asm! related issues

This is a combination of several fixes, each split into a separate commit. Splitting these into PRs is not practical since they conflict with each other.

Fixes #92378
Fixes #85247

r? ``@nagisa``
2022-02-22 12:16:28 +01:00
bors
9ecd75b831 Auto merge of #94209 - lcnr:print-mir-consts, r=oli-obk
change `mir::Constant` in mir dumps

this removes duplicate information and avoids printing the `stable_crate_id` in mir dumps which broke CI in #94059

r? `@oli-obk` cc `@b-naber`
2022-02-22 11:10:26 +00:00
lcnr
ee0b56483f change mir::Constant in mir dumps 2022-02-22 09:38:07 +01:00
bors
58a721af9f Auto merge of #93839 - Mark-Simulacrum:delete-json-rust-deserialization, r=nnethercote
Simplify rustc_serialize by dropping support for decoding into JSON

This PR currently bundles two (somewhat separate) tasks.

First, it removes the JSON Decoder trait impl, which permitted going from JSON to Rust structs. For now, we keep supporting JSON deserialization, but only to `Json` (an equivalent of serde_json::Value). The primary hard to remove user there is for custom targets -- which need some form of JSON deserialization -- but they already have a custom ad-hoc pass for moving from Json to a Rust struct.

A [comment](e7aca89598/compiler/rustc_target/src/spec/mod.rs (L1653)) there suggests that it would be impractical to move them to a Decodable-based impl, at least without backwards compatibility concerns. I suspect that if we were widely breaking compat there, it would make sense to use serde_json at this point which would produce better error messages; the types in rustc_target are relatively isolated so we would not particularly suffer from using serde_derive.

The second part of the PR (all but the first commit) is to simplify the Decoder API by removing the non-primitive `read_*` functions. These primarily add indirection (through a closure), which doesn't directly cause a performance issue (the unique closure types essentially guarantee monomorphization), but does increase the amount of work rustc and LLVM need to do. This could be split out to a separate PR, but is included here in part to help motivate the first part.

Future work might consist of:

* Specializing enum discriminant encoding to avoid leb128 for small enums (since we know the variant count, we can directly use read/write u8 in almost all cases)
* Adding new methods to support faster deserialization (e.g., access to the underlying byte stream)
   * Currently these are somewhat ad-hoc supported by specializations for e.g. `Vec<u8>`, but other types which could benefit don't today.
* Removing the Decoder trait entirely in favor of a concrete type -- today, we only really have one impl of it modulo wrappers used for specialization-based dispatch.

Highly recommend review with whitespace changes off, as the removal of closures frequently causes things to be de-indented.
2022-02-22 07:54:22 +00:00
David Wood
4e41a46f6a Reapply cg_llvm: fewer_names in uncached_llvm_type
Co-authored-by: Erik Desjardins <erikdesjardins@users.noreply.github.com>
Co-authored-by: Tomasz Miąsko <tomasz.miasko@gmail.com>
2022-02-22 08:23:53 +01:00
Ralf Jung
fb1ee8764f ScalarMaybeUninit is explicitly hexadecimal in its formatting 2022-02-21 21:46:51 -05:00
Michael Goulet
0626919f21 Do not suggest wrapping an item if it has ambiguous un-imported methods 2022-02-21 16:45:35 -08:00
bors
b8967b0d52 Auto merge of #94225 - matthiaskrgr:rollup-0728x8n, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - #91192 (Some improvements to the async docs)
 - #94143 (rustc_const_eval: adopt let else in more places)
 - #94156 (Gracefully handle non-UTF-8 string slices when pretty printing)
 - #94186 (Update pin_static_ref stabilization version.)
 - #94189 (Implement LowerHex on Scalar to clean up their display in rustdoc)
 - #94190 (Use Metadata::modified instead of FileTime::from_last_modification_ti…)
 - #94203 (CTFE engine: Scalar: expose size-generic to_(u)int methods)
 - #94211 (Better error if the user tries to do assignment ... else)
 - #94215 (trait system: comments and small nonfunctional changes)
 - #94220 (Correctly handle miniz_oxide extern crate declaration)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-02-21 22:53:45 +00:00
Amanieu d'Antras
a60b79137c Add ignore-tidy-filelength 2022-02-21 19:18:00 +00:00
Matthias Krüger
9157775152
Rollup merge of #94215 - lcnr:leak-check, r=jackh726
trait system: comments and small nonfunctional changes

r? `@nikomatsakis` because of the leak-check check removal
2022-02-21 19:36:54 +01:00
Matthias Krüger
d3649f8d52
Rollup merge of #94211 - est31:let_else_destructuring_error, r=matthewjasper
Better error if the user tries to do assignment ... else

If the user tries to do assignment ... else, we now issue a more comprehensible error in the parser.

closes #93995
2022-02-21 19:36:53 +01:00
Matthias Krüger
f3a1a8cd4f
Rollup merge of #94203 - RalfJung:to_sized_int, r=oli-obk
CTFE engine: Scalar: expose size-generic to_(u)int methods

This matches the size-generic constructors `Scalar::from_(u)int`, and it would have helped in https://github.com/rust-lang/miri/pull/1978.

r? `@oli-obk`
2022-02-21 19:36:52 +01:00
Matthias Krüger
f639ba634b
Rollup merge of #94189 - GuillaumeGomez:scalar-lower-hex, r=RalfJung
Implement LowerHex on Scalar to clean up their display in rustdoc

Follow-up of https://github.com/rust-lang/rust/pull/94091.

r? ````@RalfJung````
2022-02-21 19:36:50 +01:00
Matthias Krüger
da25e1e59c
Rollup merge of #94156 - tmiasko:pp-str, r=petrochenkov
Gracefully handle non-UTF-8 string slices when pretty printing

Fixes #78520.
2022-02-21 19:36:48 +01:00
Matthias Krüger
ea7f7f7c4c
Rollup merge of #94143 - est31:let_else_const_eval, r=lcnr
rustc_const_eval: adopt let else in more places

Continuation of #89933, #91018, #91481, #93046, #93590, #94011.

I have extended my clippy lint to also recognize tuple passing and match statements. The diff caused by fixing it is way above 1 thousand lines. Thus, I split it up into multiple pull requests to make reviewing easier. This PR handles rustc_const_eval.
2022-02-21 19:36:48 +01:00
Amanieu d'Antras
fb5539b475 Add tests 2022-02-21 18:28:22 +00:00
Amanieu d'Antras
fc41d4bf35 Take CodegenFnAttrs into account when validating asm! register operands
Checking of asm! register operands now properly takes function
attributes such as #[target_feature] and #[instruction_set] into
account.
2022-02-21 18:28:22 +00:00