Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Take 2: change how MIR represents Place #54426

Closed
wants to merge 34 commits into from

Conversation

csmoe
Copy link
Member

@csmoe csmoe commented Sep 21, 2018

Closes #52708
Introduce the new Place with "incremental refactoring" instead of the previous approach which is hard to maintain.
r? @nikomatsakis

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 21, 2018
@rust-highfive

This comment has been minimized.

@memoryruins memoryruins added the A-NLL Area: Non-lexical lifetimes (NLL) label Sep 21, 2018
@rust-highfive

This comment has been minimized.

@rust-highfive

This comment has been minimized.

pub fn split_projection<'cx, 'gcx>(
&self,
tcx: TyCtxt<'cx, 'gcx, 'tcx>,
) -> (NeoPlace<'tcx>, Option<&'tcx PlaceElem<'tcx>>) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find this operation dishearteningly inefficient :(.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we don't "re-intern" the slice of elements, then in what way is it inefficient?

I think it'd be nice to be able to treat a NeoPlace as either a list or a tree as you choose, and this operation allows for that (although I would probably tweak the signature; I'd prefer it returns something like "Result<(NeoPlace, ProjectionElem), Base>`. ie., either you reached the base case, or else not.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe something like

enum NeoPlaceTree {
    Leaf(PlaceBase),
    Branch(NeoPlace<'tcx>, ProjectionElem<'tcx>),
}

and into_tree(self) -> NeoPlaceTree as the signature (lifetimes elided, clearly).

tcx: &TyCtxt<'cx, 'gcx, 'tcx>,
) -> Option<Field> {
let (place, by_ref) = if let Some(ProjectionElem::Deref) = self.elems.last() {
(self.projection_base(*tcx), true)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can rewrite this as going backwards in the projection list.

If you want, you can use let mut elems = self.elems.iter().rev(); and then call next() on that once, check whether it's Deref, and if it is, call next() again.

You can also use indices.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feels like this is a case where treating the projection as a tree (sort of what this code is doing) is a bit cleaner. In particular, we want to look for something like P.f or *P.f and then test the type of P. We can certainly "walk backwards" over the elements, but once we've peeled off the * and the .f we sitll kind of want to extract the P as a unit, right?

@bors

This comment has been minimized.

@rust-highfive

This comment has been minimized.

@rust-highfive

This comment has been minimized.

@rust-highfive

This comment has been minimized.

@rust-highfive

This comment has been minimized.

@rust-highfive

This comment has been minimized.

@csmoe csmoe force-pushed the place2 branch 3 times, most recently from c18a525 to 0e689b1 Compare September 25, 2018 14:51
Some((projection, place_elems)) => (
NeoPlace {
base: self.clone().base,
elems: tcx.intern_place_elems(place_elems),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need to intern again here; just use place_elems directly. It is already pointing into interned memory, right?

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-6.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_time:end:284e2dda:start=1549091148431928579,finish=1549091220787576161,duration=72355647582
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#pull-requests-and-security-restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
Setting environment variables from .travis.yml
$ export IMAGE=x86_64-gnu-llvm-6.0
---
[00:24:46]    Compiling rustc_lsan v0.0.0 (/checkout/src/librustc_lsan)
[00:24:46]    Compiling rustc_asan v0.0.0 (/checkout/src/librustc_asan)
[00:24:46]    Compiling rustc_msan v0.0.0 (/checkout/src/librustc_msan)
[00:24:47]    Compiling rustc_tsan v0.0.0 (/checkout/src/librustc_tsan)
[00:25:03] error: internal compiler error: src/librustc_mir/borrow_check/nll/mod.rs:355: region is not an ReVar: ReFree(DefId(0/0:432 ~ core[255e]::num[0]::dec2flt[0]::simplify[0]), BrAnon(1))
[00:25:03] thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:605:9
[00:25:03] note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
[00:25:03] error: aborting due to previous error
[00:25:03] 
[00:25:03] 
[00:25:03] 
[00:25:03] note: the compiler unexpectedly panicked. this is a bug.
[00:25:03] 
[00:25:03] note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
[00:25:03] 
[00:25:03] note: rustc 1.34.0-dev running on x86_64-unknown-linux-gnu
[00:25:03] 
[00:25:03] note: compiler flags: -Z force-unstable-if-unmarked -C opt-level=2 -C prefer-dynamic -C debug-assertions=y -C codegen-units=1 -C link-args=-Wl,-rpath,$ORIGIN/../lib --crate-type lib
[00:25:03] note: some of the compiler flags provided by cargo are hidden
[00:25:03] 
[00:25:03] error: Could not compile `core`.
[00:25:03] 
[00:25:03] 
[00:25:03] To learn more, run the command again with --verbose.
[00:25:03] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "build" "--target" "x86_64-unknown-linux-gnu" "-j" "4" "--release" "--locked" "--color" "always" "--features" "panic-unwind backtrace" "--manifest-path" "/checkout/src/libstd/Cargo.toml" "--message-format" "json"
[00:25:03] expected success, got: exit code: 101
[00:25:03] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap build
[00:25:03] Build completed unsuccessfully in 0:21:14
[00:25:03] make: *** [all] Error 1
[00:25:03] Makefile:18: recipe for target 'all' failed
The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:0082e6c6
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
Sat Feb  2 07:32:13 UTC 2019
---
travis_time:end:15f08311:start=1549092733938533154,finish=1549092733944846785,duration=6313631
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:1bd8ce04
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb --batch -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:0ef9f73c
travis_time:start:0ef9f73c
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:09bd5980
$ dmesg | grep -i kill

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-6.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_time:end:31276a3e:start=1549133827288055381,finish=1549133899272265488,duration=71984210107
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#pull-requests-and-security-restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
Setting environment variables from .travis.yml
$ export IMAGE=x86_64-gnu-llvm-6.0
---

[00:03:44] travis_fold:start:tidy
travis_time:start:tidy
tidy check
[00:03:44] tidy error: /checkout/src/librustc_mir/borrow_check/borrow_set.rs:214: line longer than 100 chars
[00:03:44] tidy error: /checkout/src/librustc_mir/transform/uniform_array_move_out.rs:79: line longer than 100 chars
[00:03:45] tidy error: /checkout/src/librustc/mir/visit.rs:787: trailing whitespace
[00:03:45] tidy error: /checkout/src/librustc/mir/visit.rs:789: trailing whitespace
[00:03:46] some tidy checks failed
[00:03:46] 
[00:03:46] 
[00:03:46] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/tidy" "/checkout/src" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "--no-vendor" "--quiet"
[00:03:46] 
[00:03:46] 
[00:03:46] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
[00:03:46] Build completed unsuccessfully in 0:00:44
[00:03:46] Build completed unsuccessfully in 0:00:44
[00:03:46] make: *** [tidy] Error 1
[00:03:46] Makefile:68: recipe for target 'tidy' failed
The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:2d8267e8
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
Sat Feb  2 19:02:15 UTC 2019
---
travis_time:end:02a99815:start=1549134136249362228,finish=1549134136254003684,duration=4641456
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:04c93a40
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb --batch -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:09afa808
travis_time:start:09afa808
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:0a2a077c
$ dmesg | grep -i kill

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-6.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_time:end:1f5684c6:start=1549154738184715049,finish=1549154813556430569,duration=75371715520
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#pull-requests-and-security-restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
Setting environment variables from .travis.yml
$ export IMAGE=x86_64-gnu-llvm-6.0
---

[00:03:20] travis_fold:start:tidy
travis_time:start:tidy
tidy check
[00:03:20] tidy error: /checkout/src/librustc_mir/borrow_check/borrow_set.rs:214: line longer than 100 chars
[00:03:20] tidy error: /checkout/src/librustc_mir/transform/uniform_array_move_out.rs:79: line longer than 100 chars
[00:03:20] tidy error: /checkout/src/librustc/mir/visit.rs:774: trailing whitespace
[00:03:20] tidy error: /checkout/src/librustc/mir/visit.rs:776: trailing whitespace
[00:03:22] some tidy checks failed
[00:03:22] 
[00:03:22] 
[00:03:22] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/tidy" "/checkout/src" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "--no-vendor" "--quiet"
[00:03:22] 
[00:03:22] 
[00:03:22] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
[00:03:22] Build completed unsuccessfully in 0:00:48
[00:03:22] Build completed unsuccessfully in 0:00:48
[00:03:22] make: *** [tidy] Error 1
[00:03:22] Makefile:68: recipe for target 'tidy' failed
The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:2ddd6ca7
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
Sun Feb  3 00:50:24 UTC 2019
---
travis_time:end:1cb84358:start=1549155025432858411,finish=1549155025437535335,duration=4676924
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:2fef8338
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb --batch -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:0c00ada0
travis_time:start:0c00ada0
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:03ea0bac
$ dmesg | grep -i kill

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-6.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_time:end:23838cd8:start=1549198197086786975,finish=1549198275119672570,duration=78032885595
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#pull-requests-and-security-restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
Setting environment variables from .travis.yml
$ export IMAGE=x86_64-gnu-llvm-6.0
---

[00:03:12] travis_fold:start:tidy
travis_time:start:tidy
tidy check
[00:03:12] tidy error: /checkout/src/librustc_mir/borrow_check/borrow_set.rs:214: line longer than 100 chars
[00:03:12] tidy error: /checkout/src/librustc_mir/transform/uniform_array_move_out.rs:79: line longer than 100 chars
[00:03:13] tidy error: /checkout/src/librustc/mir/visit.rs:774: trailing whitespace
[00:03:13] tidy error: /checkout/src/librustc/mir/visit.rs:776: trailing whitespace
[00:03:14] some tidy checks failed
[00:03:14] 
[00:03:14] 
[00:03:14] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/tidy" "/checkout/src" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "--no-vendor" "--quiet"
[00:03:14] 
[00:03:14] 
[00:03:14] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
[00:03:14] Build completed unsuccessfully in 0:00:46
[00:03:14] Build completed unsuccessfully in 0:00:46
[00:03:14] make: *** [tidy] Error 1
[00:03:14] Makefile:68: recipe for target 'tidy' failed
The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:0070f1eb
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
Sun Feb  3 12:54:38 UTC 2019
---
travis_time:end:00a64d60:start=1549198479481187588,finish=1549198479486293567,duration=5105979
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:00c818df
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb --batch -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:00ad4ffd
travis_time:start:00ad4ffd
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:26842de1
$ dmesg | grep -i kill

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@bors
Copy link
Contributor

bors commented Feb 7, 2019

☔ The latest upstream changes (presumably #58254) made this pull request unmergeable. Please resolve the merge conflicts.

@spastorino
Copy link
Member

spastorino commented Feb 11, 2019

After conversations about MIR 2.0, I think this PR doesn't make sense anymore as is. In any case this is being discussed in Zulip.

@spastorino spastorino closed this Feb 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-NLL Area: Non-lexical lifetimes (NLL) S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants