Restructure code to avoid a heap allocation.
This commit is contained in:
@@ -543,7 +543,6 @@ where
|
|||||||
|
|
||||||
|
|
||||||
fn ebb_args_adjustement(&mut self, dest_ebb: Ebb, jump_args: &[Type]) {
|
fn ebb_args_adjustement(&mut self, dest_ebb: Ebb, jump_args: &[Type]) {
|
||||||
let ty_to_append: Option<Vec<Type>> =
|
|
||||||
if self.builder.ssa.predecessors(dest_ebb).is_empty() ||
|
if self.builder.ssa.predecessors(dest_ebb).is_empty() ||
|
||||||
self.builder.ebbs[dest_ebb].pristine
|
self.builder.ebbs[dest_ebb].pristine
|
||||||
{
|
{
|
||||||
@@ -551,6 +550,7 @@ where
|
|||||||
// so the jump arguments supplied here are this Ebb' arguments
|
// so the jump arguments supplied here are this Ebb' arguments
|
||||||
// However some of the arguments might already be there
|
// However some of the arguments might already be there
|
||||||
// in the Ebb so we have to check they're consistent
|
// in the Ebb so we have to check they're consistent
|
||||||
|
let dest_ebb_args_len = {
|
||||||
let dest_ebb_args = self.func.dfg.ebb_args(dest_ebb);
|
let dest_ebb_args = self.func.dfg.ebb_args(dest_ebb);
|
||||||
debug_assert!(
|
debug_assert!(
|
||||||
dest_ebb_args
|
dest_ebb_args
|
||||||
@@ -562,14 +562,12 @@ where
|
|||||||
"the jump argument supplied has not the \
|
"the jump argument supplied has not the \
|
||||||
same type as the corresponding dest ebb argument"
|
same type as the corresponding dest ebb argument"
|
||||||
);
|
);
|
||||||
|
dest_ebb_args.len()
|
||||||
|
};
|
||||||
self.builder.ebbs[dest_ebb].user_arg_count = jump_args.len();
|
self.builder.ebbs[dest_ebb].user_arg_count = jump_args.len();
|
||||||
Some(
|
for ty in jump_args.iter().skip(dest_ebb_args_len) {
|
||||||
jump_args
|
self.func.dfg.append_ebb_arg(dest_ebb, *ty);
|
||||||
.iter()
|
}
|
||||||
.skip(dest_ebb_args.len())
|
|
||||||
.cloned()
|
|
||||||
.collect(),
|
|
||||||
)
|
|
||||||
} else {
|
} else {
|
||||||
let dest_ebb_args = self.func.dfg.ebb_args(dest_ebb);
|
let dest_ebb_args = self.func.dfg.ebb_args(dest_ebb);
|
||||||
// The Ebb already has predecessors
|
// The Ebb already has predecessors
|
||||||
@@ -596,12 +594,6 @@ where
|
|||||||
"the jump argument supplied has not the \
|
"the jump argument supplied has not the \
|
||||||
same type as the corresponding dest ebb argument"
|
same type as the corresponding dest ebb argument"
|
||||||
);
|
);
|
||||||
None
|
|
||||||
};
|
|
||||||
if let Some(ty_args) = ty_to_append {
|
|
||||||
for ty in ty_args {
|
|
||||||
self.func.dfg.append_ebb_arg(dest_ebb, ty);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user