Commit Graph

350 Commits

Author SHA1 Message Date
Yuki Okushi
83f126bedf
Rollup merge of #78101 - RalfJung:foreign-static, r=oli-obk
fix static_ptr_ty for foreign statics

Cc https://github.com/rust-lang/rust/issues/74840

This does not fix that issue but fixes a problem in `static_ptr_ty` that we noticed while discussing that issue. I also added and updated a few comments. The one about `internal` locals being ignored does not seem to have been true [even in the commit that introduced it](https://github.com/rust-lang/rust/pull/44700/files#diff-ae2f3c7e2f9744f7ef43e96072b10e98d4e3fe74a3a399a3ad8a810fbe56c520R139).

r? @oli-obk
2020-10-21 13:59:43 +09:00
Guillaume Gomez
3fea201b11
Rollup merge of #78061 - wesleywiser:opt_zst_const_interning, r=oli-obk
Optimize const value interning for ZST types

Interning can skip any inhabited ZST type in general.

Fixes #68010

r? @oli-obk
2020-10-20 21:46:32 +02:00
Tomasz Miąsko
c2af254e3b Disable MatchBranchSimplification
This optimization can result in unsoundness, because it introduces
additional uses of a place holding the discriminant value without
ensuring that it is valid to do so.
2020-10-20 00:00:00 +00:00
Ralf Jung
c1766c6372 fix static_ptr_ty for foreign statics, and more comments in check_unsafety 2020-10-19 09:47:18 +02:00
bors
4d247ad7d3 Auto merge of #77306 - lcnr:inline-ok, r=eddyb
normalize substs while inlining

fixes #68347 or more precisely, this fixes the same ICE in rust analyser as veloren is pinned to a specific nightly
and had an error with the current one.

I didn't look into creating an MVCE here as that seems fairly annoying, will spend a few minutes doing so rn. (failed)

r? `@eddyb` cc `@bjorn3`
2020-10-18 16:10:00 +00:00
bors
834821e3b6 Auto merge of #78066 - bugadani:wat, r=jonas-schievink
Clean up small, surprising bits of code

This PR clean up a small number of unrelated, small things I found while browsing the code base.
2020-10-18 13:50:31 +00:00
Dániel Buga
f3a0f68453 Zip -> Enumerate 2020-10-18 11:01:08 +02:00
Wesley Wiser
1d07d696d2 Optimize const value interning for ZST types
Interning can skip any inhabited ZST type in general.
2020-10-17 16:07:00 -04:00
bors
ffeeb20398 Auto merge of #77373 - jonas-schievink:rm-rf-copy-prop, r=oli-obk
Remove the old copy propagation pass

This pass was added a long time ago, and has not really seen much improvement since (apart from some great work in https://github.com/rust-lang/rust/pull/76569 that unfortunately ran into preexisting soundness issues). It is slow and unsound, and we now have a destination propagation pass that performs a related optimization and could be extended.

Closes https://github.com/rust-lang/rust/issues/36673
Closes https://github.com/rust-lang/rust/issues/73717
Closes https://github.com/rust-lang/rust/issues/76740
2020-10-17 16:57:21 +00:00
Dylan DPC
496e2feed6
Rollup merge of #76199 - Mark-Simulacrum:void-zero, r=nikomatsakis
Permit uninhabited enums to cast into ints

This essentially reverts part of #6204; it is unclear why that [commit](c0f587de34) was introduced, and I suspect no one remembers.

The changed code was only called from casting checks and appears to not affect any callers of that code (other than permitting this one case).

Fixes #75647.
2020-10-17 03:27:12 +02:00
Jonas Schievink
dc3177775c Remove the old copy propagation pass 2020-10-17 02:25:31 +02:00
Yuki Okushi
d334059696
Rollup merge of #77992 - nagisa:thaw-coverage-instrumentation, r=wesleywiser
instrument-coverage: try our best to not ICE

instrument-coverage was ICEing for me on some code, in particular code
that had devirtualized paths from standard library. Instrument coverage
probably has no bussiness dictating which paths are valid and which
aren't so just feed it everything and whatever and let tooling deal with
other stuff.

For example, with this commit we can generate coverage hitpoints for
these interesting paths:

* `/rustc/.../library/core/lib.rs` – non-devirtualized path for libcore
* `/home/.../src/library/core/lib.rs` – devirtualized version of above
* `<inline asm>`, `<anon>` and many similar synthetic paths

Even if those paths somehow get to the instrumentation pass, I'd much
rather get hits for these weird paths and hope some of them work (as
would be the case for devirtualized path to libcore), rather than have
compilation fail entirely.
2020-10-17 05:36:52 +09:00
Simonas Kazlauskas
8436cfe71d instrument-coverage: try our best to not ICE
instrument-coverage was ICEing for me on some code, in particular code
that had devirtualized paths from standard library. Instrument coverage
probably has no bussiness dictating which paths are valid and which
aren't so just feed it everything and whatever and let tooling deal with
other stuff.

For example, with this commit we can generate coverage hitpoints for
these interesting paths:

* `/rustc/.../library/core/lib.rs` – non-devirtualized path for libcore
* `/home/.../src/library/core/lib.rs` – devirtualized version of above
* `<inline asm>`, `<anon>` and many similar synthetic paths

Even if those paths somehow get to the instrumentation pass, I'd much
rather get hits for these weird paths and hope some of them work (as
would be the case for devirtualized path to libcore), rather than have
compilation fail entirely.
2020-10-16 21:46:41 +03:00
bors
9bd740a8f1 Auto merge of #77947 - tmiasko:promoted-scope, r=oli-obk
Create a single source scope for promoteds

A promoted inherits all scopes from the parent body.  At the same time,
almost all statements and terminators inside the promoted body so far
refer only to one of those scopes: the outermost one.

Instead of inheriting all scopes, inherit only a single scope
corresponding to the location of the promoted, making sure that there
are no references to other scopes.
2020-10-16 02:27:49 +00:00
est31
4fa5578774 Replace target.target with target and target.ptr_width with target.pointer_width
Preparation for a subsequent change that replaces
rustc_target::config::Config with its wrapped Target.

On its own, this commit breaks the build. I don't like making
build-breaking commits, but in this instance I believe that it
makes review easier, as the "real" changes of this PR can be
seen much more easily.

Result of running:

find compiler/ -type f -exec sed -i -e 's/target\.target\([)\.,; ]\)/target\1/g' {} \;
find compiler/ -type f -exec sed -i -e 's/target\.target$/target/g' {} \;
find compiler/ -type f -exec sed -i -e 's/target.ptr_width/target.pointer_width/g' {} \;
./x.py fmt
2020-10-15 12:02:24 +02:00
Yuki Okushi
ccc86bbb40
Rollup merge of #77946 - tmiasko:validate-source-scope, r=jonas-schievink
Validate references to source scopes
2020-10-15 07:32:39 +09:00
Yuki Okushi
df08fe7214
Rollup merge of #77936 - est31:remove_needless_alloc_slice, r=jonas-schievink
Remove needless alloc_slice

Don't invoke alloc_slice.

Arenas are temporary,
empty slices are eternal!
2020-10-15 07:32:37 +09:00
est31
301907497f Remove needless alloc_slice
Don't invoke alloc_slice.

Arenas are temporary,
empty slices are eternal!
2020-10-14 14:23:32 +02:00
est31
215cd36e1c Remove unused code from remaining compiler crates 2020-10-14 04:14:32 +02:00
Tomasz Miąsko
db54752082 Create a single source scope for promoteds
A promoted inherits all scopes from the parent body.  At the same time,
almost all statements and terminators inside the promoted body so far
refer only to one of those scopes: the outermost one.

Instead of inheriting all scopes, inherit only a single scope
corresponding to the location of the promoted, making sure that there
are no references to other scopes.
2020-10-14 00:00:00 +00:00
Tomasz Miąsko
585e737ec1 Validate references to source scopes 2020-10-14 00:00:00 +00:00
Yuki Okushi
70f8e1a56f
Rollup merge of #77892 - est31:remove_redundant_absolute_paths, r=lcnr
Replace absolute paths with relative ones

Modern compilers allow reaching external crates
like std or core via relative paths in modules
outside of lib.rs and main.rs.
2020-10-14 06:02:36 +09:00
est31
a0fc455d30 Replace absolute paths with relative ones
Modern compilers allow reaching external crates
like std or core via relative paths in modules
outside of lib.rs and main.rs.
2020-10-13 14:16:45 +02:00
bors
2d6eccdb67 Auto merge of #77755 - bugadani:perf-calc-dtor, r=ecstatic-morse
Monomorphize `calculate_dtor` instead of using function pointers

Change `calculate_dtor` to avoid dynamic dispatching. This change allows the empty functions to be optimized away.

Based on the discussion in https://github.com/rust-lang/rust/pull/77754#discussion_r502498970, the performance impact of this change was measured.

Perf run results: https://perf.rust-lang.org/compare.html?start=7bc5839e99411aad9061a632b62075d1346cbb3b&end=ffec759ae9bbc4d6d2235ff40ade6723a85bc7cc
2020-10-13 10:19:30 +00:00
bors
afb4514c09 Auto merge of #77796 - jonas-schievink:switchint-refactor, r=oli-obk
Refactor how SwitchInt stores jump targets

Closes https://github.com/rust-lang/rust/issues/65693
2020-10-13 00:57:03 +00:00
Yuki Okushi
233319fc65
Rollup merge of #77818 - bugadani:range, r=oli-obk
Mono collector: replace pair of ints with Range

I found the initial PR (#33171) that introduced this piece of code but I didn't find any information about why a tuple was preferred over a `Range<usize>`.

I'm hoping there are no technical reasons to not do this.
2020-10-13 04:08:02 +09:00
Yuki Okushi
687d7646de
Rollup merge of #77550 - lcnr:ty-dep-path-ct-cleanup, r=ecstatic-morse
add shims for WithOptConstParam query calls

r? @ecstatic-morse @eddyb
2020-10-13 04:07:50 +09:00
bors
8cc82ee340 Auto merge of #77793 - tmiasko:no-op-discriminant, r=ecstatic-morse
Recognize discriminant reads as no-ops in RemoveNoopLandingPads

The cleanup blocks often contain read of discriminants. Teach
RemoveNoopLandingPads to recognize them as no-ops to remove
additional no-op landing pads.
2020-10-11 16:33:47 +00:00
Jonas Schievink
9a47f74bfe Use SmallVec in SwitchTargets
This allows building common SwitchTargets (eg. for `if`s) without
allocation.
2020-10-11 01:14:12 +02:00
Dániel Buga
0a2a68edae Use range instead of tuple of ints 2020-10-10 22:33:22 +02:00
Jonas Schievink
432535da2b Refactor how SwitchInt stores jump targets 2020-10-10 17:46:11 +02:00
Dániel Buga
0d27b765a6 Take functions by value 2020-10-10 16:19:53 +02:00
Tomasz Miąsko
ecd7862dfb Recognize discriminant reads as no-ops in RemoveNoopLandingPads
The cleanup blocks often contain read of discriminants. Teach
RemoveNoopLandingPads to recognize them as no-ops to remove
additional no-op landing pads.
2020-10-10 00:00:00 +00:00
Dániel Buga
217d6f9741 Revert calculate_dtor signature change 2020-10-09 17:18:57 +02:00
Dániel Buga
7993ddd89d Add find_map_relevant_impl 2020-10-09 16:22:49 +02:00
Lzu Tao
ab226bda9a Suggest removing &mut from borrow of &mut
Fix a typo: minding -> binding
Add test for &mut &mut
2020-10-08 14:26:21 +00:00
bors
382848989f Auto merge of #77581 - ecstatic-morse:dataflow-dump-mir-graphviz, r=davidtwco
Use `pretty::create_dump_file` for dumping dataflow results

The old code wasn't incorporating promoteds into the path, meaning other `dot` files could get clobbered. Use the MIR dump infrastructure to generate paths so that this doesn't occur in the future.
2020-10-08 11:42:24 +00:00
bors
e055f87cdf Auto merge of #77597 - simonvandel:uninhabited-hashset, r=jonas-schievink
perf: UninhabitedEnumBranching avoid n^2

Avoid n² complexity. This showed up in a profile for match-stress-enum that has 8192 variants

I have only profiled locally against `match-stress-enum`, so we should have it perf tested to make sure it does not regress other crates.
2020-10-07 23:44:57 +00:00
Simon Vandel Sillesen
e231c47aa6 perf: UninhabitedEnumBranching void n^2
Avoid n² complexity. This showed up in a profile for match-stress-enum that has 8192 variants
2020-10-07 22:06:08 +02:00
bors
4437b4b150 Auto merge of #77464 - ecstatic-morse:const-fn-impl-trait, r=oli-obk
Give `impl Trait` in a `const fn` its own feature gate

...previously it was gated under `#![feature(const_fn)]`.

I think we actually want to do this in all const-contexts? If so, this should be `#![feature(const_impl_trait)]` instead. I don't think there's any way to make use of `impl Trait` within a `const` initializer.

cc #77463

r? `@oli-obk`
2020-10-07 19:59:52 +00:00
Bastian Kauschke
f0487cee74 normalize substs during inlining 2020-10-07 10:04:08 +02:00
Dylan DPC
6b4dbb196c
Rollup merge of #77582 - ecstatic-morse:disable-early-otherwise-branch, r=wesleywiser
Move `EarlyOtherwiseBranch` to mir-opt-level 2

cc #75119

This didn't have an [effect in most cases](https://perf.rust-lang.org/compare.html?start=81e02708f1f4760244756548981277d5199baa9a&end=2e0edc0f28c5647141bedba02e7a222d3a5dc9c3&stat=instructions:u), and is not trivially sound. Let it bake at `mir-opt-level=2` for a while.

Also, this missed the cutoff for beta, so we'll have to backport this.
r? @wesleywiser
2020-10-07 00:16:08 +02:00
Dylan DPC
83c58d6fb6
Rollup merge of #77568 - lcnr:mir-inline-def-id, r=ecstatic-morse
inliner: use caller param_env

We used the callee param env instead of the caller param env by accident in #77430, this PR fixes that and caches it in the `Inliner` struct.

fixes #77564

r? @ecstatic-morse
2020-10-07 00:16:05 +02:00
Matthew Jasper
69fc6d8c5c Fix NLL compare mode tests 2020-10-06 11:19:33 +01:00
Yuki Okushi
2970af8e28
Rollup merge of #77559 - camelid:fix-rustdoc-warnings-invalid-rust-syntax, r=lcnr
Fix rustdoc warnings about invalid Rust syntax
2020-10-06 16:26:09 +09:00
Dylan MacKenzie
9beb6f81e4 Make impl Trait unstable in all contexts 2020-10-05 21:44:00 -07:00
Dylan MacKenzie
c4ef5fdf8f Remove fn from feature name 2020-10-05 21:44:00 -07:00
Dylan MacKenzie
e1d76818b2 Add #![feature(const_fn_impl)] 2020-10-05 19:56:50 -07:00
Camelid
c8d25af698 Fixup 2020-10-05 15:07:27 -07:00
Dylan MacKenzie
af4b13283f Move EarlyOtherwiseBranch to mir-opt-level 2
This didn't have an effect in most cases, and is not trivially sound.
Let it bake at `mir-opt-level=2` for a while.
2020-10-05 10:21:14 -07:00