Commit graph

115 commits

Author SHA1 Message Date
Simon Vandel Sillesen
27068cbfdc add cleanup of cfg 2020-09-20 14:45:47 +02:00
Simon Vandel Sillesen
118aae2af1 insert storageDead for not equal temp 2020-09-20 14:45:47 +02:00
Simon Vandel Sillesen
2530274023 correct comment 2020-09-20 14:45:46 +02:00
Simon Vandel Sillesen
5cc93950ac Update src/librustc_mir/transform/early_otherwise_branch.rs
Co-authored-by: Laurențiu Nicola <lnicola@users.noreply.github.com>
2020-09-20 14:45:46 +02:00
Simon Vandel Sillesen
5fb32c2e33 New MIR optimization pass to reduce branches on match of tuples of enums 2020-09-20 14:45:46 +02:00
bors
5e449b9adf Auto merge of #74949 - oli-obk:validate_const_eval_raw, r=RalfJung
Validate constants during `const_eval_raw`

This PR implements the groundwork for https://github.com/rust-lang/rust/issues/72396

* constants are now validated during `const_eval_raw`
* to prevent cycle errors, we do not validate references to statics anymore beyond the fact that they are not dangling
* the `const_eval` query ICEs if used on `static` items
* as a side effect promoteds are now evaluated to `ConstValue::Scalar` again (since they are just a reference to the actual promoted allocation in most cases).
2020-09-20 08:58:32 +00:00
bors
10b3595ba6 Auto merge of #76411 - RalfJung:promote-in-const-fn, r=ecstatic-morse
Some promotion cleanup

Based on top of both https://github.com/rust-lang/rust/pull/75502 and https://github.com/rust-lang/rust/pull/75585, this does some cleanup of the promotion code. The last 2 commits are new.

* Remove the remaining cases where `const fn` is treated different from `fn`. This means no longer promoting ptr-to-int casts, raw ptr operations, and union field accesses in `const fn` -- or anywhere, for that matter. These are all unstable in const-context so this should not break any stable code. Fixes https://github.com/rust-lang/rust/issues/75586.
* ~~Promote references to statics even outside statics (i.e., in functions) for consistency.~~
* Promote `&mut []` everywhere, not just in non-`const` functions, for consistency.
* Explain why we do not promote deref's of statics outside statics. ~~(This is the only remaining direct user of `const_kind`.)~~

This can only land once the other two PRs land; I am mostly putting this up already because I couldn't wait ;) and to get some feedback from `@rust-lang/wg-const-eval` .
2020-09-20 06:20:16 +00:00
bors
a3bc0e752f Auto merge of #75346 - davidtwco:issue-69925-polymorphic-instancedef-fnptrshim, r=nikomatsakis
shim: monomorphic `FnPtrShim`s during construction

Fixes #69925.

This PR adjusts MIR shim construction so that substitutions are applied to function pointer shims during construction, rather than during codegen (as determined by `substs_for_mir_body`).

r? `@eddyb`
2020-09-20 04:15:43 +00:00
bors
255a4c58f5 Auto merge of #72632 - jonas-schievink:dest-prop, r=oli-obk
Implement a generic Destination Propagation optimization on MIR

This takes the work that was originally started by `@eddyb` in https://github.com/rust-lang/rust/pull/47954, and then explored by me in https://github.com/rust-lang/rust/pull/71003, and implements it in a general (ie. not limited to acyclic CFGs) and dataflow-driven way (so that no additional infrastructure in rustc is needed).

The pass is configured to run at `mir-opt-level=2` and higher only. To enable it by default, some followup work on it is still needed:
* Performance needs to be evaluated. I did some light optimization work and tested against `tuple-stress`, which caused trouble in my last attempt, but didn't go much in depth here.
  * We can also enable the pass only at `opt-level=2` and higher, if it is too slow to run in debug mode, but fine when optimizations run anyways.
