-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Conversation
r? @estebank (rust_highfive has picked a reviewer for you, use r? to override) |
The job Click to expand the log.
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 |
It's gonna take me a while to get to this. @arielb1 can you step in? |
☔ The latest upstream changes (presumably #51987) made this pull request unmergeable. Please resolve the merge conflicts. |
r? @eddyb (you can always r? me on codegen-related things unless @nagisa, @arielb1 or @alexcrichton want to take them) |
use rustc::ty::layout::{TyLayout, LayoutError}; | ||
|
||
pub trait LocalAnalyzerCallbacks<'tcx> { | ||
fn ty_ssa_allowed(&self, ty: Ty<'tcx>) -> bool; |
There was a problem hiding this comment.
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)); | ||
} |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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)) { |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
IMO this shouldn't live in |
Got it |
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 |
This is useful for other codegen backends as well.