rust/src/test
bors 848e0a23f3 Auto merge of #61922 - tmandry:moar-generator-optimization, r=matthewjasper
Don't store locals that have been moved from in generators

This avoids reserving storage in generators for locals that are moved
out of (and not re-initialized) prior to yield points. Fixes #59123.

This adds a new dataflow analysis, `RequiresStorage`, to determine whether the storage of a local can be destroyed without being observed by the program. The rules are:

1. StorageLive(x) => mark x live
2. StorageDead(x) => mark x dead
3. If a local is moved from, _and has never had its address taken_, mark it dead
4. If (any part of) a local is initialized, mark it live'

This is used to determine whether to save a local in the generator object at all, as well as which locals can be overlapped in the generator layout.

Here's the size in bytes of all testcases included in the change, before and after the change:

async fn test    |Size before |Size after
-----------------|------------|----------
single           | 1028       | 1028
single_with_noop | 2056       | 1032
joined           | 5132       | 3084
joined_with_noop | 8208       | 3084

generator test              |Size before |Size after
----------------------------|------------|----------
move_before_yield           | 1028       | 1028
move_before_yield_with_noop | 2056       | 1032
overlap_move_points         | 3080       | 2056

## Future work

Note that there is a possible extension to this optimization, which modifies rule 3 to read: "If a local is moved from, _**and either has never had its address taken, or is Freeze and has never been mutably borrowed**_, mark it dead." This was discussed at length in #59123 and then #61849. Because this would cause some behavior to be UB which was not UB before, it's a step that needs to be taken carefully.

A more immediate priority for me is inlining `std::mem::size_of_val(&x)` so it becomes apparent that the address of `x` is not taken. This way, using `size_of_val` to look at the size of your inner futures does not affect the size of your outer future.

cc @cramertj @eddyb @Matthias247 @nikomatsakis @RalfJung @Zoxc
2019-07-02 12:25:00 +00:00
..
assembly Ignore NVPTX tests 2019-06-12 23:09:08 +02:00
auxiliary Expose VaListImpl as the Rust equivalent of __va_list_tag and implement Clone for it. 2019-06-17 16:04:49 -07:00
codegen Auto merge of #59625 - immunant:copy_variadics_typealias, r=eddyb 2019-06-18 21:50:46 +00:00
codegen-units Remove unnecessary ignore-tidy-linelength 2019-04-23 11:42:14 +01:00
compile-fail Auto merge of #60341 - mtak-:macos-tlv-workaround, r=alexcrichton 2019-06-20 02:36:49 +00:00
debuginfo Fix CDB support tidy check line length failures. 2019-05-20 02:44:26 -07:00
incremental Auto merge of #61778 - petrochenkov:pass, r=Mark-Simulacrum 2019-06-23 17:16:22 +00:00
mir-opt Add StorageDead statements for while conditions 2019-06-25 22:41:22 +01:00
pretty Introduce #[rustc_dummy] attribute and use it in tests 2019-06-08 23:55:25 +03:00
run-fail compiletest: Validate pass modes harder 2019-06-16 12:23:22 +03:00
run-make Make tests compatible with musl host 2019-05-10 16:12:47 +02:00
run-make-fulldeps Auto merge of #59625 - immunant:copy_variadics_typealias, r=eddyb 2019-06-18 21:50:46 +00:00
run-pass Auto merge of #61922 - tmandry:moar-generator-optimization, r=matthewjasper 2019-07-02 12:25:00 +00:00
run-pass-fulldeps let_chains: Add test cases to pprust-expr-roundtrip. 2019-06-23 01:29:29 +02:00
run-pass-valgrind Added ignore-sgx for appropriate tests 2019-05-16 14:29:12 -07:00
rustdoc Revert "implicit Option-returning doctests" 2019-07-01 16:41:37 +02:00
rustdoc-js Auto merge of #59910 - Centril:rollup-yjv7b06, r=Centril 2019-04-12 11:46:01 +00:00
rustdoc-js-std Rename rustdoc js test suites 2019-02-25 17:46:06 +01:00
rustdoc-ui Fix tests after revert of rustdoc cfg(test) feature 2019-06-08 18:26:06 +01:00
rustfix
ui Auto merge of #62253 - Centril:rollup-115uuuq, r=Centril 2019-07-01 06:41:48 +00:00
ui-fulldeps Unify all uses of 'gcx and 'tcx. 2019-06-14 18:58:23 +03:00
COMPILER_TESTS.md