Move LocalAnalyzer to rustc_mir::ssa_analyze#52208
Move LocalAnalyzer to rustc_mir::ssa_analyze#52208bjorn3 wants to merge 2 commits intorust-lang:masterfrom
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.
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.
This part could arguably stay in rustc_codegen_llvm.
There was a problem hiding this comment.
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.
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.
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.