Commit 350995ac authored by qinsoon's avatar qinsoon

reset use count before doing use-def analysis

(inlining a function will copy ssa vars from the function, and they may
already have a use count)
parent fb644cda
......@@ -887,6 +887,9 @@ impl SSAVarEntry {
pub fn increase_use_count(&self) {
self.use_count.fetch_add(1, Ordering::SeqCst);
}
pub fn reset_use_count(&self) {
self.use_count.store(0, Ordering::SeqCst);
}
pub fn has_expr(&self) -> bool {
self.expr.is_some()
......
......@@ -66,6 +66,13 @@ impl CompilerPass for DefUse {
_ => panic!("expected instruction node in visit_inst()")
}
}
#[allow(unused_variables)]
fn start_function(&mut self, vm: &VM, func: &mut MuFunctionVersion) {
for entry in func.context.values.values() {
entry.reset_use_count();
}
}
#[allow(unused_variables)]
fn finish_function(&mut self, vm: &VM, func: &mut MuFunctionVersion) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment