Cranelift DFG: make inst clone deep-clone varargs lists. (#5727)

When investigating #5716, I found that rematerialization of a `call`, in
addition to blowing up for other reasons, caused aliasing of the varargs
list (the `EntityList` in the `ListPool`), such that editing the args of
the second copy of the call instruction inadvertently updated the first
as well.

This PR modifies `DataFlowGraph::clone_inst` so that it always clones
the varargs list if present. This shouldn't have any functional impact
on Cranelift today, because we don't rematerialize any instructions with
varargs; but it's important to get it right to avoid a bug later!
This commit is contained in:
Chris Fallin
2023-02-06 17:21:09 -08:00
committed by GitHub
parent c8a6adf825
commit 673b448cfe
3 changed files with 111 additions and 0 deletions

View File

@@ -123,6 +123,15 @@ impl BlockCall {
pub fn display<'a>(&self, pool: &'a ValueListPool) -> DisplayBlockCall<'a> {
DisplayBlockCall { block: *self, pool }
}
/// Deep-clone the underlying list in the same pool. The returned
/// list will have identical contents but changes to this list
/// will not change its contents or vice-versa.
pub fn deep_clone(&self, pool: &mut ValueListPool) -> Self {
Self {
values: self.values.deep_clone(pool),
}
}
}
/// Wrapper for the context needed to display a [BlockCall] value.