* Debuginfo needs to be fixed after locals are merged. I did not look into what is required for this.
* Live ranges of locals (aka `StorageLive` and `StorageDead`) are currently deleted. We either need to decide that this is fine, or if not, merge the variable's live ranges (or remove these statements entirely – https://github.com/rust-lang/rust/issues/68622).

Some benchmarks of the pass were done in https://github.com/rust-lang/rust/pull/72635.
2020-09-20 01:38:26 +00:00
Ralf Jung
9216eb8258 fix some comments 2020-09-19 22:14:17 +02:00
Ralf Jung
7b99c8e1cf never promote non-const operations; revert STATIC promotion change 2020-09-19 22:14:17 +02:00
Ralf Jung
7febd5a257 fix doc comment 2020-09-19 22:14:17 +02:00
Ralf Jung
4d1ef03c9e cleanup promotion const_kind checks
in particular allow a few more promotions for consistency when they were already allowed in other contexts
2020-09-19 22:14:17 +02:00
Ralf Jung
4831523ac4
Rollup merge of #76757 - matthiaskrgr:clippy_try_into, r=lcnr
don't convert types to the same type with try_into (clippy::useless_conversion)
2020-09-19 11:47:52 +02:00
Ralf Jung
f62ba52f5c
Rollup merge of #75502 - ecstatic-morse:implicit-promotion-in-const-fn, r=RalfJung
Use implicit (not explicit) rules for promotability by default in `const fn`

For crater run. See https://github.com/rust-lang/const-eval/pull/54#discussion_r469995552.

cc #75586
2020-09-19 11:47:35 +02:00
Oliver Scherer
b8e6883a2f Reflect the "do not call this query directly" mentality in its name 2020-09-19 10:57:14 +02:00
Oliver Scherer
c3c8c981a8 Rustfmt 2020-09-19 10:36:36 +02:00
Oliver Scherer
182ed8544d Address review comments 2020-09-19 10:36:36 +02:00
Oliver Scherer
888afd50d9 Unify the names of const eval queries and their return types 2020-09-19 10:36:36 +02:00
Oliver Scherer
69a6be73e6 Rename const eval queries to reflect the validation changes 2020-09-19 10:36:36 +02:00
Oliver Scherer
dd9702a059 Do not call the const_eval query in mir interpretation except for caching of nulary intrinsics 2020-09-19 10:36:36 +02:00
Oliver Scherer
48f366fced Replace and_then map_err and_then chain with a match 2020-09-19 10:36:36 +02:00
Oliver Scherer
b1bd34df0c turn_into_const is infallible 2020-09-19 10:36:36 +02:00
Oliver Scherer
4397d66d42 Document op_to_const's purpose 2020-09-19 10:36:36 +02:00
Oliver Scherer
2d7ac728e4 Stop using the const_eval query for initializers of statics
As a side effect, we now represent most promoteds as `ConstValue::Scalar` again. This is useful because all implict promoteds are just references anyway and most explicit promoteds are numeric arguments to `asm!` or SIMD instructions.
2020-09-19 10:36:36 +02:00
Oliver Scherer
083f1d7a37 Validate constants during const_eval_raw 2020-09-19 10:36:36 +02:00
Jonas Schievink
2f9271b14c Clarify FIXME 2020-09-18 21:23:01 +02:00
Jonas Schievink
ffd9445812 Return Place by value 2020-09-18 21:23:01 +02:00
Jonas Schievink
682de94e31 Move inner items outside 2020-09-18 21:23:01 +02:00
Jonas Schievink
cd5d7201ad Fix rebase fallout 2020-09-18 21:23:01 +02:00
Jonas Schievink
7af964fecf Limit block count 2020-09-18 21:23:01 +02:00
Jonas Schievink
5728834448 Fix rebase fallout 2020-09-18 21:23:01 +02:00
Jonas Schievink
484db5b08a Properly inherit conflicts when merging locals 2020-09-18 21:23:01 +02:00
Jonas Schievink
934634eacc More logging 2020-09-18 21:23:01 +02:00
Jonas Schievink
88538adf9a Record intra-statement/terminator conflicts
Some MIR statements and terminators have an (undocumented...) invariant
that some of their input and outputs must not overlap. This records
conflicts between locals used in these positions.
2020-09-18 21:23:01 +02:00
Jonas Schievink
ddd6930b54 perf: bail out when there's >500 candidate locals 2020-09-18 21:23:01 +02:00
Jonas Schievink
ab26fb140c perf: only calculate conflicts for candidates 2020-09-18 21:23:01 +02:00
Jonas Schievink
402f863d8a perf: walk liveness backwards in Conflicts::build 2020-09-18 21:23:00 +02:00
Jonas Schievink
812d4bbc8d Fix dataflow assert errors 2020-09-18 21:23:00 +02:00
Jonas Schievink
78ff69ba10 Implement a destination propagation pass 2020-09-18 21:23:00 +02:00
bors
9f8ac718f4 Auto merge of #76575 - lcnr:abstract-const, r=oli-obk
compare generic constants using `AbstractConst`s

This is a MVP of rust-lang/compiler-team#340. The changes in this PR should only be relevant if `feature(const_evaluatable_checked)` is enabled.

~~currently based on top of #76559, so blocked on that.~~

r? `@oli-obk` cc `@varkor` `@eddyb`
2020-09-18 16:59:50 +00:00
Bastian Kauschke
d327fa112b initial working state 2020-09-18 16:25:25 +02:00
bors
fdc3405c20 Auto merge of #72412 - VFLashM:issue-72408-nested-closures-exponential, r=tmandry
Issue 72408 nested closures exponential

This fixes #72408.

Nested closures were resulting in exponential compilation time.

This PR is enhancing asymptotic complexity, but also increasing the constant, so I would love to see perf run results.
2020-09-18 14:08:39 +00:00
bors
2c69266c06 Auto merge of #76837 - wesleywiser:disable_consideredequal, r=oli-obk
[mir-opt] Disable the `ConsideredEqual` logic in SimplifyBranchSame opt

The logic is currently broken and we need to disable it to fix a beta
regression (see #76803)

r? `@oli-obk`
2020-09-18 10:54:14 +00:00
Valerii Lashmanov
17d2e3b5d2 Better handling for exponential-sized types in misc places
Mostly to fix ui/issues/issue-37311-type-length-limit/issue-37311.rs.

Most parts of the compiler can handle deeply nested types with a lot
of duplicates just fine, but some parts still attempt to naively
traverse type tree.

Before such problems were caught by type length limit check,
but now these places will have to be changed to handle
duplicated types gracefully.
2020-09-17 20:44:11 -05:00
Dylan MacKenzie
e03f4164d9 Default to implicit (not explicit) rules for promotability in const fn 2020-09-17 08:39:11 -07:00
Wesley Wiser
dbd7226d29 [mir-opt] Disable the ConsideredEqual logic in SimplifyBranchSame opt
The logic is currently broken and we need to disable it to fix a beta
regression (see #76803)
2020-09-17 09:36:50 -04:00
bors
7bdb5dee7b Auto merge of #76634 - RalfJung:miri-guaranteed-eq-ne, r=oli-obk
move guaranteed{ne,eq} implementation to compile-time machine

Currently, Miri needs a special hack to avoid using the core engine implementation of these intrinsics. That seems silly, so let's move them to the CTFE machine, which is the only machine that wants to use them.

I also added a reference to https://github.com/rust-lang/rust/issues/73722 as a warning to anyone who wants to adjust `guaranteed_eq`.
2020-09-17 12:15:57 +00:00
Matthias Krüger
0e3414248a don't lazily evaulate some trivial values for Option::None replacements (clippy::unnecessary_lazy_evaluations) 2020-09-17 01:37:35 +02:00
Tyler Mandry
3bf66ae25f
Rollup merge of #76794 - richkadel:graphviz-font, r=ecstatic-morse
Make graphviz font configurable

Alternative to PR #76776.

To change the graphviz output to use an alternative `fontname` value,
add a command line option like: `rustc --graphviz-font=monospace`.

r? @ecstatic-morse
2020-09-16 12:24:30 -07:00