Auto merge of #117359 - tmiasko:call-def, r=cjgillot
Fix def-use check for call terminators Fixes #117331.
This commit is contained in:
commit
6d069a0ac7
4 changed files with 93 additions and 30 deletions
|
@ -36,7 +36,7 @@ pub fn non_ssa_locals<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
|||
|
||||
// Arguments get assigned to by means of the function being called
|
||||
for arg in mir.args_iter() {
|
||||
analyzer.assign(arg, DefLocation::Argument);
|
||||
analyzer.define(arg, DefLocation::Argument);
|
||||
}
|
||||
|
||||
// If there exists a local definition that dominates all uses of that local,
|
||||
|
@ -74,7 +74,7 @@ struct LocalAnalyzer<'mir, 'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> {
|
|||
}
|
||||
|
||||
impl<'mir, 'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> LocalAnalyzer<'mir, 'a, 'tcx, Bx> {
|
||||
fn assign(&mut self, local: mir::Local, location: DefLocation) {
|
||||
fn define(&mut self, local: mir::Local, location: DefLocation) {
|
||||
let kind = &mut self.locals[local];
|
||||
match *kind {
|
||||
LocalKind::ZST => {}
|
||||
|
@ -162,7 +162,7 @@ impl<'mir, 'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> Visitor<'tcx>
|
|||
debug!("visit_assign(place={:?}, rvalue={:?})", place, rvalue);
|
||||
|
||||
if let Some(local) = place.as_local() {
|
||||
self.assign(local, DefLocation::Body(location));
|
||||
self.define(local, DefLocation::Assignment(location));
|
||||
if self.locals[local] != LocalKind::Memory {
|
||||
let decl_span = self.fx.mir.local_decls[local].source_info.span;
|
||||
if !self.fx.rvalue_creates_operand(rvalue, decl_span) {
|
||||
|
@ -183,9 +183,14 @@ impl<'mir, 'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> Visitor<'tcx>
|
|||
|
||||
fn visit_local(&mut self, local: mir::Local, context: PlaceContext, location: Location) {
|
||||
match context {
|
||||
PlaceContext::MutatingUse(MutatingUseContext::Call)
|
||||
| PlaceContext::MutatingUse(MutatingUseContext::Yield) => {
|
||||
self.assign(local, DefLocation::Body(location));
|
||||
PlaceContext::MutatingUse(MutatingUseContext::Call) => {
|
||||
let call = location.block;
|
||||
let TerminatorKind::Call { target, .. } =
|
||||
self.fx.mir.basic_blocks[call].terminator().kind
|
||||
else {
|
||||
bug!()
|
||||
};
|
||||
self.define(local, DefLocation::CallReturn { call, target });
|
||||
}
|
||||
|
||||
PlaceContext::NonUse(_)
|
||||
|
@ -237,6 +242,8 @@ impl<'mir, 'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> Visitor<'tcx>
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
PlaceContext::MutatingUse(MutatingUseContext::Yield) => bug!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue