Commit graph

2963 commits

Author SHA1 Message Date
Tyson Nottingham 52f21791fb Serialize incr comp structures to file via fixed-size buffer
Reduce a large memory spike that happens during serialization by writing
the incr comp structures to file by way of a fixed-size buffer, rather
than an unbounded vector.

Effort was made to keep the instruction count close to that of the
previous implementation. However, buffered writing to a file inherently
has more overhead than writing to a vector, because each write may
result in a handleable error. To reduce this overhead, arrangements are
made so that each LEB128-encoded integer can be written to the buffer
with only one capacity and error check. Higher-level optimizations in
which entire composite structures can be written with one capacity and
error check are possible, but would require much more work.

The performance is mostly on par with the previous implementation, with
small to moderate instruction count regressions. The memory reduction is
significant, however, so it seems like a worth-while trade-off.
2021-01-11 12:13:22 -08:00
bors 6526e5c772 Auto merge of #80889 - cjgillot:asa, r=oli-obk
Do not query the HIR directly in `opt_associated_item`.

Papercut found by `@Aaron1011.`
2021-01-11 14:54:52 +00:00
Yuki Okushi 293a491935
Rollup merge of #80887 - camelid:fix-log-color-auto, r=RalfJung
log-color: Detect TTY based on stderr, not stdout

Fixes #78435 (again).

Logging goes to stderr, not stdout, so we should base our automated
detection on stderr instead of stdout.

Thanks to Ralf Jung for noticing and reporting the bug!

r? `@oli-obk`
cc `@RalfJung`
2021-01-11 14:34:52 +09:00
Yuki Okushi 95a6279de7
Rollup merge of #80878 - unseddd:abi, r=RalfJung
Add ABI argument to `find_mir_or_eval_fn`

Add ABI argument for called function in `find_mir_or_eval_fn` and
`call_extra_fn`. Useful for comparing with expected ABI in interpreters.

