add jp id

This commit is contained in:
Folkert 2021-01-13 21:25:14 +01:00
parent e1b5076a87
commit d4e7ba552a

View file

@ -913,8 +913,9 @@ pub fn optimize_when<'a>(
for (index, branch) in indexed_branches.into_iter() { for (index, branch) in indexed_branches.into_iter() {
let ((branch_index, choice), opt_jump) = create_choices(&target_counts, index, branch); let ((branch_index, choice), opt_jump) = create_choices(&target_counts, index, branch);
if let Some(jump) = opt_jump { if let Some((index, body)) = opt_jump {
jumps.push(jump); let id = JoinPointId(env.unique_symbol());
jumps.push((index, id, body));
} }
choices.insert(branch_index, choice); choices.insert(branch_index, choice);
@ -1336,7 +1337,7 @@ fn decide_to_branching<'a>(
cond_layout: Layout<'a>, cond_layout: Layout<'a>,
ret_layout: Layout<'a>, ret_layout: Layout<'a>,
decider: Decider<'a, Choice<'a>>, decider: Decider<'a, Choice<'a>>,
jumps: &Vec<(u64, Stmt<'a>)>, jumps: &Vec<(u64, JoinPointId, Stmt<'a>)>,
) -> Stmt<'a> { ) -> Stmt<'a> {
use Choice::*; use Choice::*;
use Decider::*; use Decider::*;
@ -1345,9 +1346,9 @@ fn decide_to_branching<'a>(
match decider { match decider {
Leaf(Jump(label)) => { Leaf(Jump(label)) => {
let (_, expr) = jumps let (_, _, expr) = jumps
.iter() .iter()
.find(|(l, _)| l == &label) .find(|(l, _, _)| l == &label)
.expect("jump not in list of jumps"); .expect("jump not in list of jumps");
expr.clone() expr.clone()
} }