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

Move LocalAnalyzer to rustc_mir::ssa_analyze #52208

Closed
wants to merge 2 commits into from

Conversation

bjorn3
Copy link
Member

@bjorn3 bjorn3 commented Jul 10, 2018

This is useful for other codegen backends as well.

@rust-highfive
Copy link
Collaborator

r? @estebank

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 10, 2018
@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-5.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.

[00:03:47] travis_fold:start:tidy
travis_time:start:tidy
tidy check
[00:03:47] tidy error: /checkout/src/librustc_codegen_llvm/mir/analyze.rs: incorrect license
[00:03:47] tidy error: /checkout/src/librustc_codegen_llvm/mir/analyze.rs: missing trailing newline
[00:03:49] some tidy checks failed
[00:03:49] 
[00:03:49] 
[00:03:49] 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:49] 
[00:03:49] 
[00:03:49] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
[00:03:49] Build completed unsuccessfully in 0:00:52
[00:03:49] Build completed unsuccessfully in 0:00:52
[00:03:49] Makefile:79: recipe for target 'tidy' failed
[00:03:49] make: *** [tidy] Error 1

The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:002933f8
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
---
travis_time:end:09b585b4:start=1531223009751336422,finish=1531223009761388773,duration=10052351
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:0855aaf7
$ head -30 ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
head: cannot open ‘./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers’ for reading: No such file or directory
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:01e68dcb
$ 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)

@estebank
Copy link
Contributor

It's gonna take me a while to get to this. @arielb1 can you step in?

@bors
Copy link
Contributor

bors commented Jul 13, 2018

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

@eddyb
Copy link
Member

eddyb commented Jul 13, 2018

r? @eddyb (you can always r? me on codegen-related things unless @nagisa, @arielb1 or @alexcrichton want to take them)

@rust-highfive rust-highfive assigned eddyb and unassigned estebank Jul 13, 2018
use rustc::ty::layout::{TyLayout, LayoutError};

pub trait LocalAnalyzerCallbacks<'tcx> {
fn ty_ssa_allowed(&self, ty: Ty<'tcx>) -> bool;
Copy link
Member

Choose a reason for hiding this comment

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

It would be more useful for this to take a TyLayout.

debug!("local {} has type {:?}", index, ty);
if !analyzer.callbacks.ty_ssa_allowed(ty) {
analyzer.not_ssa(mir::Local::new(index));
}
Copy link
Member

Choose a reason for hiding this comment

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

This part could arguably stay in rustc_codegen_llvm.

Copy link
Member Author

Choose a reason for hiding this comment

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

The ty_ssa_allowed function is defined by the user of non_ssa_locals.

}

if let mir::ProjectionElem::Field(..) = proj.elem {
if self.callbacks.ty_ssa_allowed(base_ty.to_ty(self.tcx)) {
Copy link
Member

Choose a reason for hiding this comment

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

Can you check that you need this if?

self.tcx.layout_of(ty::ParamEnv::reveal_all().and(ty))
.unwrap_or_else(|e| match e {
LayoutError::SizeOverflow(_) => self.tcx.sess.fatal(&e.to_string()),
_ => bug!("failed to get layout for `{}`: {}", ty, e)
Copy link
Member

@eddyb eddyb Jul 13, 2018

Choose a reason for hiding this comment

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

This is not in rustc_codegen_llvm so ideally we would treat a failure to get the error just like some arbitrary layout that we know nothing about, instead of a fatal error.

@eddyb
Copy link
Member

eddyb commented Jul 13, 2018

IMO this shouldn't live in rustc_mir unless it's somewhat more general (identifying variables that are SSA-like without any concerns for layout). If layout is involved I'd rather it be in the rustc_codegen_ssa crate proposed in #45274 (@irinagpopa will work on that, FWIW).

@bjorn3
Copy link
Member Author

bjorn3 commented Jul 14, 2018

Got it

@bjorn3 bjorn3 closed this Jul 14, 2018
@eddyb
Copy link
Member

eddyb commented Jul 14, 2018

Note that layout may not need to be directly involved (i.e. this pass could just check for multiple writes, borrows, non-SSA reads, those sorts of things), and rustc_codegen_llvm would just mark each non-immediate/pair local as non-SSA to handle the layout side of things.
But I haven't checked for sure - you could try #52208 (comment) and see if anything breaks.

@bjorn3 bjorn3 deleted the extract_ssa_analyzer branch July 10, 2019 18:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants