Commit ca38587e authored by qinsoon's avatar qinsoon

fix in trace scheduling

parent 24fe689e
Pipeline #746 passed with stages
in 29 minutes and 44 seconds
......@@ -681,8 +681,8 @@ impl Instruction_ {
&Instruction_::Throw(exn_obj) => format!("THROW {}", ops[exn_obj]),
&Instruction_::TailCall(ref call) => format!("TAILCALL {}", call.debug_str(ops)),
&Instruction_::Branch1(ref dest) => format!("BRANCH {}", dest.debug_str(ops)),
&Instruction_::Branch2{cond, ref true_dest, ref false_dest, ..} => {
format!("BRANCH2 {} {} {}", ops[cond], true_dest.debug_str(ops), false_dest.debug_str(ops))
&Instruction_::Branch2{cond, ref true_dest, ref false_dest, true_prob} => {
format!("BRANCH2 {} {}({}) {}", ops[cond], true_dest.debug_str(ops), true_prob, false_dest.debug_str(ops))
},
&Instruction_::Select{cond, true_val, false_val} => {
format!("SELECT if {} then {} else {}", ops[cond], ops[true_val], ops[false_val])
......
......@@ -178,27 +178,34 @@ fn find_next_block(cur_block: &Block, func: &MuFunctionVersion) -> Option<MuID>
.find(|edge| f_content.get_block(edge.target).trace_hint == TraceHint::FastPath);
if has_fastpath.is_some() {
Some(has_fastpath.unwrap().target)
let target = has_fastpath.unwrap().target;
trace_if!(LOG_TRACE_SCHEDULE, "found fastpath successor {} for block {}", target, cur_block);
Some(target)
} else {
// we need to find next path by examining probability
if succs.len() == 0 {
trace_if!(LOG_TRACE_SCHEDULE, "cannot find successors of block {}", cur_block);
None
} else {
trace_if!(LOG_TRACE_SCHEDULE, "successors: {:?}", succs);
let ideal_successors : Vec<&BlockEdge> = succs.iter().filter(|b| {
match f_content.get_block(b.target).trace_hint {
TraceHint::SlowPath | TraceHint::ReturnSink => false,
_ => true
}
}).collect();
trace_if!(LOG_TRACE_SCHEDULE,
"after filtering out slowpath/retsink, we have: {:?}", ideal_successors);
if ideal_successors.len() == 0 {
None
} else {
let mut hot_blk = succs[0].target;
let mut hot_prob = succs[0].probability;
let mut hot_blk = ideal_successors[0].target;
let mut hot_prob = ideal_successors[0].probability;
for edge in succs.iter() {
if edge.probability > hot_prob {
for edge in ideal_successors.iter() {
trace_if!(LOG_TRACE_SCHEDULE, "succ: {}/{}", edge.target, edge.probability);
if edge.probability >= hot_prob {
hot_blk = edge.target;
hot_prob = edge.probability;
}
......
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