Related to [miri/1631](https://github.com/rust-lang/miri/issues/1631)

r? `@RalfJung`
2021-01-11 14:34:49 +09:00
Yuki Okushi dcd46bfd31
Rollup merge of #80809 - camelid:rust-call-abi-msg, r=lcnr
Use standard formatting for "rust-call" ABI message

Nearly all error messages start with a lowercase letter and don't use
articles - instead they refer to the plural case.
2021-01-11 14:34:40 +09:00
bors 26d451f4b3 Auto merge of #80782 - petrochenkov:viscopes, r=matthewjasper
resolve: Scope visiting doesn't need an `Ident`

Resolution scope visitor (`fn visit_scopes`) currently takes an `Ident` parameter, but it doesn't need a full identifier, or even its span, it only needs the `SyntaxContext` part.
The `SyntaxContext` part is necessary because scope visitor has to jump to macro definition sites, so it has to be directed by macro expansion information somehow.

I think it's clearer to pass only the necessary part.
Yes, usually visiting happens as a part of an identifier resolution, but in cases like collecting traits in scope (#80765) or collecting typo suggestions that's not the case.

r? `@matthewjasper`
2021-01-10 23:36:33 +00:00
Camille GILLOT 21e1963e9c Do not query the HIR in opt_associated_item. 2021-01-10 22:41:50 +01:00
Camelid 7af29abbc1 log-color: Detect TTY based on stderr, not stdout
Logging goes to stderr, not stdout, so we should base our automated
detection on stderr instead of stdout.

Thanks to Ralf Jung for noticing and reporting the bug!
2021-01-10 13:22:15 -08:00
bors c97f11af7b Auto merge of #79414 - sasurau4:feature/add-suggestion-for-pattern-in-fns-without-body, r=matthewjasper
Add suggestion for PATTERNS_IN_FNS_WITHOUT_BODY

## Overview

Fix #78927
2021-01-10 20:48:27 +00:00
Camelid 6488aecb74 Use standard formatting for "rust-call" ABI message
Nearly all error messages start with a lowercase letter and don't use
articles - instead they refer to the plural case.
2021-01-10 12:17:24 -08:00
bors 080ee6f5d7 Auto merge of #80789 - Aaron1011:fix/stmt-empty, r=petrochenkov
Synthesize a `TokenStream` for `StmtKind::Empty`

Fixes #80760
2021-01-10 17:58:38 +00:00
Nym Seddon 06fd212d6a
Add ABI argument to find_mir_or_eval_fn
Add ABI argument for called function in `find_mir_or_eval_fn` and
`call_extra_fn`. Useful for comparing with expected ABI in interpreters.

Related to [miri/1631](https://github.com/rust-lang/miri/issues/1631)
2021-01-10 15:12:50 +00:00
bors 34628e5b53 Auto merge of #80867 - JohnTitor:rollup-tvqw555, r=JohnTitor
Rollup of 9 pull requests

Successful merges:

 - #79502 (Implement From<char> for u64 and u128.)
 - #79968 (Improve core::ptr::drop_in_place debuginfo)
 - #80774 (Fix safety comment)
 - #80801 (Use correct span for structured suggestion)
 - #80803 (Remove useless `fill_in` function)
 - #80820 (Support `download-ci-llvm` on NixOS)
 - #80825 (Remove under-used ImplPolarity enum)
 - #80850 (Allow #[rustc_builtin_macro = "name"])
 - #80857 (Add comment to `Vec::truncate` explaining `>` vs `>=`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-01-10 08:01:12 +00:00
Yuki Okushi 3e735c6e93
Rollup merge of #80850 - m-ou-se:rustc-builtin-macro-name, r=petrochenkov
Allow #[rustc_builtin_macro = "name"]

This adds the option of specifying the name of a builtin macro in the `#[rustc_builtin_macro]` attribute: `#[rustc_builtin_macro = "name"]`.

This makes it possible to have both `std::panic!` and `core::panic!` as a builtin macro, by using different builtin macro names for each. This is needed to implement the edition-specific behaviour of the panic macros of RFC 3007.

Also removes `SyntaxExtension::is_derive_copy`, as the macro name (e.g. `sym::Copy`) is now tracked and provides that information directly.

r? ``@petrochenkov``
2021-01-10 16:56:05 +09:00
Yuki Okushi 700f3f23d8
Rollup merge of #80801 - estebank:correct-binding-sugg-span, r=petrochenkov
Use correct span for structured suggestion

On structured suggestion for `let` -> `const`  and `const` -> `let`, use
a proper `Span` and update tests to check the correct application.

Follow up to #80012.
2021-01-10 16:55:59 +09:00
Yuki Okushi f90c7f0f42
Rollup merge of #79968 - bjorn3:better_drop_glue_debuginfo, r=matthewjasper
Improve core::ptr::drop_in_place debuginfo

* Use span of the dropped type as function span when possible.
* Rename symbol from `core::ptr::drop_in_place::$hash` to `{{drop}}::<$TYPE>::$hash`.

Fixes #77465

(I haven't yet updated the tests)
2021-01-10 16:55:55 +09:00
bors 7a193921a0 Auto merge of #77862 - danielhenrymantilla:rustdoc/fix-macros_2_0-paths, r=jyn514,petrochenkov
Rustdoc: Fix macros 2.0 and built-in derives being shown at the wrong path

Fixes #74355

  - ~~waiting on author + draft PR since my code ought to be cleaned up _w.r.t._ the way I avoid the `.unwrap()`s:~~

      - ~~dummy items may avoid the first `?`,~~

      - ~~but within the module traversal some tests did fail (hence the second `?`), meaning the crate did not possess the exact path of the containing module (`extern` / `impl` blocks maybe? I'll look into that).~~

r? `@jyn514`
2021-01-10 05:15:01 +00:00
bors 7cf205610e Auto merge of #80831 - jyn514:no-inline, r=Mark-Simulacrum
Don't mark `force_query_with_job` as `inline(always)`

It's rather large, and using `inline(always)` forces it to be recompiled
in each calling crate. Hopefully this change will help with #65031. I intentionally only removed inline from `force_query_with_job` because the other functions are tiny and I wanted to measure this change on its own.

This may conflict with https://github.com/rust-lang/rust/issues/78780. I am not sure if it will hurt or help.

cc `@cjgillot`
2021-01-10 01:08:41 +00:00
bors f30733adb9 Auto merge of #80441 - petrochenkov:kwtok, r=Aaron1011
ast: Remove some indirection layers from values in key-value attributes

Trying to address some perf regressions from https://github.com/rust-lang/rust/pull/78837#issuecomment-745380762.
2021-01-09 22:19:46 +00:00
Aaron Hill 3ed6caae60
Synthesize a TokenStream for StmtKind::Empty
Fixes #80760
2021-01-09 14:54:14 -05:00
bors 6184f23950 Auto merge of #80830 - Aaron1011:capture-token-empty-stack, r=petrochenkov
Use an empty `TokenCursorFrame` stack when capturing tokens

We will never need to pop  past our starting frame during token
capturing. Using an empty stack allows us to avoid pointless heap
allocations/deallocations.
2021-01-09 19:33:23 +00:00
Mara Bos b293bbaba0 Don't set builtin_name for builtin macro implementations.
This used to be necessary for `is_builtin` in the past, but is no longer required.

Co-authored-by: Vadim Petrochenkov <vadim.petrochenkov@gmail.com>
2021-01-09 20:26:57 +01:00
Vadim Petrochenkov 71cd6f42a6 ast: Remove some indirection layers from values in key-value attributes 2021-01-09 21:50:39 +03:00
Mara Bos 0aad91b990 Formatting. 2021-01-09 19:50:12 +01:00
Mara Bos d651fa78ce Allow #[rustc_builtin_macro = "name"].
This makes it possible to have both std::panic and core::panic as a
builtin macro, by using different builtin macro names for each.

Also removes SyntaxExtension::is_derive_copy, as the macro name (e.g.
sym::Copy) is now tracked and provides that information directly.
2021-01-09 19:50:06 +01:00
Vadim Petrochenkov d81c1946c6 resolve/expand: Improve attribute expansion on macro definitions and calls 2021-01-09 18:43:01 +03:00
bors c87ef0a2fc Auto merge of #80749 - as-com:target-cpu-actually-native, r=nagisa
Make target-cpu=native detect individual features

This PR makes target-cpu=native check for and enable/disable individual features instead of detecting and targeting a CPU by name. This brings the flag's behavior more in line with clang and gcc and ensures that the host actually supports each feature that we are compiling for.

This should resolve issues with miscompilations on e.g. "Haswell" Pentiums and Celerons that lack support for AVX, and also enable support for `aes` on Broadwell processors that support it. It should also resolve issues with failing to detect feature support in newer CPUs that aren't yet known by LLVM (see: #80633).

Fixes #54688
Fixes #48464
Fixes #38218
2021-01-09 04:36:24 +00:00
Joshua Nelson 0215b3a456 Don't mark force_query_with_job as inline(always)
It's rather large, and using `inline(always)` forces it to be recompiled
in each calling crate.
2021-01-08 18:38:33 -05:00
Aaron Hill 7b36408b5f
Use an empty TokenCursorFrame stack when capturing tokens
We will never need to pop  past our starting frame during token
capturing. Using an empty stack allows us to avoid pointless heap
allocations/deallocations.
2021-01-08 18:16:20 -05:00
bors 26438b4738 Auto merge of #78452 - cjgillot:ddk-struct, r=Mark-Simulacrum
Access query (DepKind) metadata through fields

This refactors the access to query definition metadata (attributes such as eval always, anon, has_params) and loading/forcing functions to generate a number of structs, instead of matching on the DepKind enum. This makes access to the fields cheaper to compile. Using a struct means that finding the metadata for a given query is just an offset away; previously the match may have been compiled to a jump table but likely not completely inlined as we expect here.

A previous attempt explored a similar strategy, but using trait objects in #78314 that proved less effective, likely due to higher overheads due to forcing dynamic calls and poorer cache utilization (all metadata is fairly densely packed with this PR).
2021-01-08 18:16:00 +00:00
Camille GILLOT 0f334c3642 Check is_anon outside of can_reconstruct_query_key. 2021-01-08 18:03:27 +01:00
Camille GILLOT 5fcc537d18 Make DepConstructor a module. 2021-01-08 18:02:04 +01:00
Camille GILLOT 921b284167 Make force_from_dep_node a function pointer. 2021-01-08 18:01:50 +01:00
Camille GILLOT bee1fbb67e Make try_load_from_on_disk_cache a function pointer. 2021-01-08 17:59:27 +01:00
Camille GILLOT 438c430c76 Make can_reconstruct_query_key a function pointer. 2021-01-08 17:57:25 +01:00
Camille GILLOT 5027f1c6ea Use a field for has_params. 2021-01-08 17:55:46 +01:00
Camille GILLOT d8c87ac080 Use a field for is_eval_always. 2021-01-08 17:53:38 +01:00
Camille GILLOT 24f0b957e7 Use a field for is_anon. 2021-01-08 17:51:53 +01:00
Andrew Sun 80ca198212 Check if the pointer is null/string is not utf8 2021-01-08 11:50:21 -05:00
Camille GILLOT 016ea6b319 Use a side-table of consts instead of matching on the DepKind enum. 2021-01-08 17:48:02 +01:00
Camille GILLOT d1220fdedf Simplify DepNodeParams. 2021-01-08 17:29:49 +01:00
Camille GILLOT 79a57625f5 Move DepNodeExt outside of the macro. 2021-01-08 17:29:48 +01:00
bors ddf2cc7f8e Auto merge of #76896 - spastorino:codegen-inline-fns2, r=davidtwco,wesleywiser
Do not make local copies of inline fns in debug mode

r? `@wesleywiser`

cc `@rust-lang/wg-incr-comp`

If this is correct it supersedes https://github.com/rust-lang/rust/pull/76889

Related to #54089
2021-01-08 15:21:45 +00:00
bors 3d8608a863 Auto merge of #80535 - JohnTitor:improve-use-diag, r=estebank
Add a note for `*` and `{}` usage on `use`

Closes #80333
2021-01-08 09:51:26 +00:00
Yuki Okushi d063745023 Add a note for * and {} usage on use 2021-01-08 17:36:14 +09:00
bors 569e542f9f Auto merge of #80756 - sunfishcode:path-cleanup/rustc-incremental, r=nagisa
Optimize away some `fs::metadata` calls.

This also eliminates a use of a `Path` convenience function, in support
of #80741, refactoring `std::path` to focus on pure data structures and
algorithms.
2021-01-08 07:01:30 +00:00
Andrew Sun bc4c5bac40 Use LLVMGetHostCPUFeatures instead of stdsimd 2021-01-07 23:25:19 -05:00
Yuki Okushi f6c58afe15
Rollup merge of #80785 - petrochenkov:prettyparen, r=Aaron1011
rustc_ast_pretty: Remove `PrintState::insert_extra_parens`

It's no longer necessary after #79472.

r? `@Aaron1011`
2021-01-08 11:11:45 +09:00
Yuki Okushi 0afd72e313
Rollup merge of #79675 - CraftSpider:79669, r=estebank
Make sure rust-call errors occur correctly for traits

Fixes #79669

Adds trait method resolution to the error, and adds UI tests to ensure it doesn't happen again. Opening as draft because I'm getting weird link errors from unrelated code on my machine, and want to see what CI thinks.
2021-01-08 11:11:34 +09:00
Esteban Küber 9a5dcaab67 Use correct span for structured suggestion
On structured suggestion for `let` -> `const`  and `const` -> `let`, use
a proper `Span` and update tests to check the correct application.

Follow up to #80012.
2021-01-07 16:52:44 -08:00