Skip to content

Commit d2b84b0

Browse files
committed
keep LocalWithRefs operands live in calls and yields
1 parent e8c6786 commit d2b84b0

File tree

1 file changed

+41
-15
lines changed

1 file changed

+41
-15
lines changed

compiler/rustc_mir_dataflow/src/impls/live_borrows.rs

Lines changed: 41 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -786,20 +786,7 @@ where
786786
debug!("gen {:?}", local);
787787
self._trans.gen(local);
788788
}
789-
_ => {
790-
if let Some(node_idx) = self.borrow_deps.locals_to_node_indexes.get(&local) {
791-
let node = self.borrow_deps.dep_graph.node(*node_idx);
792-
793-
// these are `Local`s that contain references/pointers or are raw pointers
794-
// that were assigned to raw pointers, which were cast to usize. Hence we
795-
// need to treat them as uses of the references/pointers that they
796-
// refer/correspond to.
797-
if let NodeKind::LocalWithRefs(_) = node.data {
798-
debug!("gen {:?}", local);
799-
self._trans.gen(local);
800-
}
801-
}
802-
}
789+
_ => {}
803790
}
804791

805792
self.super_place(place, context, location);
@@ -825,7 +812,26 @@ where
825812
self._trans.kill(destination.local);
826813

827814
for arg in args {
828-
self.visit_operand(arg, location)
815+
match arg {
816+
Operand::Copy(place) | Operand::Move(place) => {
817+
if let Some(node_idx) =
818+
self.borrow_deps.locals_to_node_indexes.get(&place.local)
819+
{
820+
let node = self.borrow_deps.dep_graph.node(*node_idx);
821+
822+
// these are `Local`s that contain references/pointers or are raw pointers
823+
// that were assigned to raw pointers, which were cast to usize. Since the
824+
// function call is free to use these in any form, we need to gen them here.
825+
if let NodeKind::LocalWithRefs(_) = node.data {
826+
debug!("gen {:?}", place.local);
827+
self._trans.gen(place.local);
828+
}
829+
} else {
830+
self.super_operand(arg, location)
831+
}
832+
}
833+
_ => {}
834+
}
829835
}
830836
}
831837
_ => self.super_terminator(terminator, location),
@@ -837,6 +843,26 @@ where
837843
debug!("killing {:?}", resume_arg.local);
838844
self._trans.kill(resume_arg.local);
839845

846+
match value {
847+
Operand::Copy(place) | Operand::Move(place) => {
848+
if let Some(node_idx) =
849+
self.borrow_deps.locals_to_node_indexes.get(&place.local)
850+
{
851+
let node = self.borrow_deps.dep_graph.node(*node_idx);
852+
853+
// these are `Local`s that contain references/pointers or are raw pointers
854+
// that were assigned to raw pointers, which were cast to usize. Since the
855+
// function call is free to use these in any form, we need to gen them here.
856+
if let NodeKind::LocalWithRefs(_) = node.data {
857+
debug!("gen {:?}", place.local);
858+
self._trans.gen(place.local);
859+
}
860+
} else {
861+
self.super_operand(value, location)
862+
}
863+
}
864+
_ => {}
865+
}
840866
self.visit_operand(value, location)
841867
}
842868
_ => self.super_terminator(terminator, location),

0 commit comments

Comments
 (0)