-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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 Deaggregate pass to post_borrowck_cleanup #71946
Changes from all commits
fc6b16c
454871f
a10ac7d
ef005bb
310ac1a
803e048
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,9 +27,9 @@ use rustc_trait_selection::traits; | |
|
||
use crate::const_eval::error_to_const_error; | ||
use crate::interpret::{ | ||
self, compile_time_machine, intern_const_alloc_recursive, AllocId, Allocation, Frame, ImmTy, | ||
Immediate, InternKind, InterpCx, LocalState, LocalValue, Memory, MemoryKind, OpTy, | ||
Operand as InterpOperand, PlaceTy, Pointer, ScalarMaybeUninit, StackPopCleanup, | ||
self, compile_time_machine, AllocId, Allocation, Frame, ImmTy, Immediate, InterpCx, LocalState, | ||
LocalValue, Memory, MemoryKind, OpTy, Operand as InterpOperand, PlaceTy, Pointer, | ||
ScalarMaybeUninit, StackPopCleanup, | ||
}; | ||
use crate::transform::{MirPass, MirSource}; | ||
|
||
|
@@ -381,6 +381,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> { | |
match f(self) { | ||
Ok(val) => Some(val), | ||
Err(error) => { | ||
trace!("InterpCx operation failed: {:?}", error); | ||
// Some errors shouldn't come up because creating them causes | ||
// an allocation, which we should avoid. When that happens, | ||
// dedicated error variants should be introduced instead. | ||
|
@@ -707,11 +708,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> { | |
ScalarMaybeUninit::Scalar(l), | ||
ScalarMaybeUninit::Scalar(r), | ||
)) => l.is_bits() && r.is_bits(), | ||
interpret::Operand::Indirect(_) if mir_opt_level >= 2 => { | ||
let mplace = op.assert_mem_place(&self.ecx); | ||
intern_const_alloc_recursive(&mut self.ecx, InternKind::ConstProp, mplace, false); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why was this needed / why is this no longer needed? Seems like a surprising change to me. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was buggy code that basically wasn't doing anything before this PR and was causing crashes with this PR. It's a leftover that multiple refactorings made obsolete. I can remove it on master if you prefer. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No it's fine. One less interning entry point to worry about. :) |
||
true | ||
} | ||
interpret::Operand::Indirect(_) if mir_opt_level >= 2 => true, | ||
_ => false, | ||
} | ||
} | ||
|
@@ -793,10 +790,11 @@ impl<'tcx> Visitor<'tcx> for CanConstProp { | |
// end of the block anyway, and inside the block we overwrite previous | ||
// states as applicable. | ||
ConstPropMode::OnlyInsideOwnBlock => {} | ||
mode @ ConstPropMode::FullConstProp => *mode = ConstPropMode::OnlyInsideOwnBlock, | ||
other => { | ||
trace!( | ||
"local {:?} can't be propagated because of multiple assignments", | ||
local, | ||
"local {:?} can't be propagated because of multiple assignments. Previous state: {:?}", | ||
local, other, | ||
); | ||
*other = ConstPropMode::NoPropagation; | ||
} | ||
|
@@ -909,6 +907,9 @@ impl<'mir, 'tcx> MutVisitor<'tcx> for ConstPropagator<'mir, 'tcx> { | |
} | ||
} else { | ||
match statement.kind { | ||
StatementKind::SetDiscriminant { .. } => { | ||
self.use_ecx(|this| this.ecx.statement(statement)); | ||
} | ||
StatementKind::StorageLive(local) | StatementKind::StorageDead(local) => { | ||
let frame = self.ecx.frame_mut(); | ||
frame.locals[local].value = | ||
|
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.
Hm... of it's (semi-)public, maybe it should have a doc comment?
Also for consistency,
terminator
should probably get the same treatment.