Add a 'clear()' function to Context.

This includes adding `clear()` functions to its (transitive) members.
This commit is contained in:
Dan Gohman
2017-11-15 10:49:32 -08:00
parent 4c829f7c7f
commit 4d9aedbaca
10 changed files with 85 additions and 2 deletions

View File

@@ -81,6 +81,12 @@ impl DomForest {
}
}
/// Clear all data structures in this dominator forest.
pub fn clear(&mut self) {
self.values.clear();
self.stack.clear();
}
/// Swap the merged list with `buffer`, leaving the dominator forest empty.
///
/// This is typically called after a successful merge to extract the merged value list.
@@ -141,8 +147,7 @@ impl DomForest {
domtree: &DominatorTree,
liveness: &Liveness,
) -> Result<(), (Value, Value)> {
self.stack.clear();
self.values.clear();
self.clear();
self.values.reserve(va.len() + vb.len());
// Convert the two value lists into a merged sequence of nodes.
@@ -261,6 +266,13 @@ impl Coalescing {
}
/// Clear all data structures in this coalescing pass.
pub fn clear(&mut self) {
self.forest.clear();
self.values.clear();
self.split_values.clear();
}
/// Convert `func` to conventional SSA form and build virtual registers in the process.
pub fn conventional_ssa(
&mut self,